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


C# MethodInfo.GetCustomAttribute方法代码示例

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


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

示例1: Process

 public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     if ((method.ReturnType.IsPrimitive || TypeUtils.IsEnum(method.ReturnType)) && method.GetCustomAttribute<OptionallyAttribute>() != null) {
         Log.Warn("Ignoring Optionally annotation on primitive parameter on " + method.ReflectedType + "." + method.Name);
         return;
     }
     Process(method, specification);
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:7,代码来源:OptionalAnnotationFacetFactory.cs

示例2: ProcessParams

 public override void ProcessParams(IReflector reflector, MethodInfo method, int paramNum, ISpecificationBuilder holder) {
     ParameterInfo parameter = method.GetParameters()[paramNum];
     if (parameter.ParameterType.IsPrimitive || TypeUtils.IsEnum(parameter.ParameterType)) {
         if (method.GetCustomAttribute<OptionallyAttribute>() != null) {
             Log.Warn("Ignoring Optionally annotation on primitive parameter " + paramNum + " on " + method.ReflectedType + "." + method.Name);
         }
         return;
     }
     var attribute = parameter.GetCustomAttribute<OptionallyAttribute>();
     FacetUtils.AddFacet(Create(attribute, holder));
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:11,代码来源:OptionalAnnotationFacetFactory.cs

示例3: Process

        public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
            Type declaringType = method.DeclaringType;
            var classAttribute = declaringType.GetCustomAttribute<AuthorizeActionAttribute>();
            var methodAttribute = method.GetCustomAttribute<AuthorizeActionAttribute>();

            if (classAttribute != null && methodAttribute != null) {
                string declaringTypeName = declaringType == null ? "Unknown Type" : declaringType.FullName;
                Log.WarnFormat("Class and method level AuthorizeAttributes applied to class {0} - ignoring attribute on method {1}", declaringTypeName, method.Name);
            }

            Create(classAttribute ?? methodAttribute, specification);
        }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:12,代码来源:AuthorizeAnnotationFacetFactory.cs

示例4: Process

 public override void Process(IReflector reflector, MethodInfo method, IMethodRemover methodRemover, ISpecificationBuilder specification) {
     Attribute attribute = method.GetCustomAttribute<DisplayNameAttribute>() ?? (Attribute) method.GetCustomAttribute<NamedAttribute>();
     FacetUtils.AddFacet(Create(attribute, specification));
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:4,代码来源:NamedAnnotationFacetFactory.cs

示例5: AddAjaxFacet

 protected static void AddAjaxFacet(MethodInfo method, ISpecification holder) {
     if (method == null) {
         FacetUtils.AddFacet(new AjaxFacet(holder));
     }
     else {
         var attribute = method.GetCustomAttribute<ExecutedAttribute>();
         if (attribute != null && attribute.IsAjax) {
             if (attribute.AjaxValue == Ajax.Disabled) {
                 FacetUtils.AddFacet(new AjaxFacet(holder));
             }
         }
     }
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:13,代码来源:MethodPrefixBasedFacetFactoryAbstract.cs

示例6: AddOrAddToExecutedWhereFacet

 protected static void AddOrAddToExecutedWhereFacet(MethodInfo method, ISpecification holder) {
     var attribute = method.GetCustomAttribute<ExecutedAttribute>();
     if (attribute != null && !attribute.IsAjax) {
         var executedFacet = holder.GetFacet<IExecutedControlMethodFacet>();
         if (executedFacet == null) {
             FacetUtils.AddFacet(new ExecutedControlMethodFacet(method, attribute.Value, holder));
         }
         else {
             executedFacet.AddMethodExecutedWhere(method, attribute.Value);
         }
     }
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:12,代码来源:MethodPrefixBasedFacetFactoryAbstract.cs

示例7: IsQueryOnly

 private bool IsQueryOnly(MethodInfo method) {
     return (method.GetCustomAttribute<IdempotentAttribute>() == null) &&
            (method.GetCustomAttribute<QueryOnlyAttribute>() != null);
 }
开发者ID:Robin--,项目名称:NakedObjectsFramework,代码行数:4,代码来源:ActionMethodsFacetFactory.cs


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