using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Serialization;
|
|
|
|
namespace ButcherFactory.SegmentProductionAuto_
|
|
{
|
|
[XmlType("KeyValue"), XmlRoot("KeyValue")]
|
|
public class SerializableKeyValuePair<TKey, TValue>
|
|
{
|
|
public TKey Key { get; set; }
|
|
public TValue Value { get; set; }
|
|
}
|
|
|
|
public static class SerializableKeyValuePairExtensions
|
|
{
|
|
public static SerializableKeyValuePair<TKey, TValue> ToSerializablePair<TKey, TValue>(this KeyValuePair<TKey, TValue> pair)
|
|
{
|
|
return new SerializableKeyValuePair<TKey, TValue> { Key = pair.Key, Value = pair.Value };
|
|
}
|
|
}
|
|
|
|
public class WeightDetails
|
|
{
|
|
|
|
[XmlIgnore]
|
|
public Dictionary<long, List<decimal>> Cache { get; set; }
|
|
|
|
[XmlArray("Cache")]
|
|
public SerializableKeyValuePair<long, List<decimal>>[] CacheArray
|
|
{
|
|
get
|
|
{
|
|
return Cache == null ? null : Cache.Select(p => p.ToSerializablePair()).ToArray();
|
|
}
|
|
set
|
|
{
|
|
Cache = value == null ? null : value.ToDictionary(p => p.Key, p => p.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|