本文整理汇总了C#中System.ComponentModel.PropertyDescriptorCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDescriptorCollection.Remove方法的具体用法?C# PropertyDescriptorCollection.Remove怎么用?C# PropertyDescriptorCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.PropertyDescriptorCollection
的用法示例。
在下文中一共展示了PropertyDescriptorCollection.Remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProperties
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;
}
示例2: ReplaceTrackingPropertyDescriptors
/// <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;
}
示例3: ConvertPropertys
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;
}
示例4: PropertyDescriptorCollection
PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(new PropertyDescriptor[0]);
foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(this))
{
pdc.Add(pd);
}
//put Position property on top
PropertyDescriptor posd = pdc["pPosition"];
pdc.Remove(posd);
pdc.Insert(0, posd);
foreach (String key in CustomProperties.Keys)
{
pdc.Add(new DictionaryPropertyDescriptor(CustomProperties, key, attributes));
}
return pdc;
}
示例5: FilterProperties
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"]);
}
示例6: ModifyDynamicProperties
/// <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)));
}
示例7: AssertReadOnly
private void AssertReadOnly (PropertyDescriptorCollection descriptors, string testCase)
{
MockPropertyDescriptor mockPropertyDescr = new MockPropertyDescriptor (
"Date", DateTime.Now);
try {
descriptors.Add (mockPropertyDescr);
Assert.Fail (testCase + "#1");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
// ensure read-only check if performed before value is checked
try {
descriptors.Add (null);
Assert.Fail (testCase + "#2");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
descriptors.Clear ();
Assert.Fail (testCase + "#3");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
descriptors.Insert (0, mockPropertyDescr);
Assert.Fail (testCase + "#4");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
// ensure read-only check if performed before value is checked
try {
descriptors.Insert (0, null);
Assert.Fail (testCase + "#5");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
descriptors.Remove (mockPropertyDescr);
Assert.Fail (testCase + "#6");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
// ensure read-only check if performed before value is checked
try {
descriptors.Remove (null);
Assert.Fail (testCase + "#7");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
descriptors.RemoveAt (0);
Assert.Fail (testCase + "#8");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
IList list = (IList) descriptors;
Assert.IsTrue (((IList) descriptors).IsReadOnly, testCase + "#9");
Assert.IsTrue (((IList) descriptors).IsFixedSize, testCase + "#10");
try {
list.Add (mockPropertyDescr);
Assert.Fail (testCase + "#11");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
// ensure read-only check if performed before value is checked
try {
list.Add (null);
Assert.Fail (testCase + "#12");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
list.Clear ();
Assert.Fail (testCase + "#13");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
try {
list.Insert (0, mockPropertyDescr);
Assert.Fail (testCase + "#14");
} catch (NotSupportedException) {
// read-only collection cannot be modified
}
// ensure read-only check if performed before value is checked
try {
list.Insert (0, null);
//.........这里部分代码省略.........
示例8: ModifyProperties
private void ModifyProperties(PropertyDescriptorCollection col)
{
if (!ShowB)
{
col.Remove(col.Find("InputB", true));
}
if (!ShowA)
{
col.Remove(col.Find("InputA", true));
}
}
示例9: FilterProperties
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));
}