public override Item InitItem(JObject itemsDestination, Source source) { try { var typeId = (int)itemsDestination.GetValue("typeID"); var sq = (bool)itemsDestination.GetValue("sq"); var length = (int)itemsDestination.GetValue("length"); var cot = (int)itemsDestination.GetValue("cot"); var isNegative = (bool)itemsDestination.GetValue("isNegative"); var isTest = (bool)itemsDestination.GetValue("isTest"); var oa = (int)itemsDestination.GetValue("oa"); var ca = (int)itemsDestination.GetValue("ca"); var item60870 = new Item60870(typeId, sq, length, cot, isNegative, isTest, oa, ca); Dictionary <ItemSource, ItemDestination> dictionary = new Dictionary <ItemSource, ItemDestination>(); var index = 0; foreach (var jToken in itemsDestination["objects"]) { var itemObj = (JObject)jToken; var addrObj = (int)itemObj.GetValue("addrObj"); var attributeObj = itemObj["attributeObj"]; var listAttributeObj = attributeObj.First().ToList(); foreach (var itemAttributeObj in listAttributeObj) { //Создаем Destination var item = itemAttributeObj; var typeElement = (string)item["typeElement"]; var indexElement = index++; //Получить ItemDestination var itemDestination = new Obj(addrObj, typeElement, indexElement); //Создаем Source var attributeElement = new JObject(item["attributeElement"].Parent); //Получить ItemSource var itemSource = source.InitItemSource(attributeElement); if (itemSource != null) { dictionary.Add(itemSource, itemDestination); } } } return(new ItemBridge(item60870, dictionary)); } catch { Log.Write(new Exception("IEC60870_Server.InitItem()"), Log.Code.ERROR); return(null); } }
public ItemBridge(Item60870 item, Dictionary <ItemSource, ItemDestination> dictionary) { Item = item; Dictionary = dictionary; }