private void CreateObjectPropertiesNodes(object obj, TreeNode nodeObject) { foreach (PropertyInfo propInfo in obj.GetType().BaseType.GetProperties( BindingFlags.Instance | BindingFlags.Public)) // | BindingFlags.DeclaredOnly { object[] arrayOfCustomAttributes = propInfo.GetCustomAttributes(true); // object[] arrayOfCustomAttributes = propInfo.GetCustomAttributes(typeof(HLAAttributeAttribute), false); foreach (Attribute custumAttr in arrayOfCustomAttributes) { if (custumAttr is HLAAttributeAttribute) { HLAAttributeAttribute attr = custumAttr as HLAAttributeAttribute; object newValue = propInfo.GetValue(obj, null); TreeNode nodeProperty = FindNode(nodeObject.Nodes, attr.Name); if (nodeProperty != null) { object oldValue = ((HLAAttributePropertiesInformationValue)nodeProperty.Tag).ObjectValue; if (newValue != null && !newValue.Equals(oldValue)) { HLAAttributePropertiesInformationValue nodeInfo = new HLAAttributePropertiesInformationValue(attr.AttributeInfo, propInfo, newValue); // Updates the UI if the selected object is the same that the object that its properties has been changed if (this.propertyGrid.InternalPropertyGrid.SelectedObject.Equals(nodeProperty.Tag)) { this.propertyGrid.InternalPropertyGrid.SelectedObject = nodeInfo; } nodeProperty.Tag = nodeInfo; } } else { nodeProperty = new TreeNode(attr.Name); nodeProperty.ImageIndex = 1; nodeProperty.SelectedImageIndex = 1; HLAAttributePropertiesInformationValue nodeInfo = new HLAAttributePropertiesInformationValue(attr.AttributeInfo, propInfo, newValue); nodeProperty.Tag = nodeInfo; nodeObject.Nodes.Add(nodeProperty); } } } } }