예제 #1
0
        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);
                        }
                    }
                }
            }
        }
예제 #2
0
 public void Add(GuidDataObject obj)
 {
     if (obj != null)
     {
         map.Add(obj.GetGuid(), obj);
     }
 }
예제 #3
0
        public override string ToString()
        {
            if (Guid == Guid.Empty)
            {
                return("<null>");
            }
            GuidDataObject obj = Get();

            return(obj == null ? ("{" + Guid.ToString() + "}") : obj.ToString());
        }
예제 #4
0
 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;
     }
 }
예제 #5
0
 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));
 }
예제 #6
0
        public override Guid GetUIValue()
        {
            GuidDataObject obj = comboBox.SelectedIndex < 0 ? null : items[comboBox.SelectedIndex];

            return(obj == null ? new Guid() : obj.GetGuid());
        }