Пример #1
0
        //
        static IDictionary <Enum, HashSet <Transition> > BuildTransitions(TypeBuilder typeBuilder, Type machineType, Type stateType)
        {
            var methods     = StateMethods.GetStateMethods(machineType);
            var transitions = new Dictionary <Enum, HashSet <Transition> >(7);

            for (int i = 0; i < methods.Length; i++)
            {
                Enum state = (Enum)StateExtension.GetStateCore(methods[i], stateType);
                HashSet <Transition> actions;
                if (!transitions.TryGetValue(state, out actions))
                {
                    actions = new HashSet <Transition>();
                    transitions.Add(state, actions);
                }
                var info = new Transition(methods[i].MetadataToken);
                if (!actions.Contains(info))
                {
                    info.Method = CreateTransition(typeBuilder, methods[i]);
                    actions.Add(info);
                }
            }
            return(transitions);
        }
Пример #2
0
        public void Test00_GetStateMethods()
        {
            var methods = StateMethods.GetStateMethods(typeof(Machine));

            Assert.AreEqual(1, methods.Length);
        }