private static IEnumerable <GuidDataObject> ListChildObjects(GuidDataObject obj, Type type) { if (obj == null) { yield break; } if (Match(obj, type)) { yield return(obj); } if (!(obj is ISearchable)) { yield break; } foreach (Accessor field in FieldAccessor.GetForObject(obj).ToList()) { Type fieldType = field.GetAccessorType(); if (IsGenericList(fieldType)) { IList list = field.Get() as IList; foreach (object item in list) { foreach (GuidDataObject match in ListChildObjects(item as GuidDataObject, type)) { yield return(match); } } } } }
public void Add(GuidDataObject obj) { if (obj != null) { map.Add(obj.GetGuid(), obj); } }
public override string ToString() { if (Guid == Guid.Empty) { return("<null>"); } GuidDataObject obj = Get(); return(obj == null ? ("{" + Guid.ToString() + "}") : obj.ToString()); }
public void Set(GuidDataObject value) { _guid = value == null ? Guid.Empty : value.GetGuid(); if (value != null && Context == null) { JsonSerializer.MapContext context = new JsonSerializer.MapContext(); context.Add(value); this.Context = context; } }
public T GetObject <T>(Guid guid) where T : GuidDataObject { if (map.ContainsKey(guid)) { GuidDataObject obj = map[guid]; if (obj is T) { return((T)obj); } } return(default(T)); }
public override Guid GetUIValue() { GuidDataObject obj = comboBox.SelectedIndex < 0 ? null : items[comboBox.SelectedIndex]; return(obj == null ? new Guid() : obj.GetGuid()); }