コード例 #1
0
        public MethodItem Make(PathInfo searchPath, TypeMethodInfo genericMethod)
        {
            var newMethod    = genericMethod.MakeGenericMethod(searchPath);
            var newGenerator = new ParsedGenerator(newMethod, SourceCode, _genericParameters, _services);

            return(new MethodItem(newGenerator, newMethod));
        }
コード例 #2
0
        /// <summary>
        /// Makes the specified search path.
        /// </summary>
        /// <param name="searchPath">The search path.</param>
        /// <param name="methodDefinition">The method definition.</param>
        /// <returns>MethodItem.</returns>
        public MethodItem Make(PathInfo searchPath, TypeMethodInfo methodDefinition)
        {
            var genericMethod = methodDefinition.MakeGenericMethod(searchPath);
            var generator     = new RuntimeMethodGenerator(_method, genericMethod, ImplementTypes);

            return(new MethodItem(generator, genericMethod));
        }
コード例 #3
0
        public MethodItem Make(PathInfo methodPath, TypeMethodInfo methodDefinition)
        {
            var genericMethod = methodDefinition.MakeGenericMethod(methodPath);
            var generator     = this.makeGeneric(genericMethod);

            return(new MethodItem(generator, genericMethod));
        }
コード例 #4
0
        private TypeMethodInfo resolveGenericBinding(TypeMethodInfo methodDefinition)
        {
            if (!_genericBindings.Keys.Any())
            {
                //there are no bindings available
                return(methodDefinition);
            }

            var translations = new Dictionary <string, string>();

            foreach (var param in _genericBindings.Keys)
            {
                var translatedName = param.Type.TypeName;
                if (translations.ContainsKey(translatedName))
                {
                    //we already have translation
                    continue;
                }

                var bindings = _genericBindings.Get(param).ToArray();
                if (bindings.Length > 1)
                {
                    throw new NotImplementedException("Determine binding for parametric parameters");
                }

                translations.Add(translatedName, bindings[0].TypeName);
            }

            //remap argument bindings from definitions parameters to current method parameters
            var genericMethod = methodDefinition.MakeGenericMethod(translations);

            for (var i = 0; i < genericMethod.Parameters.Length; ++i)
            {
                var currentParameter = genericMethod.Parameters[i];
                var oldParameter     = methodDefinition.Parameters[i];

                var args = _argBindings.Get(oldParameter);
                _argBindings.Set(currentParameter, args);
            }

            return(genericMethod);
        }