示例#1
0
        public override bool LoadObjLinks(object obj, bool wrapped, EmraldModel lists)
        {
            dynamic dynObj = (dynamic)obj;

            //load the Immediate Actions
            this._immediateActions.Clear();
            foreach (var actName in dynObj.immediateActions)
            {
                Action curAct = lists.allActions.FindByName((string)actName);
                if (curAct == null)
                {
                    throw new Exception("Deserialize State, failed to find immediateAction - " + actName);
                }

                _immediateActions.Add(curAct);
            }

            //load the Event Items
            foreach (var eventName in dynObj.events)
            {
                Event curEv = lists.allEvents.FindByName((string)eventName);
                if (curEv == null)
                {
                    throw new Exception("Deserialize State, failed to find event - " + eventName);
                }
                _events.Add(curEv);
            }

            //load the Event Actions
            if (dynObj.eventActions != null)
            {
                this._evActions.Clear();
                foreach (dynamic curToObj in dynObj.eventActions)
                {
                    try
                    {
                        ActionList curEvActList = new ActionList();
                        curEvActList.DeserializeJSON(curToObj, lists);
                        this._evActions.Add(curEvActList);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Syntax error bad event actions- " + e.Message);
                    }
                }
            }
            return(true);
        }