You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

44 lines
1.2 KiB

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);
}
}
}
}