public void AddTests() { var collection = new PropertyDescriptorCollection(null); for (var i = 0; i < 100; i++) { Assert.Equal(i, collection.Add(new MockPropertyDescriptor($"name{i}"))); Assert.Equal(i + 1, collection.Count); } }
public void ReadOnlyThrows() { var collection = new PropertyDescriptorCollection(null, true); // The readonly check occurs before anything else, so we don't need to pass in actual valid values Assert.Throws<NotSupportedException>(() => collection.Add(null)); Assert.Throws<NotSupportedException>(() => collection.Insert(1, null)); Assert.Throws<NotSupportedException>(() => collection.RemoveAt(1)); Assert.Throws<NotSupportedException>(() => collection.Remove(null)); Assert.Throws<NotSupportedException>(() => collection.Clear()); }
public void collection_cannot_be_mutated() { var property0 = PropertyDescriptor.For(typeof(DecoratedType).GetProperty("Property0")); var property1 = PropertyDescriptor.For(typeof(DecoratedType).GetProperty("Property1")); IList<PropertyDescriptor> collection = new PropertyDescriptorCollection(new[] { property0, property1 }); Assert.Throws<NotSupportedException>(() => collection.Add(property1)); Assert.Throws<NotSupportedException>(() => collection.Clear()); Assert.Throws<NotSupportedException>(() => collection.Insert(0, property1)); Assert.Throws<NotSupportedException>(() => collection.Remove(property0)); Assert.Throws<NotSupportedException>(() => collection.RemoveAt(0)); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value, false); BackFrame backFrame = (BackFrame)value; PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); for (int i = 0; i < properties.Count; i++) { if (properties[i].IsBrowsable) { if (backFrame.IsCustomXamlFrame() && (properties[i].Name == "FrameWidth" || properties[i].Name == "FrameGradientEndColor" || properties[i].Name == "FrameGradientType" || properties[i].Name == "FrameHatchStyle" || properties[i].Name == "BackGradientEndColor" || properties[i].Name == "BackGradientType" || properties[i].Name == "BackHatchStyle")) { propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), properties[i], new ReadOnlyAttribute(true))); } else { propertyDescriptorCollection.Add(properties[i]); } } } return(propertyDescriptorCollection); }
public PropertyDescriptorCollection GetProperties() { // Create a new collection object PropertyDescriptorCollection PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); for (int i = 0; i < this.Items.Count; i++) { NamedCollectionPropertyDescriptor <T> pd = new NamedCollectionPropertyDescriptor <T>(this, i); pds.Add(pd); } return(pds); }
/// <summary> /// Returns the property descriptors for the described ModelEnum domain class, adding tracking property /// descriptor(s). /// </summary> private PropertyDescriptorCollection GetCustomProperties(Attribute[] attributes) { // Get the default property descriptors from the base class PropertyDescriptorCollection propertyDescriptors = base.GetProperties(attributes); //Add the descriptor for the tracking property. if (ModelElement is ModelEnum modelEnum) { storeDomainDataDirectory = modelEnum.Store.DomainDataDirectory; EFCoreValidator.AdjustEFCoreProperties(propertyDescriptors, modelEnum); //Add the descriptors for the tracking properties propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum , storeDomainDataDirectory.GetDomainProperty(ModelEnum.NamespaceDomainPropertyId) , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsNamespaceTrackingDomainPropertyId) , new Attribute[] { new DisplayNameAttribute("Namespace") , new DescriptionAttribute("Overrides default namespace") , new CategoryAttribute("Code Generation") })); propertyDescriptors.Add(new TrackingPropertyDescriptor(modelEnum , storeDomainDataDirectory.GetDomainProperty(ModelEnum.OutputDirectoryDomainPropertyId) , storeDomainDataDirectory.GetDomainProperty(ModelEnum.IsOutputDirectoryTrackingDomainPropertyId) , new Attribute[] { new DisplayNameAttribute("Output Directory") , new DescriptionAttribute("Overrides default output directory") , new CategoryAttribute("Code Generation") , new TypeConverterAttribute(typeof(ProjectDirectoryTypeConverter)) })); } // Return the property descriptors for this element return(propertyDescriptors); }
public PropertyDescriptorCollection GetProperties() { //if (propertyDescriptors == null) // propertyDescriptors = new Dictionary<Type, PropertyDescriptorCollection>(); //if (propertyDescriptors.ContainsKey(_type)) // return propertyDescriptors[_type]; PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true); PropertyDescriptorCollection newProps = new PropertyDescriptorCollection(null); // For each property use a property descriptor of our own foreach (PropertyDescriptor oProp in baseProps) { if (oProp.Name == "ObjectValue") { if (!this.ValueType.Equals(typeof(void))) { XValueDesctiptor np = new XValueDesctiptor(oProp, this); newProps.Add(np); } } else if (oProp.Name == "ValueType") { if (!this.ValueType.Equals(typeof(void))) { if (this.ValueType.Equals(typeof(object))) { newProps.Add(oProp); } else { ReadOnlyPropertyDesc rp = new ReadOnlyPropertyDesc(oProp); newProps.Add(rp); } } } else if (oProp.Name == "Name") { if (oProp.SerializationVisibility == DesignerSerializationVisibility.Visible) { if (NameReadOnly) { ReadOnlyPropertyDesc rp = new ReadOnlyPropertyDesc(oProp); newProps.Add(rp); } else { newProps.Add(oProp); } } } else { newProps.Add(oProp); } } //propertyDescriptors.Add(_type, newProps); return(newProps); }
public void MemberImportCustomization() { ArrayList calls = new ArrayList(); TestTypeDescriptor logicalType = new TestTypeDescriptor(); PropertyDescriptorCollection properties = logicalType.GetProperties(); properties.Add(new TestPropertyDescriptor("prop1", typeof(object), new Hashtable())); TestObjectMemberImporter memberImporter = new TestObjectMemberImporter(calls); Hashtable services = new Hashtable(); services.Add(typeof(IObjectMemberImporter), memberImporter); properties.Add(new TestPropertyDescriptor("prop2", typeof(object), services)); ComponentImporter importer = new ComponentImporter(typeof(Thing), logicalType); ImportContext context = new ImportContext(); context.Register(importer); JsonRecorder writer = new JsonRecorder(); writer.WriteStartObject(); writer.WriteMember("prop1"); writer.WriteString("value1"); writer.WriteMember("prop2"); writer.WriteString("value2"); writer.WriteEndObject(); JsonReader reader = writer.CreatePlayer(); Thing thing = (Thing)context.Import(typeof(Thing), reader); Assert.AreEqual(1, calls.Count); Assert.AreSame(memberImporter, calls[0]); Assert.AreEqual(new object[] { context, reader, thing }, memberImporter.ImportArgs); Assert.AreEqual("value2", memberImporter.ImportedValue); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context) ? base.GetProperties(context, value, attributes) : TypeDescriptor.GetProperties(value, attributes); COT thisCotInstance = (COT)value; int number = thisCotInstance.Number; if (number == 5) { return(propertyDescriptorCollection); } PropertyDescriptorCollection adjusted = new PropertyDescriptorCollection(null); List <string> propsToSkip = new List <string>(); for (int i = number + 1; i <= 5; i++) { propsToSkip.Add("CotReport" + i); propsToSkip.Add("Plot" + (i - 1)); } if (propertyDescriptorCollection != null) { foreach (PropertyDescriptor thisDescriptor in propertyDescriptorCollection) { if (propsToSkip.Contains(thisDescriptor.Name)) { adjusted.Add(new PropertyDescriptorExtended(thisDescriptor, o => value, null, new Attribute[] { new BrowsableAttribute(false) })); } else { adjusted.Add(thisDescriptor); } } } return(adjusted); }
public PropertyDescriptorCollection GetProperties(Attribute[] attributes) { // Get the collection of properties var baseProps = GetProperties(); globalizedProps = new PropertyDescriptorCollection(null); // For each property use a property descriptor of our own that is able to be globalized for (var i = 0; i < baseProps.Count; i++) { globalizedProps.Add(new GlobalPropertyDescriptor(baseProps[i])); } return(globalizedProps); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (value is AltIdList) { PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); AltIdList altIdList = (AltIdList)value; foreach (AltId current in altIdList) { propertyDescriptorCollection.Add(new AltIdPropertyDescriptor(current)); } return(propertyDescriptorCollection); } return(base.GetProperties(context, value, attributes)); }
PropertyDescriptorCollection ITypedList.GetItemProperties(PropertyDescriptor[] accessors) { PropertyDescriptorCollection coll = TypeDescriptor.GetProperties(typeof(Record)); ArrayList list = new ArrayList(coll); list.Sort(new PDComparer()); PropertyDescriptorCollection res = new PropertyDescriptorCollection(null); for (int n = 0; n < GridRealTime.ColumnCount; n++) { res.Add(list[n] as PropertyDescriptor); } return(res); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection NewProps = new PropertyDescriptorCollection(null); if (Vars.Count > 0) { foreach (KeyValuePair <IWmeValue, Variable> kvp in Vars) { VariablePropertyDescriptor pd = new VariablePropertyDescriptor(kvp.Value); NewProps.Add(pd); } } return(NewProps); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection coll = new PropertyDescriptorCollection(null); PropertyDescriptorCollection baseProperties = TypeDescriptor.GetProperties(this, true); foreach (PropertyDescriptor pd in baseProperties) { coll.Add(pd.Attributes.Contains(Required.Yes) ? new RequiredPropertyDescriptor(pd) : pd); } return(coll); }
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); using (IEnumerator <KeyValuePair <string, JToken> > enumerator = GetEnumerator()) { while (enumerator.MoveNext()) { KeyValuePair <string, JToken> current = enumerator.Current; propertyDescriptorCollection.Add(new JPropertyDescriptor(current.Key, GetTokenPropertyType(current.Value))); } return(propertyDescriptorCollection); } }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection collection = TypeDescriptor.GetProperties(this); PropertyDescriptorCollection output = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor descr in collection) { if (descr.Name != "Id" && descr.IsBrowsable) { output.Add(descr); } } return(output); }
public PropertyDescriptorCollection GetProperties() { // Create a new collection object PropertyDescriptorCollection PropertyDescriptorCollection descriptionCollection = new PropertyDescriptorCollection(null); // Iterate the list of channels for (int i = 0; i < Channels.Count; i++) { // Create a property descriptor for each channel so we can customise it's appearence in the property grid view GraphChannelPropertyDescription description = new GraphChannelPropertyDescription(Channels[i]); descriptionCollection.Add(description); } return(descriptionCollection); }
public override PropertyDescriptorCollection GetProperties() { var propertyDescriptorCollection = new PropertyDescriptorCollection(null); for (int i = 0; i < List.Count; i++) { var propertyDescriptor = new ProjectToFailoverClusterGroupMappingCollectionPropertyDescriptor(this, i); propertyDescriptorCollection.Add(propertyDescriptor); } return(propertyDescriptorCollection); }
public PropertyDescriptorCollection GetProperties() { if (dynamicProps == null) { PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true); dynamicProps = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor oProp in baseProps) { dynamicProps.Add(new DynamicPropertyDescriptor(this, oProp)); } } return(dynamicProps); }
public PropertyDescriptorCollection GetProperties() { // Get the collection of properties var baseProps = new PropertyDescriptorCollection(propertyDescriptors.ToArray(), true); globalizedProps = new PropertyDescriptorCollection(null); // For each property use a property descriptor of our own that is able to be globalized foreach (PropertyDescriptor oProp in baseProps) { globalizedProps.Add(new GlobalPropertyDescriptor(oProp)); } return(globalizedProps); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { ISite serviceProvider = null; IComponent component = PropertyDescriptorUtils.GetComponent(context); if (component != null) { serviceProvider = component.Site; } PropertyDescriptorCollection descriptors = new PropertyDescriptorCollection(null); descriptors.Add(new RuleSetPropertyDescriptor(serviceProvider, TypeDescriptor.CreateProperty(typeof(RuleSet), "RuleSet Definition", typeof(RuleSet), new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content), DesignOnlyAttribute.Yes }))); return(descriptors); }
// Token: 0x06001278 RID: 4728 RVA: 0x000599BC File Offset: 0x00057BBC PropertyDescriptorCollection ICustomTypeDescriptor.cmethod_3334(Attribute[] arg_0) { PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); using (IEnumerator <KeyValuePair <string, Class_361> > enumerator = this.smethod_3330()) { while (enumerator.MoveNext()) { KeyValuePair <string, Class_361> keyValuePair = enumerator.Current; propertyDescriptorCollection.Add(new Class_372(keyValuePair.Key)); } } return(propertyDescriptorCollection); }
public virtual PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true); PropertyDescriptorCollection newProps = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor oProp in baseProps) { if (propertyNames.Contains(oProp.Name)) { newProps.Add(oProp); } } return(newProps); }
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { //create the property collection PropertyDescriptorCollection props = new PropertyDescriptorCollection(null); string currentLanguage = SnippetDesignerPackage.Instance.ActiveSnippetLanguage; foreach (PropertyDescriptor prop in base.GetProperties(attributes)) { props.Add(prop); } // Return the computed properties return(props); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null); Dictionary <string, object> d = new Dictionary <string, object>(); for (int i = 0; i < this.List.Count; i++) { string n = this.List[i].GetType().Name; switch (this.List[i].GetType().Name) { case "Behavior": Behavior b = (Behavior)this.List[i]; if (b.script != null) { n = b.script.name; } break; case "BlueprintBehavior": BlueprintBehavior bb = (BlueprintBehavior)this.List[i]; if (bb.blueprint != null) { n = bb.blueprint.name; } break; } int it = 0; foreach (string k in d.Keys) { if (k.Equals(n) || k.Equals(n + " (" + it.ToString() + ")")) { it += 1; } } if (it > 0) { n += " (" + it.ToString() + ")"; } d.Add(n, this.List[i]); CollectionPropertyDescriptor pd = new CollectionPropertyDescriptor(d, i); pds.Add(pd); } return(pds); }
public PropertyDescriptorCollection GetProperties() { if (globalizedProps == null) { PropertyDescriptorCollection baseProps = TypeDescriptor.GetProperties(this, true); globalizedProps = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor oProp in baseProps) { globalizedProps.Add(new BasePropertyDescriptor(oProp)); } } return(globalizedProps); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, Object value, Attribute[] attributes) { PropertyDescriptorCollection buffClassProps; PropertyDescriptorCollection buffProps = TypeDescriptor.GetProperties(value, attributes, true); buffClassProps = new PropertyDescriptorCollection(null); foreach (PropertyDescriptor oPD in buffProps) { buffClassProps.Add(new SelectedEventEntryPropertyDescriptor(oPD)); Application.DoEvents(); } return(buffClassProps); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection pdc_augmented = new PropertyDescriptorCollection(new PropertyDescriptor[] { }); PropertyDescriptorCollection pdc_underlying = TypeDescriptor.GetProperties(underlying_type); foreach (PropertyDescriptor pd_underlying in pdc_underlying) { AugmentedPropertyDescriptorForProperties pd_augmented = new AugmentedPropertyDescriptorForProperties(pd_underlying); pdc_augmented.Add(pd_augmented); } return(pdc_augmented); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection descriptors = new PropertyDescriptorCollection(null); for (int index = 0; index < List.Count; index++) { TemplateItem option = List[index] as TemplateItem; TemplateItemPropertyDescriptor descriptor = new TemplateItemPropertyDescriptor(option, index); descriptors.Add(descriptor); } return(descriptors); }
/// <summary> /// Returns the properties for this instance of a component using the attribute array as a filter. /// </summary> /// <param name="attributes">An array of type <see cref="T:System.Attribute"/> that is used as a filter.</param> /// <returns> /// A <see cref="T:System.ComponentModel.PropertyDescriptorCollection"/> that represents the filtered properties for this component instance. /// </returns> public virtual PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection descriptors = new PropertyDescriptorCollection(null); if (_value != null) { foreach (KeyValuePair <string, JToken> propertyValue in _value) { descriptors.Add(new JPropertyDescriptor(propertyValue.Key, GetTokenPropertyType(propertyValue.Value))); } } return(descriptors); }
public PropertyDescriptorCollection GetProperties() { // This sort does not work by itself: // Needs: PropertyGrid.PropertySort = System.Windows.Forms.PropertySort.Categorized; list.Sort(); PropertyDescriptorCollection desc = new PropertyDescriptorCollection(null); for (int i = 0; i < list.Count; i++) { VillagePropertyDescriptor vil = new VillagePropertyDescriptor(list[i]); desc.Add(vil); } return(desc); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { if (context != null && value is AutoSizePanel && ((AutoSizePanel)value).AutoSize) { PropertyDescriptorCollection properties = base.GetProperties(context, value, attributes); PropertyDescriptorCollection propertyDescriptorCollection = new PropertyDescriptorCollection(null); { foreach (PropertyDescriptor item in properties) { if (item.Name == "Size") { propertyDescriptorCollection.Add(TypeDescriptor.CreateProperty(value.GetType(), item, new ReadOnlyAttribute(isReadOnly: true))); } else { propertyDescriptorCollection.Add(item); } } return(propertyDescriptorCollection); } } return(base.GetProperties(context, value, attributes)); }
public PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection descriptors = new PropertyDescriptorCollection(null); for (int index = 0; index < List.Count; index++) { SelectOption option = List[index] as SelectOption; SelectOptionPropertyDescriptor descriptor = new SelectOptionPropertyDescriptor(option, index); descriptors.Add(descriptor); } return(descriptors); }
private PropertyDescriptorCollection GetProperties () { // Create a collection object to hold property descriptors PropertyDescriptorCollection pds = new PropertyDescriptorCollection (null); // Iterate the list of Paths for (int i = 0; i < this.List.Count; i++) { // Create a property descriptor for the ReferencePath item and add to the property descriptor collection ReferencePathCollectionPropertyDescriptor pd = new ReferencePathCollectionPropertyDescriptor (this, i); pds.Add (pd); } // return the property descriptor collection return pds; }
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { // Retrieve cached properties and filtered properties bool filtering = attributes != null && attributes.Length > 0; FilterCache cache = _provider._filterCache; PropertyDescriptorCollection props = _provider._propCache; // Use a cached version if we can if (filtering && cache != null && cache.IsValid(attributes)) return cache.FilteredProperties; else if (!filtering && props != null) return props; // Otherwise, create the property collection props = new PropertyDescriptorCollection(null); /*foreach (PropertyDescriptor prop in base.GetProperties(attributes)) { props.Add(prop); }*/ foreach (FieldInfo field in _objectType.GetFields(BindingFlags.Public | BindingFlags.Instance)) { FieldPropertyDescriptor fieldDesc = new FieldPropertyDescriptor(field); if (!filtering || fieldDesc.Attributes.Contains(attributes)) props.Add(fieldDesc); } // Store the updated properties if (filtering) { cache = new FilterCache(); cache.FilteredProperties = props; cache.Attributes = attributes; _provider._filterCache = cache; } else _provider._propCache = props; // Return the computed properties return props; }