private void InitPropertyBag() { PropertyInfo pi; Type t = typeof(CriteriaProperty); // _selectedObject.GetType(); PropertyInfo[] props = t.GetProperties(); // Display information for all properties. for (int i = 0; i < props.Length; i++) { pi = props[i]; object[] myAttributes = pi.GetCustomAttributes(true); string category = ""; string description = ""; bool isreadonly = false; bool isbrowsable = true; object defaultvalue = null; string userfriendlyname = ""; string typeconverter = ""; string designertypename = ""; string helptopic = ""; bool bindable = true; string editor = ""; for (int n = 0; n < myAttributes.Length; n++) { var a = (Attribute)myAttributes[n]; switch (a.GetType().ToString()) { case "System.ComponentModel.CategoryAttribute": category = ((CategoryAttribute)a).Category; break; case "System.ComponentModel.DescriptionAttribute": description = ((DescriptionAttribute)a).Description; break; case "System.ComponentModel.ReadOnlyAttribute": isreadonly = ((ReadOnlyAttribute)a).IsReadOnly; break; case "System.ComponentModel.BrowsableAttribute": isbrowsable = ((BrowsableAttribute)a).Browsable; break; case "System.ComponentModel.DefaultValueAttribute": defaultvalue = ((DefaultValueAttribute)a).Value; break; case "CslaGenerator.Attributes.UserFriendlyNameAttribute": userfriendlyname = ((UserFriendlyNameAttribute)a).UserFriendlyName; break; case "CslaGenerator.Attributes.HelpTopicAttribute": helptopic = ((HelpTopicAttribute)a).HelpTopic; break; case "System.ComponentModel.TypeConverterAttribute": typeconverter = ((TypeConverterAttribute)a).ConverterTypeName; break; case "System.ComponentModel.DesignerAttribute": designertypename = ((DesignerAttribute)a).DesignerTypeName; break; case "System.ComponentModel.BindableAttribute": bindable = ((BindableAttribute)a).Bindable; break; case "System.ComponentModel.EditorAttribute": editor = ((EditorAttribute)a).EditorTypeName; break; } } userfriendlyname = userfriendlyname.Length > 0 ? userfriendlyname : pi.Name; var types = new List <string>(); foreach (var obj in _selectedObject) { if (!types.Contains(obj.Name)) { types.Add(obj.Name); } } // here get rid of ComponentName and Parent bool isValidProperty = (pi.Name != "Properties" && pi.Name != "ComponentName" && pi.Name != "Parent"); if (isValidProperty && IsBrowsable(types.ToArray(), pi.Name)) { // CR added missing parameters //this.Properties.Add(new PropertySpec(userfriendlyname,pi.PropertyType.AssemblyQualifiedName,category,description,defaultvalue, editor, typeconverter, _selectedObject, pi.Name,helptopic)); Properties.Add(new PropertySpec(userfriendlyname, pi.PropertyType.AssemblyQualifiedName, category, description, defaultvalue, editor, typeconverter, _selectedObject, pi.Name, helptopic, isreadonly, isbrowsable, designertypename, bindable)); } } }
private void InitPropertyBag() { PropertyInfo propertyInfo; Type t = typeof(ValueProperty);// _selectedObject.GetType(); PropertyInfo[] props = t.GetProperties(); // Display information for all properties. for (int i = 0; i < props.Length; i++) { propertyInfo = props[i]; object[] myAttributes = propertyInfo.GetCustomAttributes(true); string category = ""; string description = ""; bool isreadonly = false; bool isbrowsable = true; object defaultvalue = null; string userfriendlyname = ""; string typeconverter = ""; string designertypename = ""; string helptopic = ""; bool bindable = true; string editor = ""; for (int n = 0; n < myAttributes.Length; n++) { var a = (Attribute)myAttributes[n]; switch (a.GetType().ToString()) { case "System.ComponentModel.CategoryAttribute": category = ((CategoryAttribute)a).Category; break; case "System.ComponentModel.DescriptionAttribute": description = ((DescriptionAttribute)a).Description; break; case "System.ComponentModel.ReadOnlyAttribute": isreadonly = ((ReadOnlyAttribute)a).IsReadOnly; break; case "System.ComponentModel.BrowsableAttribute": isbrowsable = ((BrowsableAttribute)a).Browsable; break; case "System.ComponentModel.DefaultValueAttribute": defaultvalue = ((DefaultValueAttribute)a).Value; break; case "CslaGenerator.Attributes.UserFriendlyNameAttribute": userfriendlyname = ((UserFriendlyNameAttribute)a).UserFriendlyName; break; case "CslaGenerator.Attributes.HelpTopicAttribute": helptopic = ((HelpTopicAttribute)a).HelpTopic; break; case "System.ComponentModel.TypeConverterAttribute": typeconverter = ((TypeConverterAttribute)a).ConverterTypeName; break; case "System.ComponentModel.DesignerAttribute": designertypename = ((DesignerAttribute)a).DesignerTypeName; break; case "System.ComponentModel.BindableAttribute": bindable = ((BindableAttribute)a).Bindable; break; case "System.ComponentModel.EditorAttribute": editor = ((EditorAttribute)a).EditorTypeName; break; } } // Set ReadOnly properties if (SelectedObject[0].PropertyType == TypeCodeEx.CustomType) { if ((SelectedObject[0].DeclarationMode != PropertyDeclaration.ClassicPropertyWithTypeConversion && SelectedObject[0].DeclarationMode != PropertyDeclaration.ManagedWithTypeConversion && SelectedObject[0].DeclarationMode != PropertyDeclaration.UnmanagedWithTypeConversion || SelectedObject[0].BackingFieldType == TypeCodeEx.Empty || SelectedObject[0].BackingFieldType == TypeCodeEx.CustomType) && propertyInfo.Name == "IsDatabaseBound") { isreadonly = true; } } if (SelectedObject[0].DeclarationMode != PropertyDeclaration.ClassicPropertyWithTypeConversion && SelectedObject[0].DeclarationMode != PropertyDeclaration.ManagedWithTypeConversion && SelectedObject[0].DeclarationMode != PropertyDeclaration.UnmanagedWithTypeConversion && propertyInfo.Name == "BackingFieldType") { isreadonly = true; } if (SelectedObject[0].ReadOnly && propertyInfo.Name == "PropSetAccessibility") { isreadonly = true; } userfriendlyname = userfriendlyname.Length > 0 ? userfriendlyname : propertyInfo.Name; var types = new List <ValueProperty>(); foreach (var obj in _selectedObject) { if (!types.Contains(obj)) { types.Add(obj); } } // here get rid of Parent bool isValidProperty = propertyInfo.Name != "Parent"; if (isValidProperty && IsBrowsable(types.ToArray(), propertyInfo.Name)) { // CR added missing parameters //this.Properties.Add(new PropertySpec(userfriendlyname,propertyInfo.PropertyType.AssemblyQualifiedName,category,description,defaultvalue, editor, typeconverter, _selectedObject, propertyInfo.Name,helptopic)); Properties.Add(new PropertySpec(userfriendlyname, propertyInfo.PropertyType.AssemblyQualifiedName, category, description, defaultvalue, editor, typeconverter, _selectedObject, propertyInfo.Name, helptopic, isreadonly, isbrowsable, designertypename, bindable)); } } }