本文整理汇总了C#中Attribute.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Attribute.GetType方法的具体用法?C# Attribute.GetType怎么用?C# Attribute.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attribute
的用法示例。
在下文中一共展示了Attribute.GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompareTo
public int CompareTo(Attribute t)
{
if (t.GetType() == typeof(TagAttribute)) {
string rval = (string)t.Value;
return this._value.CompareTo(rval);
} else {
return -1;
}
}
示例2: ShouldHideMember
/// <summary>
/// This function takes a member descriptor and an attribute and determines whether
/// the member satisfies the particular attribute. This either means that the member
/// contains the attribute or the member does not contain the attribute and the default
/// for the attribute matches the passed in attribute.
/// </summary>
private static bool ShouldHideMember(MemberDescriptor member, Attribute attribute)
{
if (member == null || attribute == null)
{
return true;
}
Attribute memberAttribute = member.Attributes[attribute.GetType()];
if (memberAttribute == null)
{
return !attribute.IsDefaultAttribute();
}
else
{
return !attribute.Equals(memberAttribute);
}
}
示例3: Equals
/// <summary>
/// Compares for reference AND value equality.
/// </summary>
/// <param name="obj">The object to compare with this instance.</param>
/// <returns>
/// <c>true</c> if both operands are equal; otherwise, <c>false</c>.
/// </returns>
public bool Equals(Attribute obj)
{
bool ivarsEqual = true;
if (obj.GetType() != this.GetType())
{
return false;
}
if (this._recordType != obj._recordType)
{
ivarsEqual = false;
}
if (this._recordLength != obj._recordLength)
{
ivarsEqual = false;
}
if (this._recordSpecificFields != obj._recordSpecificFields)
{
ivarsEqual = false;
}
return ivarsEqual;
}
示例4: Contains
/// <devdoc>
/// Determines if this collection of attributes has the specified attribute.
/// </devdoc>
public bool Contains(Attribute attribute)
{
Attribute attr = this[attribute.GetType()];
if (attr != null && attr.Equals(attribute))
{
return true;
}
return false;
}
示例5: Contains
/// <summary>
/// Determines if this collection of attributes has the specified attribute.
/// </summary>
public bool Contains(Attribute attribute)
{
Attribute attr = this[attribute.GetType()];
return attr != null && attr.Equals(attribute);
}
示例6: ReadMetadataAttribute
private void ReadMetadataAttribute(Attribute attribute, IDictionary<string, object> metadata)
{
var attrType = attribute.GetType();
// Note, we don't support ReflectionContext in this scenario as
if (attrType.GetTypeInfo().GetCustomAttribute<MetadataAttributeAttribute>(true) == null)
return;
foreach (var prop in attrType
.GetRuntimeProperties()
.Where(p => p.DeclaringType == attrType && p.CanRead))
{
AddMetadata(metadata, prop.Name, prop.GetValue(attribute, null));
}
}