Esempio n. 1
0
        public static SerializableCondition Deserialize(XmlReader rdr, Action <XmlReader, string> bodyContentReadAction)
        {
            Dictionary <string, Func <XmlReader, SerializableCondition> > dictionary = new Dictionary <string, Func <XmlReader, SerializableCondition> >();

            dictionary.Add("OnAdminGained", new Func <XmlReader, SerializableCondition>(SCOnAdminGained.DeserializeFromReader));
            dictionary.Add("OnConnect", new Func <XmlReader, SerializableCondition>(SCOnConnect.DeserializeFromReader));
            dictionary.Add("HasFlags", new Func <XmlReader, SerializableCondition>(SCHasFlags.DeserializeFromReader));
            dictionary.Add("Instantly", new Func <XmlReader, SerializableCondition>(SCInstantly.DeserializeFromReader));
            dictionary.Add("OnDisconnect", new Func <XmlReader, SerializableCondition>(SCOnDisconnect.DeserializeFromReader));
            while (!rdr.EOF && (!rdr.IsStartElement() || !dictionary.ContainsKey(rdr.Name)))
            {
                rdr.Read();
            }
            if (rdr.EOF)
            {
                throw new FormatException("Unexpected end of file!");
            }
            string name = rdr.Name;
            SerializableCondition serializableCondition = dictionary[rdr.Name](rdr);

            rdr.Read();
            if (bodyContentReadAction != null)
            {
                bodyContentReadAction(rdr, name);
            }
            rdr.Read();
            return(serializableCondition);
        }
Esempio n. 2
0
        public static SerializableConditionalActionSet Deserialize(XmlReader rdr)
        {
            SerializableConditionalActionSet ret = new SerializableConditionalActionSet();
            Action <XmlReader, string>       bodyContentReadAction = (Action <XmlReader, string>)((xmlReader, EndKeyName) =>
            {
                while (!rdr.EOF && (string.IsNullOrWhiteSpace(rdr.Name) || rdr.NodeType == XmlNodeType.Comment || rdr.NodeType == XmlNodeType.Whitespace))
                {
                    rdr.Read();
                }
                for (bool flag = !xmlReader.EOF && (!(xmlReader.Name == EndKeyName) || xmlReader.IsStartElement()); flag; flag = !xmlReader.EOF && (!(xmlReader.Name == EndKeyName) || xmlReader.IsStartElement()))
                {
                    ret.Actions.Add(SerializableAction.Deserialize(xmlReader));
                    do
                    {
                        xmlReader.Read();
                    }while (xmlReader.NodeType == XmlNodeType.Whitespace || xmlReader.NodeType == XmlNodeType.Comment);
                }
            });

            ret.Condition = SerializableCondition.Deserialize(rdr, bodyContentReadAction);
            return(ret);
        }