public static object CreateObject(Type intanceType, params object[] constructorValues)
        {
            //parameterless
            if (constructorValues == null || constructorValues.Length == 0)
            {
                var instanceCreator = ConstructorFactory.CreateConstructor(intanceType);
                return(instanceCreator());
            }
            else // with parameters
            {
                var paramTypes      = constructorValues.Select(value => value.GetType()).ToArray();
                var instanceCreator = ConstructorFactory.CreateConstructor(intanceType, paramTypes);

                return(instanceCreator(constructorValues));
            }
        }
Exemplo n.º 2
0
        public static object CreateObject <TArg1, TArg2, TArg3, TArg4, TArg5>(Type instanceType, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor <TArg1, TArg2, TArg3, TArg4, TArg5>(instanceType);

            return(instanceCreator(arg1, arg2, arg3, arg4, arg5));
        }
Exemplo n.º 3
0
        public static object CreateObject <TArg1, TArg2>(Type instanceType, TArg1 arg1, TArg2 arg2)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor <TArg1, TArg2>(instanceType);

            return(instanceCreator(arg1, arg2));
        }
Exemplo n.º 4
0
        public static object CreateObject(Type instanceType)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor(instanceType);

            return(instanceCreator());
        }
Exemplo n.º 5
0
        public static TReturn CreateObject <TArg1, TArg2, TArg3, TArg4, TArg5, TReturn>(TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor <TArg1, TArg2, TArg3, TArg4, TArg5, TReturn>();

            return(instanceCreator(arg1, arg2, arg3, arg4, arg5));
        }
Exemplo n.º 6
0
        public static TReturn CreateObject <TArg1, TReturn>(TArg1 arg1)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor <TArg1, TReturn>();

            return(instanceCreator(arg1));
        }