示例#1
0
        private static TMachineState CreateNewState <TMachineState>(IMachineStateOwner owner, params object[] args)
            where TMachineState : IMachineState
        {
            Type newStateType = typeof(TMachineState);

            object[] ctorArgs = new[] { owner }.Concat(args).ToArray();
            Type[]   ctorArgTypes = ctorArgs.Select(arg => arg.GetType()).ToArray();

            ConstructorInfo ctor = newStateType.GetConstructor(ctorArgTypes);

            Verifiers.Assert(ctor != null, "No constructor with specified signature has been found: {0}", (object)(ctorArgTypes));

            return((TMachineState)ctor.Invoke(ctorArgs));
        }