本文整理汇总了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);
}
示例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));
}
示例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);
}
示例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));
}
示例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);
}