PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes) { var descriptors = new PropertyDescriptorCollection(null); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(_properties); foreach (PropertyDescriptor eachProperty in properties) { descriptors.Add( _customisations.ContainsKey(eachProperty.Name) ? new CustomPropertyDescriptor(eachProperty, _customisations[eachProperty.Name]) : eachProperty); } var nonBrowsables = _customisations.Where(c => !c.Value.IsBrowsable); nonBrowsables.ForEach(a => descriptors.Remove(descriptors[a.Key])); //put Position property on top PropertyDescriptor positionDescriptor = descriptors["Position"]; descriptors.Remove(positionDescriptor); descriptors.Insert(0, positionDescriptor); return(descriptors); }
/// <summary> /// This is a callback function for DynamicTypeDescriptionProvider. /// You can modify the collection in this method. /// Things you can do in this method: /// Hide a property /// Show a property /// Add/Remove attributes of a property /// Create a new property on the fly /// /// More info: http://www.codeproject.com/KB/grid/PropertyGridDynamicProp.aspx /// </summary> /// <param name="pdc"></param> public void ModifyDynamicProperties(PropertyDescriptorCollection pdc) { PropertyDescriptor pd = pdc.Find("SourcePath", false); pdc.Remove(pd); switch (DecodingMode) { case JobDecodingMode.SingleDecoding: pdc.Add(TypeDescriptor.CreateProperty( this.GetType(), pd, new EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(UITypeEditor)) )); break; case JobDecodingMode.BatchDecoding: pdc.Add(TypeDescriptor.CreateProperty( this.GetType(), pd, new EditorAttribute(typeof(FolderEditor), typeof(UITypeEditor)) )); break; } pd = pdc.Find("FilterText", false); pdc.Remove(pd); pdc.Add(TypeDescriptor.CreateProperty(this.GetType(), pd, new ReadOnlyAttribute(!IsFilterActive))); pd = pdc.Find("FormatterSettings", false); pdc.Remove(pd); pdc.Add(TypeDescriptor.CreateProperty(this.GetType(), pd, new ReadOnlyAttribute(!IsFormatterActive))); }
private void ModifyProperties(PropertyDescriptorCollection col) { if (!ShowB) { col.Remove(col.Find("InputB", true)); } if (!ShowA) { col.Remove(col.Find("InputA", true)); } }
/// <summary> /// Returns the property descriptors for the described ModelClass 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 Association association) { storeDomainDataDirectory = association.Store.DomainDataDirectory; // only display roles for 1..1 and 0-1..0-1 associations if (((association.SourceMultiplicity != Multiplicity.One || association.TargetMultiplicity != Multiplicity.One) && (association.SourceMultiplicity != Multiplicity.ZeroOne || association.TargetMultiplicity != Multiplicity.ZeroOne))) { PropertyDescriptor sourceRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceRole"); propertyDescriptors.Remove(sourceRoleTypeDescriptor); PropertyDescriptor targetRoleTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetRole"); propertyDescriptors.Remove(targetRoleTypeDescriptor); } // only display delete behavior on the principal end if (association.SourceRole != EndpointRole.Principal) { PropertyDescriptor sourceDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "SourceDeleteAction"); propertyDescriptors.Remove(sourceDeleteActionTypeDescriptor); } if (association.TargetRole != EndpointRole.Principal) { PropertyDescriptor targetDeleteActionTypeDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().Single(x => x.Name == "TargetDeleteAction"); propertyDescriptors.Remove(targetDeleteActionTypeDescriptor); } /********************************************************************************/ DomainPropertyInfo collectionClassPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.CollectionClassDomainPropertyId); DomainPropertyInfo isCollectionClassTrackingPropertyInfo = storeDomainDataDirectory.GetDomainProperty(Association.IsCollectionClassTrackingDomainPropertyId); // Define attributes for the tracking property/properties so that the Properties window displays them correctly. Attribute[] collectionClassAttributes = { new DisplayNameAttribute("Collection Class"), new DescriptionAttribute("Type of collections generated. Overrides the default collection class for the model"), new CategoryAttribute("Code Generation") }; propertyDescriptors.Add(new TrackingPropertyDescriptor(association, collectionClassPropertyInfo, isCollectionClassTrackingPropertyInfo, collectionClassAttributes)); } // Return the property descriptors for this element return(propertyDescriptors); }
protected override void FilterProperties(PropertyDescriptorCollection col) { base.FilterProperties(col); PropertyDescriptor oldValue = col["Value"]; col.Remove(oldValue); col.Add(new CustomValuePropertyDescriptor(oldValue, entry.Type ?? typeof(string))); PropertyDescriptor oldRoaming = col["Roaming"]; col.Remove(oldRoaming); col.Add(new RoamingPropertyDescriptor(oldRoaming, entry)); }
public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes); // here is how you remove properties not needed for that particular bars type properties.Remove(properties.Find("PointAndFigurePriceType", true)); properties.Remove(properties.Find("ReversalType", true)); properties.Remove(properties.Find("Value2", true)); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\r\rBetter Line Breaks"); return(properties); }
public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes); properties.Remove(properties.Find("BasePeriodType", true)); properties.Remove(properties.Find("PointAndFigurePriceType", true)); properties.Remove(properties.Find("ReversalType", true)); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value2", "\r\rReversal"); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\r\rTrend"); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "BasePeriodValue", "\r\rOpen Offset"); return(properties); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { DefaultableMulti defaultableMulti = (DefaultableMulti)value; var descriptor = TypeDescriptor.GetProperties(defaultableMulti.GetType(), attributes); PropertyDescriptor[] propertyDescriptors = descriptor.OfType <PropertyDescriptor>().ToArray(); PropertyDescriptorCollection result = new PropertyDescriptorCollection(propertyDescriptors, false); foreach (PropertyDescriptor prop in descriptor) { if (defaultableMulti.CanHideProperty(prop.Name)) { try { result.Remove(prop); } catch (Exception e) { Console.WriteLine(e); } } } return(result); }
/// <summary> /// </summary> /// <param name="propertyDescriptor"></param> /// <param name="chartStyle"></param> /// <param name="attributes"></param> /// <returns></returns> public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, ChartStyle chartStyle, Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, chartStyle, attributes); properties.Remove(properties.Find("Pen2", true)); properties.Remove(properties.Find("BarWidthUI", true)); // here is how you change the display name of the property on the properties grid Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "UpColor", "\r\r\rUpper Gradient"); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "DownColor", "\r\r\rLower Gradient"); Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Pen", "\r\r\rLine"); return(properties); }
public PropertyDescriptorCollection Build() { foreach (var propertyDescriptorItem in updatedAttributes.Values) { var newAttributes = propertyDescriptorItem.Attributes.ToArray(); var propertyDescriptorToReplace = propertyDescriptorItem.PropertyDescriptorToReplace; if (propertyDescriptorToReplace != null) { PropertyDescriptor newDescriptor; if (propertyDescriptorToReplace is ElementPropertyDescriptor) { ElementPropertyDescriptor elementPropertyDescriptor = propertyDescriptorToReplace as ElementPropertyDescriptor; newDescriptor = new ElementPropertyDescriptor(Element, elementPropertyDescriptor.DomainPropertyInfo, newAttributes); } else { RolePlayerPropertyDescriptor rolePlayerPropertyDescriptor = propertyDescriptorToReplace as RolePlayerPropertyDescriptor; newDescriptor = new RolePlayerPropertyDescriptor(Element, rolePlayerPropertyDescriptor.DomainRoleInfo, newAttributes); } propertyDescriptors.Remove(propertyDescriptorToReplace); propertyDescriptors.Add(newDescriptor); } } return(propertyDescriptors); }
public override PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection props = parentTypeDescriptionProvider.GetTypeDescriptor(instance).GetProperties(); var assoc = instance as Association; var propsToBeRemoved = new List <string>(); if (!(assoc.End1Multiplicity == Multiplicity.ZeroMany && assoc.End2Multiplicity == Multiplicity.ZeroMany)) { propsToBeRemoved.AddRange(new[] { "ManyToManyMappingTable", "End1ManyToManyMappingColumn", "End1ManyToManyNavigationProperty", "End1ManyToManyFieldName", "End2ManyToManyMappingColumn", "End2ManyToManyNavigationProperty", "End2ManyToManyFieldName" }); } foreach (PropertyDescriptor p in props.OfType <PropertyDescriptor>()) { if (propsToBeRemoved.Contains(p.Name)) { props.Remove(p); } } return(props); }
public override PropertyDescriptorCollection GetProperties() { PropertyDescriptorCollection props = parentTypeDescriptionProvider.GetTypeDescriptor(instance).GetProperties(); try { var navProp = instance as NavigationProperty; var assoc = navProp.Store.ElementDirectory.FindElements <Association>().First(a => a.Name == navProp.Association); var primaryMultiplicities = new[] { Multiplicity.One, Multiplicity.ZeroOne }; var propsToBeRemoved = new List <string>(); if (!(primaryMultiplicities.Any(m => m == assoc.End1Multiplicity) && primaryMultiplicities.Any(m => m == assoc.End2Multiplicity))) { propsToBeRemoved.AddRange(new[] { "IsForeignkey", "ForeignkeyColumn" }); } else if (!navProp.IsForeignkey) { propsToBeRemoved.Add("ForeignkeyColumn"); } foreach (PropertyDescriptor p in props.OfType <PropertyDescriptor>()) { if (propsToBeRemoved.Contains(p.Name)) { props.Remove(p); } } } catch { } return(props); }
public static void AdjustEFCoreProperties(PropertyDescriptorCollection propertyDescriptors, Association element) { ModelRoot modelRoot = element.Source.ModelRoot; for (int index = 0; index < propertyDescriptors.Count; index++) { bool shouldRemove = false; switch (propertyDescriptors[index].Name) { case "TargetPersistencePoint": shouldRemove = element.TargetAutoProperty || modelRoot.EntityFrameworkVersion == EFVersion.EF6; break; case "SourcePersistencePoint": if (element is BidirectionalAssociation bidirectionalAssociation) { shouldRemove = bidirectionalAssociation.SourceAutoProperty || modelRoot.EntityFrameworkVersion == EFVersion.EF6; } break; default: break; } if (shouldRemove) { propertyDescriptors.Remove(propertyDescriptors[index--]); } } }
public void RemoveExistingTests(int index) { var propertyDescriptors = new PropertyDescriptor[] { new MockPropertyDescriptor("propertyDescriptor1"), new MockPropertyDescriptor("propertyDescriptor2"), new MockPropertyDescriptor("propertyDescriptor3"), new MockPropertyDescriptor("propertyDescriptor4"), new MockPropertyDescriptor("propertyDescriptor5"), new MockPropertyDescriptor("propertyDescriptor6"), new MockPropertyDescriptor("propertyDescriptor7"), new MockPropertyDescriptor("propertyDescriptor8"), new MockPropertyDescriptor("propertyDescriptor9") }; // Must send in a copy to the constructor as the array itself is manipulated var collection = new PropertyDescriptorCollection(propertyDescriptors.ToArray()); Assert.True(index >= 0 && index < propertyDescriptors.Length, $"Index '{index}' is out of bounds"); collection.Remove(propertyDescriptors[index]); for (int i = 0; i < propertyDescriptors.Length; i++) { if (i == index) { Assert.False(collection.Contains(propertyDescriptors[index]), "Should have removed descriptor"); } else { Assert.True(collection.Contains(propertyDescriptors[i]), $"Descriptor should be in collection: {i}"); } } }
protected void ModifyIndicatorProperties(PropertyDescriptorCollection col) { foreach (PropertyDescriptor propDesc in col) { // wtf propdesc can be null???????? if (propDesc != null && propDesc.Category != null) { if ((propDesc.Category.Equals("ParametersBase")) && !PropertiesExposed.Contains(propDesc.Name)) { try { PropertyDescriptor tmp = col.Find(propDesc.Name, true); if (tmp != null) { col.Remove(tmp); } else { Print("was null"); } } catch (NullReferenceException ex) { Print(ex.ToString()); } } } } }
// this restricts which ChartStyles can be used with this BarType // public override Gui.Chart.ChartStyleType[] ChartStyleTypesSupported // { // get { return new Gui.Chart.ChartStyleType[] { Gui.Chart.ChartStyleType.OpenClose, Gui.Chart.ChartStyleType.CandleStick }; } // } public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes); // here is how you remove properties not needed for that particular bars type properties.Remove(properties.Find("BasePeriodType", true)); properties.Remove(properties.Find("BasePeriodValue", true)); properties.Remove(properties.Find("PointAndFigurePriceType", true)); properties.Remove(properties.Find("ReversalType", true)); properties.Remove(properties.Find("Value2", true)); // here is how you change the display name of the property on the properties grid Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "\rBrick size"); return(properties); }
/// <summary> /// Returns list of properties in the order defined. /// </summary> /// <returns>Returns the list properties with Index excluded. </returns> public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { PropertyDescriptorCollection properties = base.GetProperties(attributes); PropertyDescriptor index = properties.Find("Index", false); properties.Remove(index); return(properties); }
public static void Remove(this PropertyDescriptorCollection propertyDescriptors, string name) { PropertyDescriptor propertyDescriptor = propertyDescriptors.OfType <PropertyDescriptor>().SingleOrDefault(x => x.Name == name); if (propertyDescriptor != null) { propertyDescriptors.Remove(propertyDescriptor); } }
/// <summary> /// property descriptor collection - add / remove additional properties /// </summary> public override PropertyDescriptorCollection GetProperties(PropertyDescriptor propertyDescriptor, Period period, Attribute[] attributes) { // local variables PropertyDescriptorCollection properties = base.GetProperties(propertyDescriptor, period, attributes); // remove properties not needed for this bar type properties.Remove(properties.Find("BasePeriodType", true)); properties.Remove(properties.Find("PointAndFigurePriceType", true)); properties.Remove(properties.Find("ReversalType", true)); properties.Remove(properties.Find("BasePeriodValue", true)); properties.Remove(properties.Find("Value2", true)); // set display labels NinjaTrader.Gui.Design.DisplayNameAttribute.SetDisplayName(properties, "Value", "Config # (1=default)"); // return collection return(properties); }
private void Remove(string Name) { foreach (CustomProperty prop in _propertyCollection) { if (prop.Name == Name) { _propertyCollection.Remove(prop); return; } } }
protected override void FilterProperties(PropertyDescriptorCollection globalizedProps) { base.FilterProperties(globalizedProps); PropertyDescriptor copyLocalPD = globalizedProps["CopyLocal"]; globalizedProps.Remove(copyLocalPD); if (defaultCopyLocalValue != null) { globalizedProps.Add(new ReplaceDefaultValueDescriptor(copyLocalPD, defaultCopyLocalValue.Value)); } else { globalizedProps.Add(new DummyValueDescriptor(copyLocalPD)); } if (string.IsNullOrEmpty(HintPath)) { globalizedProps.Remove(globalizedProps["HintPath"]); } }
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 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(Attribute[] attributes) { PropertyDescriptor pd; var pdc = new PropertyDescriptorCollection(base.GetProperties(attributes).Cast <PropertyDescriptor>().ToArray()); if ((pd = pdc.Find("Source", false)) != null) { pdc.Add(TypeDescriptor.CreateProperty(typeof(Binding), pd, new Attribute[] { new DefaultValueAttribute("null") })); pdc.Remove(pd); } return(pdc); }
/// <summary> /// Replaces the property descriptors for the tracking property. /// </summary> /// <remarks> /// Returned descriptors allow the properties to be reset with tracked value and resume tracking once modified. /// </remarks> internal PropertyDescriptorCollection ReplaceTrackingPropertyDescriptors(PropertyDescriptorCollection properties) { // Replace the existing descriptor for the DisplayName property DomainPropertyInfo displayNameProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.DisplayNameDomainPropertyId); DomainPropertyInfo displayNameTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsDisplayNameTrackingDomainPropertyId); var displayNameDescriptor = properties[Reflector <NamedElementSchema> .GetProperty(e => e.DisplayName).Name]; if (displayNameDescriptor != null) { properties.Remove(displayNameDescriptor); properties.Add(new TrackingPropertyDescriptor(this, displayNameProperty, displayNameTrackingProperty, displayNameDescriptor.Attributes.Cast <Attribute>().ToArray <Attribute>())); } // Replace the existing descriptor for the Description property DomainPropertyInfo descriptionProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.DescriptionDomainPropertyId); DomainPropertyInfo descriptionTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsDescriptionTrackingDomainPropertyId); var descriptionDescriptor = properties[Reflector <NamedElementSchema> .GetProperty(e => e.Description).Name]; if (descriptionDescriptor != null) { properties.Remove(descriptionDescriptor); properties.Add(new TrackingPropertyDescriptor(this, descriptionProperty, descriptionTrackingProperty, descriptionDescriptor.Attributes.Cast <Attribute>().ToArray <Attribute>())); } // Replace the existing descriptor for the CodeIdentifier property DomainPropertyInfo codeIdentifierProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.CodeIdentifierDomainPropertyId); DomainPropertyInfo codeIdentifierTrackingProperty = this.Store.DomainDataDirectory.GetDomainProperty(NamedElementSchema.IsCodeIdentifierTrackingDomainPropertyId); var codeIdentifierDescriptor = properties[Reflector <NamedElementSchema> .GetProperty(e => e.CodeIdentifier).Name]; if (codeIdentifierDescriptor != null) { properties.Remove(codeIdentifierDescriptor); properties.Add(new TrackingPropertyDescriptor(this, codeIdentifierProperty, codeIdentifierTrackingProperty, codeIdentifierDescriptor.Attributes.Cast <Attribute>().ToArray <Attribute>())); } return(properties); }
public void RemoveProperty(string propertyName) { var descriptor = m_FullPropertyDescriptors.Find(propertyName, true); if (descriptor != null) { m_FullPropertyDescriptors.Remove(descriptor); } else { throw new ObjectNotFoundException(propertyName); } }
public void RemoveProperty(string propertyName) { var descriptor = _FullPropertyDescriptors.Find(propertyName, true); if (descriptor != null) { _FullPropertyDescriptors.Remove(descriptor); } else { throw new Exception("Property is not found"); } }
/// <inheritdoc /> public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) { var descriptors = new PropertyDescriptorCollection(base.GetProperties().Cast <PropertyDescriptor>().ToArray()); foreach (var property_descriptor in __Properties.Select(p => descriptors.Find(p, false))) { var new_property_descriptor = TypeDescriptor.CreateProperty( typeof(Binding), property_descriptor, new DefaultValueAttribute(null), new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Content)); descriptors.Remove(property_descriptor); descriptors.Add(new_property_descriptor); } return(descriptors); }
private PropertyDescriptorCollection ConvertPropertys(PropertyDescriptorCollection pdc) { PropertyDescriptor pd = pdc.Find("ItemsSource", false); if (pd != null) { PropertyDescriptor pdNew = TypeDescriptor.CreateProperty(typeof(ItemsControl), pd, new Attribute[] { new DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible), new DefaultValueAttribute("") }); pdc.Add(pdNew); pdc.Remove(pd); } return(pdc); }
/// <summary> /// Called by TypeDescriptors to determine what should be shown in a property editor. Removing a property hides /// it from the property editor in Visual Studio, nothing more. /// </summary> /// <param name="propertyDescriptors"></param> /// <param name="element"></param> public static void AdjustEFCoreProperties(PropertyDescriptorCollection propertyDescriptors, ModelRoot element) { ModelRoot modelRoot = element; for (int index = 0; index < propertyDescriptors.Count; index++) { bool shouldRemove = false; switch (propertyDescriptors[index].Name) { case "DatabaseInitializerType": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore; break; case "AutomaticMigrationsEnabled": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore; break; case "ProxyGenerationEnabled": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore; break; case "DatabaseType": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore; break; case "InheritanceStrategy": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore && !modelRoot.IsEFCore5Plus; break; case "LazyLoadingEnabled": shouldRemove = modelRoot.EntityFrameworkVersion == EFVersion.EFCore && modelRoot.GetEntityFrameworkPackageVersionNum() < 2.1; break; } if (shouldRemove) { propertyDescriptors.Remove(propertyDescriptors[index--]); } } }
/// <summary> /// Returns a collection of properties for the type of array specified by the value parameter, using the specified context and attributes. /// </summary> /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="value">An <see cref="T:System.Object"/> that specifies the type of array for which to get CKSProperties.</param> /// <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"/> with the properties that are exposed for this data type, or null if there are no CKSProperties. /// </returns> public override PropertyDescriptorCollection GetProperties( ITypeDescriptorContext context, object value, Attribute[] attributes) { SPMetalDefinitionProperties configProperties = (SPMetalDefinitionProperties)value; PropertyDescriptorCollection properties = base.GetProperties(context, value, attributes); if (configProperties.Mode == SPMetalDefinitionSource.CurrentDeploymentSite) { PropertyDescriptor urlDescriptor = properties["Url"]; properties.Remove(urlDescriptor); properties.Add(new ReadOnlyPropertyDescriptor("Url", null) { InnerDescriptor = urlDescriptor, ReadOnlyEvaluator = p => true }); } return(properties); }