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


C# MemberInfo.IsDefined方法代码示例

本文整理汇总了C#中System.Reflection.MemberInfo.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.IsDefined方法的具体用法?C# MemberInfo.IsDefined怎么用?C# MemberInfo.IsDefined使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.IsDefined方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateProperty

        protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
        {
            JsonProperty property = base.CreateProperty(member, memberSerialization);

            if (member.IsDefined(typeof(DisableAuditingAttribute)) || member.IsDefined(typeof(JsonIgnoreAttribute)))
            {
                property.ShouldSerialize = instance => false;
            }

            return property;
        }
开发者ID:Zbun,项目名称:Gld.Activity.Project,代码行数:11,代码来源:AuditingContractResolver.cs

示例2: GetOpenTypeDescription

 public static string GetOpenTypeDescription(MemberInfo typeElement)
 {
     Type typeToQuery;
      if (typeElement.MemberType == MemberTypes.TypeInfo || typeElement.MemberType == MemberTypes.NestedType)
      {
     typeToQuery = (Type)typeElement;
      }
      else
      {
     typeToQuery = typeElement.DeclaringType;
      }
      if (typeToQuery.IsDefined(typeof(OpenTypeAttribute), true))
      {
     OpenTypeAttribute mappingSpec =
        (OpenTypeAttribute) typeToQuery.GetCustomAttributes(typeof (OpenTypeAttribute), true)[0];
     if (!string.IsNullOrEmpty(mappingSpec.ResourceName))
     {
        ResourceManager manager = new ResourceManager(mappingSpec.ResourceName, typeToQuery.Assembly);
        string descr = manager.GetString(typeElement.Name);
        if (descr == null)
        {
           throw new MissingResourceItemException(typeElement.Name, mappingSpec.ResourceName,
                                                  typeToQuery.Assembly.FullName);
        }
        return descr;
     }
      }
      if (typeElement.IsDefined(typeof(DescriptionAttribute), true))
      {
     DescriptionAttribute descrAttr =
        (DescriptionAttribute) typeElement.GetCustomAttributes(typeof (DescriptionAttribute), true)[0];
     return descrAttr.Description;
      }
      return typeElement.Name;
 }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:35,代码来源:AttributeUtils.cs

示例3: GetOpenTypeName

 public static string GetOpenTypeName(MemberInfo typeElement)
 {
     if (typeElement.IsDefined(typeof(OpenTypeAttribute), true))
      {
     OpenTypeAttribute mappingSpec =
        (OpenTypeAttribute)typeElement.GetCustomAttributes(typeof(OpenTypeAttribute), true)[0];
     if (!string.IsNullOrEmpty(mappingSpec.MappedName))
     {
        return mappingSpec.MappedName;
     }
      }
      return typeElement.Name;
 }
开发者ID:SzymonPobiega,项目名称:NetMX,代码行数:13,代码来源:AttributeUtils.cs

示例4: CreateMemberInstance

        protected override Object CreateMemberInstance(Type memberType, MemberInfo memberInfo, ISearchContext searchContext)
        {
            var locator = CreateElementLocator(memberInfo);

            var isCached = memberInfo.IsDefined(typeof (CacheLookupAttribute), true);

            if (memberType.IsWebElement())
            {
                ILoader<IWebElement> elementLoader = _loaderFactory.CreateElementLoader(searchContext, locator, isCached);

                IWebElement elementProxy = 
                    typeof(HtmlFrame).IsAssignableFrom(memberType)
                        ? _proxyFactory.CreateFrameProxy(elementLoader)
                        : _proxyFactory.CreateElementProxy(elementLoader);

                if (typeof (IWebElement) == memberType || typeof (IHtmlElement) == memberType)
                {
                    return new HtmlElement(elementProxy);
                }

                return Create(memberType, elementProxy);
            }

            if (memberType.IsWebElementList())
            {
                var genericArguments = memberType.GetGenericArguments();

                if (genericArguments.Length == 0)
                {
                    return null;
                }

                var elementType = genericArguments[0];

                if (elementType == typeof (IWebElement) || elementType == typeof (IHtmlElement))
                {
                    elementType = typeof (HtmlElement);
                }

                return _proxyFactory.CreateListProxy(
                    elementType, _loaderFactory.CreateListLoader(elementType, searchContext, locator, isCached)
                );
            }

            return null;
        }
开发者ID:tablesmit,项目名称:Selenium.HtmlElements.Net,代码行数:46,代码来源:PageObjectFactory.cs

示例5: MyTransformer

        private IEnumerable<TransformedName> MyTransformer(MemberInfo member, TransformReason reason) {
            if (member.IsDefined(typeof(OperatorMethodAttribute), false)) {
                Operators op;
                switch(member.Name) {
                    case "Add": op = Operators.Add; break;
                    case "Subtract": op = Operators.Subtract; break;
                    case "Divide": op = Operators.Divide; break;
                    case "Multiply": op = Operators.Multiply; break;
                    default: throw new NotImplementedException();
                }
                yield return new TransformedName(
                    new OperatorMapping(op, false, true, false),
                    ContextId.Empty);
            }

            yield return new TransformedName(member.Name, ContextId.Empty);
        }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:17,代码来源:DefaultIntOps.cs

示例6: IsExtensionMethod

 private bool IsExtensionMethod(MemberInfo memberInfo)
 {
     return memberInfo.IsDefined(typeof (ExtensionAttribute), true);
 }
开发者ID:paulbatum,项目名称:storevil,代码行数:4,代码来源:SparkGlossaryFormatter.cs

示例7: HasIgnoreAttribute

		public static bool HasIgnoreAttribute( MemberInfo member )
		{
			return member.IsDefined( IgnoreType, false );
		}
开发者ID:alesliehughes,项目名称:olive,代码行数:4,代码来源:Reflect.cs

示例8: ExpandProperty

		bool ExpandProperty(MemberInfo memberInfo)
		{
			return (memberInfo.IsDefined(typeof(Debugger.Tests.ExpandAttribute), true)) ||
			       ListContains(expandProperties, memberInfo);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:5,代码来源:DebuggerTestsBase.cs

示例9: OutlineMemberAttribute

	void OutlineMemberAttribute (MemberInfo mi)
	{
		if (!mi.IsDefined (typeof (System.ObsoleteAttribute), false))
			return;
		var oa = mi.GetCustomAttributes (typeof (System.ObsoleteAttribute), false) [0] as ObsoleteAttribute;
		var msg = oa.Message;
		o.WriteLine ("[Obsolete{0}]", msg == null || msg == "" ? "" : string.Format ("(\"{0}\")", msg));
	}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:8,代码来源:outline.cs

示例10: GetColumnAttribute

        protected ColumnAttribute GetColumnAttribute(MemberInfo member)
        {
            if (member.IsDefined(typeof(ColumnAttribute), false))
            {
                return (ColumnAttribute)member.GetCustomAttributes(typeof(ColumnAttribute), false)[0];
            }

            return null;
        }
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:9,代码来源:ReflectionMapStrategyBase.cs

示例11: IsDefined

        public static bool IsDefined(MemberInfo element, Type attributeType, bool inherit)
        {
            // Returns true if a custom attribute subclass of attributeType class/interface with inheritance walk
            if (element == null)
                throw new ArgumentNullException(nameof(element));

            if (attributeType == null)
                throw new ArgumentNullException(nameof(attributeType));
            
            if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
                throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
            Contract.EndContractBlock();

            switch(element.MemberType)
            {
                case MemberTypes.Property:  
                    return InternalIsDefined((PropertyInfo)element, attributeType, inherit);

                case MemberTypes.Event: 
                    return InternalIsDefined((EventInfo)element, attributeType, inherit);

                default:
                    return element.IsDefined(attributeType, inherit);
            }

        }
开发者ID:Clockwork-Muse,项目名称:coreclr,代码行数:26,代码来源:Attribute.cs

示例12: GetDescription

        /// <summary>
        /// Get The Type Description using Description Attribute and 
        /// objects to format the Description.
        /// </summary>
        /// <param name="member"> Specified Member for which Info is Required</param>
        /// <param name="args">An Object array containing zero or more objects to format.</param>
        /// <returns>return <see cref="String.Empty"/> if DescriptionAttribute is 
        /// not found or return type description</returns>
        public static string GetDescription(MemberInfo member, params object[] args)
        {
            string text1;

            if (member == null)
            {
                throw new ArgumentNullException("member");
            }

            if (member.IsDefined(typeof(DescriptionAttribute), false))
            {
                DescriptionAttribute[] attributes =
                    (DescriptionAttribute[])member.GetCustomAttributes(typeof(DescriptionAttribute), false);
                text1 = attributes[0].Description;
            }
            else
            {
                return String.Empty;
            }

            if ((args != null) && (args.Length > 0))
            {
                return String.Format(null, text1, args);
            }
            return text1;
        }
开发者ID:yonglehou,项目名称:ToolRepository,代码行数:34,代码来源:ReflectionExt.cs

示例13: IsXmlIgnore

		private bool IsXmlIgnore(MemberInfo member) {
			return member.IsDefined(typeof(XmlIgnoreAttribute), false);
		}
开发者ID:BackupTheBerlios,项目名称:ch3etah-svn,代码行数:3,代码来源:MetadataNodeBase.cs

示例14: IsDefined

 internal static bool IsDefined(MemberInfo target, Type caType, bool inherit) {
   // JScript implements subclasses of MemberInfo which throw an exception when Module is
   // accessed. We know that none of these are from a ReflectionOnly assembly.
   Type t = target.GetType();
   if (t.Assembly == typeof(CustomAttribute).Assembly || !target.Module.Assembly.ReflectionOnly)
     return target.IsDefined(caType, inherit);
   return CustomAttribute.CheckForCustomAttribute(CustomAttributeData.GetCustomAttributes(target), caType);
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:8,代码来源:customattribute.cs

示例15: AssertIsDeprecated

 private static void AssertIsDeprecated(MemberInfo member)
 {
     Assert.NotNull(member);
     Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
 }
开发者ID:radavies,项目名称:protobuf,代码行数:5,代码来源:DeprecatedMemberTest.cs


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