private static UTinyType.Reference ParseTypeReference(object obj, bool updateReference = true) { if (obj is UTinyType.Reference) { return((UTinyType.Reference)obj); } UTinyId id; string name; var reference = TryParseReference(obj, out id, out name) ? new UTinyType.Reference(id, name) : new UTinyType.Reference(); return(updateReference ? UTinyUpdater.UpdateReference(reference) : reference); }
private static UTinySystem.Reference ParseSystemReference(object obj) { if (obj is UTinySystem.Reference) { return((UTinySystem.Reference)obj); } UTinyId id; string name; var reference = TryParseReference(obj, out id, out name) ? new UTinySystem.Reference(id, name) : new UTinySystem.Reference(); return(UTinyUpdater.UpdateReference(reference)); }
private static void ParseUTinyList(IRegistry registry, UTinyList uTinyList, IDictionary <string, object> dictionary) { var typeReference = ParseTypeReference(GetValue(dictionary, "Type"), false); IList <object> itemsList; if (TryGetValue(dictionary, "Items", out itemsList)) { foreach (var obj in itemsList) { var valueDictionary = obj as IDictionary <string, object>; if (valueDictionary != null) { if (valueDictionary.ContainsKey("$TypeId")) { uTinyList.Add(ParseCustomObjectType(registry, valueDictionary)); } // @HACK We assume an object `Properties` OR `Type` keys is a `UTinyObject` else if (valueDictionary.ContainsKey("Properties") || valueDictionary.ContainsKey("Type")) { var @object = new UTinyObject(registry, typeReference, null, false); @object.Refresh(null, true); ParseUTinyObject(registry, @object, valueDictionary); uTinyList.Add(@object); } else { throw new NotImplementedException("CommandStream.FrontEnd Failed to deserialize UTinyList item"); } } else { uTinyList.Add(obj); } } } uTinyList.Type = UTinyUpdater.UpdateReference(uTinyList.Type); }