コード例 #1
0
        public static ConstructorInfo GetConstructor(this IResolverConstructorSelector constructorSelector, Type type, IResolver resolver)
        {
            ConstructorInfo ctor;

            if (constructorSelector.TryGetConstructor(type, resolver, out ctor))
            {
                return(ctor);
            }

            throw new ResolveException("Unable to resolve type: " + type);
        }
コード例 #2
0
        private Func <object> CreateGetInstanceFunc(Type type)
        {
            if (type == typeof(object))
            {
                return(() => new object());
            }

            object instance;

            if (TryGetInstance(type, out instance))
            {
                return(() => instance);
            }

            ConstructorInfo constructor;

            if (_constructorSelector.TryGetConstructor(type, this, out constructor))
            {
                return(GetCreateInstanceFunc(constructor));
            }

            return(_getInstanceFuncNotFound);
        }
コード例 #3
0
        public static bool CanGetConstructor(this IResolverConstructorSelector constructorSelector, Type type, IResolver resolver)
        {
            ConstructorInfo dummy;

            return(constructorSelector.TryGetConstructor(type, resolver, out dummy));
        }