public MethodInterpreterKey(MethodInterpreter interpreter, Type implementingType = null)
        {
            Interpreter = interpreter;
            var methodBase = Interpreter.Method;

            DeclaringType    = methodBase.DeclaringType;
            ImplementingType = implementingType ?? methodBase.DeclaringType;
            _methodName      = methodBase.Name;

            var parameterList = new List <Type>();

            if (!methodBase.IsStatic)
            {
                parameterList.Add(methodBase.DeclaringType);
            }
            parameterList.AddRange(methodBase.GetParameters().Select(par => par.ParameterType).ToList());
            var returnType = methodBase.GetReturnType();

            if (returnType != typeof(void))
            {
                parameterList.Add(returnType);
            }
            _parameterList = parameterList.ToArray();

            _hash = ComputeHash();
        }
예제 #2
0
        public static MethodInterpreterKey ToKey(this MethodInterpreter methodInterpreter, Type implementingType = null)
        {
            var resultKey = new MethodInterpreterKey(methodInterpreter, implementingType);

            resultKey.AdjustDeclaringTypeByImplementingType();
            return(resultKey);
        }
예제 #3
0
        public static bool[] GetUsedArguments(MethodInterpreter interpreter)
        {
            var argsCount = interpreter.Method.GetParameters().Length;

            if (interpreter.Method is ConstructorInfo || !interpreter.Method.IsStatic)
            {
                argsCount++;
            }
            var result      = new bool[argsCount];
            var analyzeData = interpreter.AnalyzeProperties;
            var arguments   = analyzeData.Arguments;

            for (var index = 0; index < arguments.Count; index++)
            {
                var argument = arguments[index];
                result[index] = analyzeData.GetVariableData(argument) != EscapingMode.Unused;
            }
            return(result);
        }