예제 #1
0
        public StateMachine(System.Xml.Linq.XDocument document)
        {
            BeginState = document.Root.Attribute("beginState").Value;
            string endState = document.Root.Attribute("endState").Value;

            EndStates.Add(endState);
            States = new List <State>();
            //States = (from x in document.Descendants("State")

            //           select new State() { Name = x.Attribute("name").Value, Display = x.Attribute("display").Value }).ToList();
            foreach (var x in document.Descendants("State"))
            {
                var state = new State()
                {
                    Name = x.Attribute("name").Value, Display = x.Attribute("display").Value
                };
                var isnav = x.Attribute("isNavigate");
                if (isnav != null && Boolean.TryParse(isnav.Value, out bool isNav))
                {
                    state.IsNavigate = isNav;
                    var order = x.Attribute("order");
                    if (order != null && Int32.TryParse(order.Value, out int i))
                    {
                        state.SortOrder = i;
                    }
                }
                States.Add(state);
            }

            Transitions = (from x in document.Descendants("Transition")
                           select new Transition()
            {
                Name = x.Attribute("name").Value,
                OriginState = x.Attribute("origin").Value,
                DestinationState = x.Attribute("destination").Value,
                SortOrder = Convert.ToInt32(x.Attribute("order").Value)
            }).ToList();
        }
예제 #2
0
 public bool addEndState(T state)
 {
     return(EndStates.Add(state));
 }