当前位置: 首页>>代码示例>>C#>>正文


C# Attribute.GetType方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:tomgud,项目名称:Memorize,代码行数:9,代码来源:tagattribute.cs

示例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);
            }
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:23,代码来源:TypeDescriptor.cs

示例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;
        }
开发者ID:mcgredonps,项目名称:open-dis-csharp,代码行数:33,代码来源:Attribute.cs

示例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;
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:12,代码来源:attributecollection.cs

示例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);
        }
开发者ID:geoffkizer,项目名称:corefx,代码行数:9,代码来源:AttributeCollection.cs

示例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));
            }
        }
开发者ID:benpye,项目名称:corefx,代码行数:15,代码来源:TypeInspector.cs


注:本文中的Attribute.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。