本文整理汇总了C#中System.ComponentModel.AttributeCollection类的典型用法代码示例。如果您正苦于以下问题:C# AttributeCollection类的具体用法?C# AttributeCollection怎么用?C# AttributeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeCollection类属于System.ComponentModel命名空间,在下文中一共展示了AttributeCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputAttributes
private static void OutputAttributes(AttributeCollection attributeCollection)
{
foreach (Attribute attribute in attributeCollection)
{
Console.WriteLine("Attribute: {0}", attribute.ToString());
}
}
示例2:
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
if (_attributes == null)
_attributes = _typeDescriptionProvider.GetAttributes();
return _attributes;
}
示例3: AttributesContainer
/// <summary>
/// Initializes a new instance of the <see cref="AttributesContainer"/> class.
/// </summary>
/// <param name="attributes">The collection of attributes.</param>
public AttributesContainer(AttributeCollection attributes)
{
if (attributes == null) throw new ArgumentNullException("attributes");
this.attributes = attributes;
foreach (Type type in from Attribute attr in this.attributes select attr.GetType())
RegisterAttribute(type.Name, type);
}
示例4: GetEditorAttribute
/// <summary>
/// Returns the EditorAttribute in the AttributeCollection.
/// </summary>
public static EditorAttribute GetEditorAttribute(AttributeCollection attributes)
{
foreach (Attribute attribute in attributes) {
EditorAttribute editorAttribute = attribute as EditorAttribute;
if (editorAttribute != null) {
return editorAttribute;
}
}
return null;
}
示例5: CanGetEditorAttributeFromCollection
public void CanGetEditorAttributeFromCollection()
{
BindableAttribute bindableAttribute = new BindableAttribute(false);
EditorAttribute editorAttribute = new EditorAttribute();
Attribute[] attributes = new Attribute[] { bindableAttribute, editorAttribute };
AttributeCollection attributeCollection = new AttributeCollection(attributes);
Assert.AreSame(editorAttribute, WixBindingTestsHelper.GetEditorAttribute(attributeCollection));
}
示例6: FromExisting
public static AttributeCollection FromExisting (AttributeCollection existing, params Attribute [] newAttributes)
{
if (existing == null)
throw new ArgumentNullException ("existing");
AttributeCollection ret = new AttributeCollection ();
ret.attrList.AddRange (existing.attrList);
if (newAttributes != null)
ret.attrList.AddRange (newAttributes);
return ret;
}
示例7: frmSettings_Load
private void frmSettings_Load(object sender, EventArgs e)
{
System.Configuration.UserScopedSettingAttribute userAttr = new System.Configuration.UserScopedSettingAttribute();
System.ComponentModel.AttributeCollection attrs = new System.ComponentModel.AttributeCollection(userAttr);
propertyGrid1.BrowsableAttributes = attrs;
propertyGrid1.SelectedObject = Properties.Settings.Default;
cboCompany.Items.AddRange(hc.getAllCompanies());
}
示例8: CheckAndAddProperty
private void CheckAndAddProperty(PSPropertyInfo propertyInfo, Attribute[] attributes, ref PropertyDescriptorCollection returnValue)
{
using (typeDescriptor.TraceScope("Checking property \"{0}\".", new object[] { propertyInfo.Name }))
{
if (!propertyInfo.IsGettable)
{
typeDescriptor.WriteLine("Property \"{0}\" is write-only so it has been skipped.", new object[] { propertyInfo.Name });
}
else
{
AttributeCollection propertyAttributes = null;
Type propertyType = typeof(object);
if ((attributes != null) && (attributes.Length != 0))
{
PSProperty property = propertyInfo as PSProperty;
if (property != null)
{
DotNetAdapter.PropertyCacheEntry adapterData = property.adapterData as DotNetAdapter.PropertyCacheEntry;
if (adapterData == null)
{
typeDescriptor.WriteLine("Skipping attribute check for property \"{0}\" because it is an adapted property (not a .NET property).", new object[] { property.Name });
}
else if (property.isDeserialized)
{
typeDescriptor.WriteLine("Skipping attribute check for property \"{0}\" because it has been deserialized.", new object[] { property.Name });
}
else
{
propertyType = adapterData.propertyType;
propertyAttributes = adapterData.Attributes;
foreach (Attribute attribute in attributes)
{
if (!propertyAttributes.Contains(attribute))
{
typeDescriptor.WriteLine("Property \"{0}\" does not contain attribute \"{1}\" so it has been skipped.", new object[] { property.Name, attribute });
return;
}
}
}
}
}
if (propertyAttributes == null)
{
propertyAttributes = new AttributeCollection(new Attribute[0]);
}
typeDescriptor.WriteLine("Adding property \"{0}\".", new object[] { propertyInfo.Name });
PSObjectPropertyDescriptor descriptor = new PSObjectPropertyDescriptor(propertyInfo.Name, propertyType, !propertyInfo.IsSettable, propertyAttributes);
descriptor.SettingValueException += this.SettingValueException;
descriptor.GettingValueException += this.GettingValueException;
returnValue.Add(descriptor);
}
}
}
示例9: AddDisplayName
internal static AttributeCollection AddDisplayName(string name, AttributeCollection attributes) {
var displayNameAttrib = attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
// If there is already a display name attribute, don't change anything
if (displayNameAttrib != null) {
return attributes;
}
// Add a friendlier display name attribute
return AttributeCollection.FromExisting(
attributes,
new DisplayNameAttribute(MakeFriendlyName(name)));
}
示例10: DeleteNonRelevatAttributes
public static AttributeCollection DeleteNonRelevatAttributes(AttributeCollection collection)
{
ArrayList attributes = GetAttributes(collection);
ArrayList newAttributes = new ArrayList();
foreach (Attribute attr in attributes)
{
if (acceptableAttributes.ContainsKey(attr.GetType())
|| acceptableAttributes.ContainsKey(attr.GetType().BaseType))
{
newAttributes.Add(attr);
}
}
return GetAttributes(newAttributes);
}
示例11: OnAddingAttribute
/// <summary>
/// 添加标签属性时的触发事件函数.用于设置自身的某些属性值
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void OnAddingAttribute(object sender, AttributeCollection.AttributeAddingEventArgs e)
{
string name = e.Item.Name.ToLower();
switch (name)
{
case "id":
this.Id = e.Item.Text.Trim();
break;
case "name":
this.Name = e.Item.Text.Trim();
break;
}
OnAddingAttribute(name, e.Item);
}
示例12: FromExisting
public static AttributeCollection FromExisting(AttributeCollection existing, params Attribute[] newAttributes)
{
if (existing == null)
{
throw new ArgumentNullException("existing");
}
if (newAttributes == null)
{
newAttributes = new Attribute[0];
}
Attribute[] array = new Attribute[existing.Count + newAttributes.Length];
int count = existing.Count;
existing.CopyTo(array, 0);
for (int i = 0; i < newAttributes.Length; i++)
{
if (newAttributes[i] == null)
{
throw new ArgumentNullException("newAttributes");
}
bool flag = false;
for (int j = 0; j < existing.Count; j++)
{
if (array[j].TypeId.Equals(newAttributes[i].TypeId))
{
flag = true;
array[j] = newAttributes[i];
break;
}
}
if (!flag)
{
array[count++] = newAttributes[i];
}
}
Attribute[] destinationArray = null;
if (count < array.Length)
{
destinationArray = new Attribute[count];
Array.Copy(array, 0, destinationArray, 0, count);
}
else
{
destinationArray = array;
}
return new AttributeCollection(destinationArray);
}
示例13: GetAttributes
public override AttributeCollection GetAttributes()
{
if (_finalAttributeCollection == null)
{
lock (_lockAttributeGetter)
{
if (_finalAttributeCollection == null)
{
bool metadataModified;
Type reflectedType = TypeDescriptor.GetReflectionType(_configuration.ComponentType);
Attribute[] originalAttributes =
reflectedType.GetCustomAttributes(true).Cast<Attribute>().ToArray();
Attribute[] finalAttributes = GetAttributes(originalAttributes, _configuration,
out metadataModified);
_finalAttributeCollection = new AttributeCollection(finalAttributes);
}
}
}
return _finalAttributeCollection;
}
示例14: DomainOperationParameter
/// <summary>
/// Initializes a new instance of the DomainOperationParameter class
/// </summary>
/// <param name="name">The name of the parameter</param>
/// <param name="parameterType">The Type of the parameter</param>
/// <param name="attributes">The set of attributes for the parameter</param>
public DomainOperationParameter(string name, Type parameterType, AttributeCollection attributes)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException("name");
}
if (parameterType == null)
{
throw new ArgumentNullException("parameterType");
}
if (attributes == null)
{
throw new ArgumentNullException("attributes");
}
this._name = name;
this._parameterType = parameterType;
this._attributes = attributes;
}
示例15: SYNamePropertyDescriptor
public SYNamePropertyDescriptor(PropertyDescriptor descr):base(descr)
{
_d = descr;
int count = _d.Attributes.Count;
Attribute[] attrs = new Attribute[count];
Attribute vis_att = new System.ComponentModel.BrowsableAttribute(true);
for (int i = 0; i < count; ++i)
{
if (_d.Attributes[i].TypeId == vis_att.TypeId)
{
attrs[i] = vis_att;
}
else
{
attrs[i] = _d.Attributes[i];
}
}
_ac = new AttributeCollection(attrs);
//Array.Resize(attrs, attrs.Length + 1);
//attrs[attrs.Length - 1] = new System.ComponentModel.BrowsableAttribute(true);
}