Esempio n. 1
0
        /// <summary>
        /// Similar with FormatterServices.GetUninitializedObject. Allocate and return zeroed T-typed object.
        /// </summary>
        public static ClassDisposeHandle UninitializedAllocation <T>(out T result) where T : class
        {
            ClassDisposeHandle handle = UninitializedAllocation(typeof(T), out Object obj);

            result = obj as T;

            return(handle);
        }
Esempio n. 2
0
        /// <summary>
        /// Similar with new T();
        /// </summary>
        public static ClassDisposeHandle Allocate <T>(out T result) where T : class
        {
            ClassDisposeHandle handle = UninitializedAllocation <T>(out result);

            ArbitaryMethodInvoker.InvokeAction(GetConstructorLocation <T>(), result);

            return(handle);
        }
Esempio n. 3
0
        /// <summary>
        /// Similar with new T(arg0);
        /// </summary>
        public static ClassDisposeHandle Allocate <T, TArg0>(
            out T result,
            TArg0 arg0)
            where T : class
        {
            ClassDisposeHandle handle = UninitializedAllocation <T>(out result);

            ConstructorInfo ci = GetConstructorInfo <T>(typeof(TArg0));

            ArbitaryMethodInvoker.InvokeAction(ci.MethodHandle.GetFunctionPointer(), result, arg0);

            return(handle);
        }
Esempio n. 4
0
        /// <summary>
        /// Similar with new T(arg0, arg1, arg2, arg3, arg4, arg5);
        /// </summary>
        public static ClassDisposeHandle Allocate <T, TArg0, TArg1, TArg2, TArg3, TArg4, TArg5>(
            out T result,
            TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5)
            where T : class
        {
            ClassDisposeHandle handle = UninitializedAllocation <T>(out result);

            ConstructorInfo ci = GetConstructorInfo <T>(typeof(TArg0), typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));

            ArbitaryMethodInvoker.InvokeAction(ci.MethodHandle.GetFunctionPointer(), result, arg0, arg1, arg2, arg3, arg4, arg5);

            return(handle);
        }