本文整理汇总了C#中System.ComponentModel.AttributeCollection类的典型用法代码示例。如果您正苦于以下问题:C# AttributeCollection类的具体用法?C# AttributeCollection怎么用?C# AttributeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeCollection类属于System.ComponentModel命名空间,在下文中一共展示了AttributeCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: OutputAttributes
private static void OutputAttributes(AttributeCollection attributeCollection)
{
foreach (Attribute attribute in attributeCollection)
{
Console.WriteLine("Attribute: {0}", attribute.ToString());
}
}
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:7,代码来源:ProgrammingMetadataStore.cs
示例2:
AttributeCollection ICustomTypeDescriptor.GetAttributes()
{
if (_attributes == null)
_attributes = _typeDescriptionProvider.GetAttributes();
return _attributes;
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:7,代码来源:CustomTypeDescriptorImpl.cs
示例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);
}
开发者ID:denkhaus,项目名称:WPG,代码行数:13,代码来源:AttributesContainer.cs
示例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;
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:13,代码来源:WixBindingTestsHelper.cs
示例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));
}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:10,代码来源:WixBindingTestsHelperTests.cs
示例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;
}
开发者ID:stabbylambda,项目名称:mono,代码行数:10,代码来源:AttributeCollection.cs
示例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());
}
开发者ID:jobre,项目名称:Patiento-versikt,代码行数:10,代码来源:frmSettings.cs
示例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);
}
}
}
开发者ID:nickchal,项目名称:pash,代码行数:53,代码来源:PSObjectTypeDescriptor.cs
示例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)));
}
开发者ID:sanyaade-mobiledev,项目名称:ASP.NET-Mvc-2,代码行数:13,代码来源:CustomMetaColumn.cs
示例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);
}
开发者ID:KillerGoldFisch,项目名称:GCharp,代码行数:15,代码来源:AttributeUtils.cs
示例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);
}
开发者ID:wujiang1984,项目名称:WechatBuilder,代码行数:20,代码来源:Tag.cs
示例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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:AttributeCollection.cs
示例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;
}
开发者ID:nenadvicentic,项目名称:CustomTypeDescriptors,代码行数:21,代码来源:LambdaTypeDescriptor.cs
示例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;
}
开发者ID:OpenRIAServices,项目名称:OpenRiaServices,代码行数:27,代码来源:DomainOperationParameter.cs
示例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);
}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:21,代码来源:SampleTypeDescriptorFilterService.cs
示例16: WrappedProperty
public WrappedProperty(MemberDescriptor descr, PropertyView propertyView, Attribute[] attrs)
: base(descr, attrs)
{
this.realPropertyDescriptor = (PropertyDescriptor) descr;
this.name = propertyView.Name;
this.displayName = propertyView.DisplayName;
Attribute[] attribs = new Attribute[descr.Attributes.Count + 4];
int i = 0;
foreach (Attribute attrib in descr.Attributes)
{
attribs[i] = attrib;
i++;
}
attribs[i] = new DescriptionAttribute(propertyView.Description);
attribs[i + 1] = new CategoryAttribute(propertyView.Category);
attribs[i + 2] = new DescriptionAttribute(propertyView.Description);
attribs[i + 3] = new ReadOnlyAttribute(propertyView.IsReadOnly);
attributes = new AttributeCollection(attribs);
}
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:22,代码来源:WrappedProperty.cs
示例17: ObjectPropertyDescriptor
public ObjectPropertyDescriptor(MemberDescriptor descr, IContext context, IPropertyMap propertyMap, object obj, Attribute[] attrs)
: base(descr, attrs)
{
this.realPropertyDescriptor = (PropertyDescriptor) descr;
this.name = propertyMap.Name;
this.displayName = propertyMap.Name;
Attribute[] attribs = new Attribute[descr.Attributes.Count + 4];
int i = 0;
foreach (Attribute attrib in descr.Attributes)
{
attribs[i] = attrib;
i++;
}
attribs[i] = new DescriptionAttribute(propertyMap.Name + " is a property.");
attribs[i + 1] = new CategoryAttribute("");
attribs[i + 2] = new DefaultValueAttribute(context.ObjectManager.GetOriginalPropertyValue(obj, propertyMap.Name));
attribs[i + 3] = new ReadOnlyAttribute(propertyMap.IsReadOnly);
attributes = new AttributeCollection(attribs);
}
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:22,代码来源:ObjectPropertyDescriptor.cs
示例18: AddDefaultAttributes
protected static AttributeCollection AddDefaultAttributes(ColumnProvider columnProvider, AttributeCollection attributes) {
List<Attribute> extraAttributes = new List<Attribute>();
// If there is no required attribute and the Provider says required, add one
var requiredAttribute = attributes.FirstOrDefault<RequiredAttribute>();
if (requiredAttribute == null && !columnProvider.Nullable) {
extraAttributes.Add(new RequiredAttribute());
}
// If there is no StringLength attribute and it's a string, add one
var stringLengthAttribute = attributes.FirstOrDefault<StringLengthAttribute>();
int maxLength = columnProvider.MaxLength;
if (stringLengthAttribute == null && columnProvider.ColumnType == typeof(String) && maxLength > 0) {
extraAttributes.Add(new StringLengthAttribute(maxLength));
}
// If we need any extra attributes, create a new collection
if (extraAttributes.Count > 0) {
attributes = AttributeCollection.FromExisting(attributes, extraAttributes.ToArray());
}
return attributes;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:23,代码来源:ColumnProvider.cs
示例19: DebugValidate
private static void DebugValidate(AttributeCollection attributes, object instance, bool noCustomTypeDesc)
{
#if DEBUG
if (!DebugShouldValidate(instance)) return;
AttributeCollection debugAttributes = DebugTypeDescriptor.GetAttributes(instance, noCustomTypeDesc);
DebugValidate(attributes, debugAttributes);
#endif
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:8,代码来源:TypeDescriptor.cs
示例20: PipelineMerge
/// <devdoc>
/// Metadata merging is the second stage of our metadata pipeline. This stage
/// merges extended metdata with primary metadata, and stores it in
/// the cache if it is available.
/// </devdoc>
private static ICollection PipelineMerge(int pipelineType, ICollection primary, ICollection secondary, object instance, IDictionary cache)
{
// If there is no secondary collection, there is nothing to merge.
//
if (secondary == null || secondary.Count == 0)
{
return primary;
}
// Next, if we were given a cache, see if it has accurate data.
//
if (cache != null)
{
ICollection mergeCache = cache[_pipelineMergeKeys[pipelineType]] as ICollection;
if (mergeCache != null && mergeCache.Count == (primary.Count + secondary.Count))
{
// Walk the merge cache.
IEnumerator mergeEnum = mergeCache.GetEnumerator();
IEnumerator primaryEnum = primary.GetEnumerator();
bool match = true;
while(primaryEnum.MoveNext() && mergeEnum.MoveNext())
{
if (primaryEnum.Current != mergeEnum.Current)
{
match = false;
break;
}
}
if (match)
{
IEnumerator secondaryEnum = secondary.GetEnumerator();
while(secondaryEnum.MoveNext() && mergeEnum.MoveNext())
{
if (secondaryEnum.Current != mergeEnum.Current)
{
match = false;
break;
}
}
}
if (match)
{
return mergeCache;
}
}
}
// Our cache didn't match. We need to merge metadata and return
// the merged copy. We create an array list here, rather than
// an array, because we want successive sections of the
// pipeline to be able to modify it.
//
ArrayList list = new ArrayList(primary.Count + secondary.Count);
foreach(object obj in primary)
{
list.Add(obj);
}
foreach(object obj in secondary)
{
list.Add(obj);
}
if (cache != null)
{
ICollection cacheValue;
switch(pipelineType)
{
case PIPELINE_ATTRIBUTES:
Attribute[] attrArray = new Attribute[list.Count];
list.CopyTo(attrArray, 0);
cacheValue = new AttributeCollection(attrArray);
break;
case PIPELINE_PROPERTIES:
PropertyDescriptor[] propArray = new PropertyDescriptor[list.Count];
list.CopyTo(propArray, 0);
cacheValue = new PropertyDescriptorCollection(propArray, true);
break;
case PIPELINE_EVENTS:
EventDescriptor[] eventArray = new EventDescriptor[list.Count];
list.CopyTo(eventArray, 0);
cacheValue = new EventDescriptorCollection(eventArray, true);
break;
default:
Debug.Fail("unknown pipeline type");
cacheValue = null;
break;
}
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:TypeDescriptor.cs
注:本文中的System.ComponentModel.AttributeCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论