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


C# Microsoft.Cci.GetParameters方法代码示例

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


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

示例1: MakeMethodParameters

        private void MakeMethodParameters(MethodBase method, Cci.IMethodReference methodRef, out Type[] methodGenericParameters, out ParameterInfo[] parameters, out ParameterInfo returnParameter)
        {
            Type declaringType = method.DeclaringType;

            if (methodRef.IsGeneric && methodRef.AsGenericMethodInstanceReference == null)
            {
                // generic definition
                methodGenericParameters = MakeGenericParameters((MethodInfo)method, methodRef);
            }
            else
            {
                methodGenericParameters = Type.EmptyTypes;
            }

            Type[] typeGenericParameters;
            if (declaringType.IsGenericTypeDefinition)
            {
                typeGenericParameters = declaringType.GetGenericArguments();
            }
            else
            {
                typeGenericParameters = Type.EmptyTypes;
            }

            GenericContext genericContext = methodGenericParameters.Length > 0 || typeGenericParameters.Length > 0 ?
                new GenericContext(typeGenericParameters, methodGenericParameters) : default(GenericContext);

            parameters = new ParameterInfo[methodRef.ParameterCount];
            int i = 0;
            foreach (var parameter in methodRef.GetParameters(_context))
            {
                parameters[i] = MakeParameterInfo(method, i + 1, parameter.GetType(_context), genericContext, parameter.CustomModifiers, parameter.IsByReference);
                i++;
            }

            returnParameter = MakeParameterInfo(method, 0, methodRef.GetType(_context), genericContext, methodRef.ReturnValueCustomModifiers, methodRef.ReturnValueIsByRef);
        }
开发者ID:furesoft,项目名称:roslyn,代码行数:37,代码来源:ReflectionEmitter.cs

示例2: ResolveOverload

        private MethodBase ResolveOverload(MemberInfo[] members, Cci.IMethodReference methodRef)
        {
            IEnumerable<Cci.IParameterTypeInformation> paramRefs = methodRef.GetParameters(_context);

            Type[] reusableResolvedParameters = null;
            Type[] typeGenericParameters = members[0].DeclaringType.GetGenericArguments();

            MethodBase candidate = null;
            foreach (MethodBase method in members)
            {
                Debug.Assert(!method.IsGenericMethod || method.IsGenericMethodDefinition);

                if (methodRef.AcceptsExtraArguments && method.CallingConvention != CallingConventions.VarArgs)
                {
                    continue;
                }

                if (methodRef.IsGeneric != method.IsGenericMethodDefinition)
                {
                    continue;
                }

                Type[] methodGenericParameters = (methodRef.IsGeneric) ? method.GetGenericArguments() : Type.EmptyTypes;
                if (methodGenericParameters.Length != methodRef.GenericParameterCount)
                {
                    continue;
                }
                GenericContext genericContext = new GenericContext(typeGenericParameters, methodGenericParameters);
                Type[] resolvedParameters = reusableResolvedParameters ??
                    ResolveMethodParameters(methodRef, paramRefs, genericContext);

                if (ParametersMatch(resolvedParameters, method.GetParameters()) && ReturnTypeMatches(methodRef, method, genericContext))
                {
                    Debug.Assert(candidate == null);
                    candidate = method;
#if !DEBUG
                    break;
#endif
                }

                // We can reuse resolved parameters if the method isn't generic. 
                // If it is its signature might contain references to its generic parameters which are different for each overload.
                if (reusableResolvedParameters == null && !methodRef.IsGeneric)
                {
                    reusableResolvedParameters = resolvedParameters;
                }
            }

            Debug.Assert(candidate != null);
            return candidate;
        }
开发者ID:furesoft,项目名称:roslyn,代码行数:51,代码来源:ReflectionEmitter.cs

示例3: GetParameterTypes

        private void GetParameterTypes(Cci.ISignature signature, out Type[] types, out Type[][] reqMods, out Type[][] optMods)
        {
            // name, default value, marshalling and custom attributes are handled later in DefineParameter
            types = new Type[signature.ParameterCount];
            reqMods = optMods = null;

            int i = 0;
            foreach (var parameter in signature.GetParameters(_context))
            {
                Type type = ResolveParameterType(parameter);

                // TODO (tomat, Dev12): this doesn't handle types constructed from modified types, we need Ref.Emit support for that:
                ModifiedType modifiedType = type as ModifiedType;
                if (modifiedType != null)
                {
                    type = modifiedType.UnmodifiedType;

                    if (modifiedType.RequiredModifiers != null)
                    {
                        if (reqMods == null)
                        {
                            reqMods = new Type[types.Length][];
                        }

                        reqMods[i] = modifiedType.RequiredModifiers;
                    }

                    if (modifiedType.OptionalModifiers != null)
                    {
                        if (optMods == null)
                        {
                            optMods = new Type[types.Length][];
                        }

                        optMods[i] = modifiedType.OptionalModifiers;
                    }
                }

                types[i++] = type;
            }
        }
开发者ID:furesoft,项目名称:roslyn,代码行数:41,代码来源:ReflectionEmitter.cs


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