Files
marketdata/MarketDataLib/Generator/CMTrend/CMTPricingExceptions.cs
2024-02-22 14:52:53 -05:00

71 lines
2.2 KiB
C#

using MarketData.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MarketData.Generator.CMTrend
{
public class CMTPricingExceptions:List<CMTPricingException>
{
public NVPCollections ToNVPCollections()
{
NVPCollections nvpCollections=new NVPCollections();
foreach(CMTPricingException pricingException in this)
{
nvpCollections.Add(pricingException.ToNVPCollection());
}
return nvpCollections;
}
public static CMTPricingExceptions FromNVPCollections(NVPCollections nvpCollections)
{
CMTPricingExceptions pricingExcpetions=new CMTPricingExceptions();
foreach(NVPCollection nvpCollection in nvpCollections)
{
pricingExcpetions.Add(CMTPricingException.FromNVPCollection(nvpCollection));
}
return pricingExcpetions;
}
public void AddFromNVPCollection(NVPCollection nvpCollection)
{
Add(CMTPricingException.FromNVPCollection(nvpCollection));
}
}
public class CMTPricingException
{
public CMTPricingException()
{
}
public CMTPricingException(CMTPricingException pricingException)
{
this.Symbol=pricingException.Symbol;
this.ExceptionCount=pricingException.ExceptionCount;
}
public CMTPricingException(String symbol,int exceptionCount)
{
this.Symbol=symbol;
this.ExceptionCount=exceptionCount;
}
public String Symbol { get; set; }
public int ExceptionCount { get; set; }
public virtual NVPCollection ToNVPCollection()
{
NVPCollection nvpCollection=new NVPCollection();
nvpCollection.Add(new NVP("Symbol",Symbol.ToString()));
nvpCollection.Add(new NVP("ExceptionCount",ExceptionCount.ToString()));
return nvpCollection;
}
public static CMTPricingException FromNVPCollection(NVPCollection nvpCollection)
{
CMTPricingException pricingException=new CMTPricingException();
NVPDictionary nvpDictionary=nvpCollection.ToDictionary();
pricingException.Symbol=nvpDictionary["Symbol"].Get<String>();
pricingException.ExceptionCount=nvpDictionary["ExceptionCount"].Get<int>();
return pricingException;
}
}
}