private IPropertyInformation EnsurePropertyDefinitionExisitsOnClassDefinition( ClassDefinition classDefinition, Type declaringType, string propertyName) { var propertyInfo = PropertyInfoAdapter.Create(declaringType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)); var propertyReflector = new PropertyReflector( classDefinition, propertyInfo, new ReflectionBasedMemberInformationNameResolver(), PropertyMetadataProvider, DomainModelConstraintProviderStub); var propertyDefinition = propertyReflector.GetMetadata(); if (!classDefinition.MyPropertyDefinitions.Contains(propertyDefinition.PropertyName)) { var propertyDefinitions = new PropertyDefinitionCollection(classDefinition.MyPropertyDefinitions, false); propertyDefinitions.Add(propertyDefinition); PrivateInvoke.SetNonPublicField(classDefinition, "_propertyDefinitions", propertyDefinitions); var endPoints = new RelationEndPointDefinitionCollection(classDefinition.MyRelationEndPointDefinitions, false); endPoints.Add(MappingObjectFactory.CreateRelationEndPointDefinition(classDefinition, propertyInfo)); PrivateInvoke.SetNonPublicField(classDefinition, "_relationEndPoints", endPoints); } return(propertyInfo); }
private PropertyDefinitionCollection getSystemPara() { PropertyDefinitionCollection result = new PropertyDefinitionCollection(); foreach (XmlNode p in Parameter.glb_Parameter.system_parameter) { try { PropertyDefinition para = new PropertyDefinition(); para.Category = "系统参数"; para.TargetProperties.Add(p.Name); para.Description = ""; para.SetValue(StringProperty, p.InnerText); para.DisplayName = cnNames[p.Name]; string des; cnDescription.TryGetValue(p.Name, out des); para.Description = des; result.Add(para); } catch (Exception e) { } } return(result); }
/// <summary> /// Utility method to copy a property definition collection /// </summary> /// <param name="srcProperties"></param> /// <param name="targetProperties"></param> private static void CopyProperties(PropertyDefinitionCollection srcProperties, PropertyDefinitionCollection targetProperties, bool ignoreDeleted) { if (ignoreDeleted) { foreach (PropertyDefinition propDef in srcProperties) { if (propDef.ElementState != SchemaElementState.SchemaElementState_Deleted) { targetProperties.Add(CloneProperty(propDef)); } } } else { foreach (PropertyDefinition propDef in srcProperties) { targetProperties.Add(CloneProperty(propDef)); } } }
private void PreparePropertyGrid() { PropertyDefinitionCollection propertyDefinitions = new PropertyDefinitionCollection(); var properties = TypeDescriptor.GetProperties(person.GetType()); // Allowing for multiple selection, if on further iterations through the selected items we will remove properties that do not exist in both PropertySets foreach (var p in properties.Cast <PropertyDescriptor>()) { if (p.PropertyType != typeof(System.Windows.Media.Color?)) { continue; } string category = p.Category; string description = p.Description; string displayName = p.DisplayName ?? p.Name; int? displayOrder = null; bool? isBrowsable = p.IsBrowsable; bool? isExpandable = null; var orderAttribute = p.Attributes[typeof(PropertyOrderAttribute)] as PropertyOrderAttribute; if (orderAttribute != null) { displayOrder = orderAttribute.Order; } var expandableAttribute = p.Attributes[typeof(ExpandableObjectAttribute)] as ExpandableObjectAttribute; if (expandableAttribute != null) { isExpandable = true; } var aPropertyDefinition = new PropertyDefinition { Category = category, Description = description, DisplayName = displayName, DisplayOrder = displayOrder, IsBrowsable = isBrowsable, IsExpandable = isExpandable, TargetProperties = new[] { p.Name }, }; if (p.PropertyType == typeof(System.Windows.Media.Color?)) { aPropertyDefinition.IsExpandable = true; aPropertyDefinition.PropertyDefinitions.Add(new PropertyDefinition() { TargetProperties = new[] { "R", "G", "B" } }); } propertyDefinitions.Add(aPropertyDefinition); } this.propertyGrid.PropertyDefinitions = propertyDefinitions; }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { PropertyDefinitionCollection col = new PropertyDefinitionCollection(); col.Add(new PropertyDefinition() { Name = "Name" }); if (value is Page) { col.Add(new PropertyDefinition() { Name = "Width" }); col.Add(new PropertyDefinition() { Name = "Height" }); col.Add(new PropertyDefinition() { Name = "Image" }); col.Add(new PropertyDefinition() { Name = "ImageTop" }); col.Add(new PropertyDefinition() { Name = "ImageLeft" }); } else if (value is Element) { col.Add(new PropertyDefinition() { Name = "Width" }); col.Add(new PropertyDefinition() { Name = "Height" }); col.Add(new PropertyDefinition() { Name = "X" }); col.Add(new PropertyDefinition() { Name = "Y" }); col.Add(new PropertyDefinition() { Name = "Value" }); col.Add(new PropertyDefinition() { Name = "FontSize" }); col.Add(new PropertyDefinition() { Name = "FontName" }); col.Add(new PropertyDefinition() { Name = "Bold" }); col.Add(new PropertyDefinition() { Name = "Italic" }); col.Add(new PropertyDefinition() { Name = "Underline" }); col.Add(new PropertyDefinition() { Name = "Strikeout" }); col.Add(new PropertyDefinition() { Name = "ElementType" }); col.Add(new PropertyDefinition() { Name = "ListChoises" }); //col.Add(new PropertyDefinition() { Name = "Font" }); //col.Add(new PropertyDefinition() { Name = "Style" }); //col.Add(new PropertyDefinition() { Name = "GroupName" }); } return(col); }
/// <summary> /// Utility method to copy a property definition collection /// </summary> /// <param name="srcProperties"></param> /// <param name="targetProperties"></param> private static void CopyProperties(PropertyDefinitionCollection srcProperties, PropertyDefinitionCollection targetProperties, bool ignoreDeleted) { if (ignoreDeleted) { foreach (PropertyDefinition propDef in srcProperties) { if (propDef.ElementState != SchemaElementState.SchemaElementState_Deleted) targetProperties.Add(CloneProperty(propDef)); } } else { foreach (PropertyDefinition propDef in srcProperties) { targetProperties.Add(CloneProperty(propDef)); } } }
public void Add() { _collection.Add(_propertyDefinition); Assert.That(_collection.Count, Is.EqualTo(1)); }