Ejemplo n.º 1
0
    static List<PropertyItem> ParseObject(PropertyGrid grid, Object objItem) {
      if (null == objItem)
        return new List<PropertyItem>();

      List<PropertyItem> pc = new List<PropertyItem>();
      Type t = objItem.GetType();
      var props = t.GetProperties();

      foreach (PropertyInfo pinfo in props) {
        Boolean isBrowsable = true;
        BrowsableAttribute b = PropertyItem.GetAttribute<BrowsableAttribute>(pinfo);
        if (b != null)
          isBrowsable = b.Browsable;

        var args = new OnPreparePropertyEventArgs { Browsable = true };
        grid.doOnPrepareProperty(pinfo, args);
        isBrowsable = isBrowsable && args.Browsable;

        if (isBrowsable) {
          var readOnly = false;
          var required = false;

          // SL3 Only
          var attrRO = PropertyItem.GetAttribute<ReadOnlyAttribute>(pinfo);
          if (attrRO != null)
            readOnly = attrRO.IsReadOnly;
          var attrRQ = PropertyItem.GetAttribute<RequiredAttribute>(pinfo);
          if (attrRQ != null)
            required = attrRQ.IsRequired;


          try {
            Object value = pinfo.GetValue(objItem, null);
            PropertyItem prop = new PropertyItem(grid, objItem, value, pinfo, readOnly, required);
            pc.Add(prop);
          } catch { }
        }
      }

      return pc;
    }
Ejemplo n.º 2
0
 internal void doOnPrepareProperty(PropertyInfo propInfo, OnPreparePropertyEventArgs args){
   var eve = this.OnPrepareProperty;
   if(eve != null)
     eve(propInfo, args);
 }