public void SetDescription(object _parent, PropertyInfo _pi) { De de = Attribute.GetCustomAttribute(_pi, typeof(De)) as De; if (de == null) { return; } HideAttribute hide = Attribute.GetCustomAttribute(_pi, typeof(HideAttribute)) as HideAttribute; if (hide != null) { return; } if (descs == null) { return; } PropertyDescriptor pd = TypeDescriptor.GetProperties(_pi.DeclaringType)[_pi.Name]; de = (De)pd.Attributes[typeof(De)]; string ckey = _parent.GetType().Name + "." + _pi.Name; Desc desc = descs[_parent.GetType().Name + "." + _pi.Name]; if (desc == null) { desc = new Desc(); } de.Acc = desc.accsess; de.Description = desc.description; BrowsableAttribute ba = (BrowsableAttribute)pd.Attributes[typeof(BrowsableAttribute)]; if (ba != null) { FieldInfo isBrowsable = ba.GetType().GetField("Browsable", BindingFlags.IgnoreCase | BindingFlags.NonPublic | BindingFlags.Instance); if (de.Browsable) { isBrowsable.SetValue(ba, desc.accsess.CheckUser(User.current)); } } return; }
void GetExec(object _parent, PropertyInfo _pi, Descs _descsOut) { De de = Attribute.GetCustomAttribute(_pi, typeof(De)) as De; if (de == null) { return; } PropertyDescriptor pd = TypeDescriptor.GetProperties(_pi.DeclaringType)[_pi.Name]; de = (De)pd.Attributes[typeof(De)]; Desc desc = new Desc(); desc.accsess = de.Acc; desc.description = de.Description; desc.actual = true; string ckey = _parent.GetType().Name + "." + _pi.Name; _descsOut[ckey] = desc; }
Descs GetDescription(ParMainLite _parMainLite) { Descs ret = new Descs(); GetExec(_parMainLite, ret); if (descs == null) { return(null); } foreach (string ckey in descs.Keys) { if (ret[ckey] == null) { Desc desc = descs[ckey]; desc.actual = false; ret[ckey] = desc; } } return(ret); }
public KeyDesc(string _key, Desc _desc) { key = _key; desc = _desc; }