public static DicWrapperID <T> GenerateDicWrapperID <T>(List <KeyValuePair <int, T> > values) where T : class { DicWrapperID <T> newDic = new DicWrapperID <T>(); foreach (KeyValuePair <int, T> e in values) { PairWrapperID <T> wrap = new PairWrapperID <T>(); wrap.key = e.Key; wrap.value = e.Value; newDic.objects.Add(wrap); } return(newDic); }
public static Dictionary <int, T> GenerateDicFromJson <T>(DicWrapperID <T> wrapper) where T : class { Dictionary <int, T> dic = new Dictionary <int, T>(); foreach (PairWrapperID <T> obj in wrapper.objects) { if (!dic.ContainsKey(obj.key)) { dic.Add(obj.key, obj.value); } } return(dic); }