示例#1
0
文件: Contract.cs 项目: ErgEnn/NetRpc
        public ContractMethod(Type contractType, Type?instanceType, bool hasSwaggerRole, string contractTypeTag, MethodInfo methodInfo,
                              List <FaultExceptionAttribute> faultExceptionAttributes, List <HttpHeaderAttribute> httpHeaderAttributes,
                              List <ResponseTextAttribute> responseTextAttributes, List <SecurityApiKeyAttribute> securityApiKeyAttributes)
        {
            MethodInfo = methodInfo;
            InnerSystemTypeParameters = new ReadOnlyCollection <PPInfo>(InnerType.GetInnerSystemTypeParameters(methodInfo));
            FaultExceptionAttributes  = new ReadOnlyCollection <FaultExceptionAttribute>(faultExceptionAttributes);
            HttpHeaderAttributes      = new ReadOnlyCollection <HttpHeaderAttribute>(httpHeaderAttributes);
            ResponseTextAttributes    = new ReadOnlyCollection <ResponseTextAttribute>(responseTextAttributes);
            SecurityApiKeyAttributes  = new ReadOnlyCollection <SecurityApiKeyAttribute>(securityApiKeyAttributes);

            //IgnoreAttribute
            IsGrpcIgnore        = GetCustomAttribute <GrpcIgnoreAttribute>(contractType, methodInfo) != null;
            IsRabbitMQIgnore    = GetCustomAttribute <RabbitMQIgnoreAttribute>(contractType, methodInfo) != null;
            IsHttpIgnore        = GetCustomAttribute <HttpIgnoreAttribute>(contractType, methodInfo) != null;
            IsTracerIgnore      = GetCustomAttribute <TracerIgnoreAttribute>(contractType, methodInfo) != null;
            IsTracerArgsIgnore  = GetCustomAttribute <TracerArgsIgnoreAttribute>(contractType, methodInfo) != null;
            IsTraceReturnIgnore = GetCustomAttribute <TracerReturnIgnoreAttribute>(contractType, methodInfo) != null;

            Route    = new MethodRoute(contractType, methodInfo);
            IsMQPost = GetCustomAttribute <MQPostAttribute>(contractType, methodInfo) != null;
            Tags     = new ReadOnlyCollection <string>(GetTags(contractTypeTag, methodInfo));

            //SwaggerRole
            if (hasSwaggerRole)
            {
                var contractRoleAttributes = instanceType !.GetCustomAttributes <SwaggerRoleAttribute>(true).ToList();
                var instanceMethod         = instanceType !.GetMethod(methodInfo.Name) !;
                var roles = GetRoles(contractRoleAttributes, instanceMethod);
                Roles = new ReadOnlyCollection <string>(roles);
            }
        }
示例#2
0
        public ContractMethod(Type contractType, List <SwaggerRoleAttribute> contractTypeRoles, string contractTypeTag, MethodInfo methodInfo,
                              List <FaultExceptionAttribute> faultExceptionAttributes, List <HttpHeaderAttribute> httpHeaderAttributes,
                              List <ResponseTextAttribute> responseTextAttributes, List <SecurityApiKeyAttribute> securityApiKeyAttributes)
        {
            MethodInfo = methodInfo;
            InnerSystemTypeParameters = new ReadOnlyCollection <PPInfo>(InnerType.GetInnerSystemTypeParameters(methodInfo));
            FaultExceptionAttributes  = new ReadOnlyCollection <FaultExceptionAttribute>(faultExceptionAttributes);
            HttpHeaderAttributes      = new ReadOnlyCollection <HttpHeaderAttribute>(httpHeaderAttributes);
            ResponseTextAttributes    = new ReadOnlyCollection <ResponseTextAttribute>(responseTextAttributes);
            SecurityApiKeyAttributes  = new ReadOnlyCollection <SecurityApiKeyAttribute>(securityApiKeyAttributes);

            //IgnoreAttribute
            IsGrpcIgnore        = GetCustomAttribute <GrpcIgnoreAttribute>(contractType, methodInfo) != null;
            IsRabbitMQIgnore    = GetCustomAttribute <RabbitMQIgnoreAttribute>(contractType, methodInfo) != null;
            IsHttpIgnore        = GetCustomAttribute <HttpIgnoreAttribute>(contractType, methodInfo) != null;
            IsTracerIgnore      = GetCustomAttribute <TracerIgnoreAttribute>(contractType, methodInfo) != null;
            IsTracerArgsIgnore  = GetCustomAttribute <TracerArgsIgnoreAttribute>(contractType, methodInfo) != null;
            IsTraceReturnIgnore = GetCustomAttribute <TracerReturnIgnoreAttribute>(contractType, methodInfo) != null;

            Route    = new MethodRoute(contractType, methodInfo);
            IsMQPost = GetCustomAttribute <MQPostAttribute>(contractType, methodInfo) != null;
            IsHideFaultExceptionDescription = GetCustomAttribute <HideFaultExceptionDescriptionAttribute>(contractType, methodInfo) != null;
            Tags = new ReadOnlyCollection <string>(GetTags(contractTypeTag, methodInfo));

            //SwaggerRole
            var roles = GetRoles(contractTypeRoles, methodInfo);

            Roles = new ReadOnlyCollection <string>(roles);
        }