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));
            }
        }
Beispiel #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));
        }
Beispiel #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));
        }
Beispiel #4
0
        public static object CreateObject(Type instanceType)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor(instanceType);

            return(instanceCreator());
        }
Beispiel #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));
        }
Beispiel #6
0
        public static TReturn CreateObject <TArg1, TReturn>(TArg1 arg1)
        {
            var instanceCreator = ConstructorFactory.CreateConstructor <TArg1, TReturn>();

            return(instanceCreator(arg1));
        }