Пример #1
0
 void LookupItem()
 {
     if (_self.txtID.Text == _lookupKey)
     {
         return;
     }
     _lookupKey = _self.txtID.Text;
     _self.panelPropertyControl.Controls.Clear();
     try {
         var obj = _storage[int.Parse(_self.txtID.Text)];
         _self.txtValue.Text = obj.ToString();
         foreach (var key in CoreUT.SortInheritanceDAG(obj.GetType()))
         {
             var control = PropertyControlFactory.NewInstance(key);
             if (control != null)
             {
                 control.TargetObject = obj;
                 control.Dock         = DockStyle.Fill;
                 _self.panelPropertyControl.Controls.Add(control);
             }
         }
     }
     catch (Exception) {
         _self.txtID.Focus();
         _self.txtID.SelectAll();
         _self.txtValue.Text = "(none)";
     }
 }
        public static PropertyControl NewInstance(object target)
        {
            if (target == null)
            {
                return(null);
            }
            var control = CoreUT.SortInheritanceDAG(target.GetType())
                          .Select(type => PropertyControlFactory.NewInstance(type))
                          .WhereNotNull()
                          .FirstOrDefault();

            if (control != null)
            {
                control.TargetObject = target;
            }
            return(control);
        }
Пример #3
0
 PropertyControl GetControl(Type targetType)
 {
     foreach (Type key in Hisui.CoreUT.SortInheritanceDAG(targetType))
     {
         if (_controls.ContainsKey(key))
         {
             return(_controls[key]);
         }
         var control = PropertyControlFactory.NewInstance(key);
         if (control != null)
         {
             _controls.Add(key, control);
             return(control);
         }
     }
     return(null);
 }