using System.Collections.Generic;
using MarketData.Utils;

namespace MarketData.Generator.MGSHMomentum
{
  public class MGSHSlotPositions : List<MGSHSlotPosition>
  {
    public MGSHSlotPositions()
    {
    }
    public MGSHSlotPositions(int slot,MGSHPositions positions)
    {
      for(int index=0;index<positions.Count;index++)
      {
        Add(new MGSHSlotPosition(slot,positions[index]));
      }
    }
    public NVPCollections ToNVPCollections()
    {
      NVPCollections nvpCollections=new NVPCollections();
      foreach(MGSHSlotPosition position in this)
      {
        nvpCollections.Add(position.ToNVPCollection());
      }
      return nvpCollections;
    }
    public static MGSHSlotPositions FromNVPCollections(NVPCollections nvpCollections)
    {
      MGSHSlotPositions positions=new MGSHSlotPositions();
      foreach(NVPCollection nvpCollection in nvpCollections)
      {
        positions.Add(MGSHSlotPosition.FromNVPCollection(nvpCollection)); 
      }
      return positions;
    }
  }
  public class MGSHSlotPosition : MGSHPosition
  {
    public MGSHSlotPosition()
    {
    }
    public MGSHSlotPosition(int slot,MGSHPosition position) : base(position)
    {
      Slot=slot;
    }
    public MGSHSlotPosition(MGSHPosition position) : base(position)
    {
    }
    public int Slot{get;set;}
    public MGSHPosition ToPosition()
    {
      MGSHPosition position = new MGSHPosition(this);
      return position;
    }
    public override NVPCollection ToNVPCollection()
    {
      NVPCollection nvpCollection=base.ToNVPCollection();
      nvpCollection.Insert(0,new NVP("Slot",Slot.ToString()));
      return nvpCollection;
    }
    public static new MGSHSlotPosition FromNVPCollection(NVPCollection nvpCollection)
    {
      NVPDictionary nvpDictionary=nvpCollection.ToDictionary();
      MGSHPosition position=MGSHPosition.FromNVPCollection(nvpCollection);
      MGSHSlotPosition slotPosition=new MGSHSlotPosition(position);
      slotPosition.Slot=nvpDictionary["Slot"].Get<int>();
      return slotPosition;
    }
  }
}
