Esempio n. 1
0
        public StateChangeEvent(pStateChangeType s)
            : base(s.UnitID, s.Timer)
        {
            this.newState = s.NewState;
            for (int i = 0; i < s.From.Count; i++)
            {
                this.from.Add(s.From[i]);
            }
            for (int i = 0; i < s.Except.Count; i++)
            {
                this.except.Add(s.Except[i]);
            }

            if (null != s.EngramRange)
            {
                this.Range = new EngramRange(s.EngramRange);
            }
        }
Esempio n. 2
0
        public override pStateChangeType pGetStateChange()
        {
            string unitID = "Unknown object";
            pStateChangeType returnValue;
            try
            {
                reader.Read();
                pEngramRange engramRange = null;
                if ("EngramRange" == reader.Name)
                {
                    engramRange = pGetEngramRange();
                }

                unitID = pGetString();
                int timer = pGetInt();
                string newState = pGetString();
                returnValue = new pStateChangeType(unitID, engramRange, timer, newState);
                if ("From" == reader.Name)
                {
                    while ("From" == reader.Name)
                    {
                        returnValue.AddPrecursor(pGetString());
                    }
                }
                else while ("Except" == reader.Name)
                    {
                        returnValue.AddException(pGetString());
                    }
                reader.ReadEndElement();
            }
            catch (System.Exception e)
            {
                throw new ApplicationException("Error reading StateChange for " +
                    unitID + ": ", e);
            }

            return returnValue;
        }