Beispiel #1
0
        /// <summary>
        /// Конструктор, реализация требуется для интерфейса ISerializable. Вызывается при десериализации.
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        public PointOfInterest(SerializationInfo info, StreamingContext context)
        {
            Title    = TryGetString(info, "Name");
            FileName = TryGetString(info, "FileName");
            Text     = TryGetString(info, "Text");
            Note     = TryGetString(info, "Note");
            //Items
            List <PointOfInterest> Items = TryGetValue(info, "Items", typeof(List <PointOfInterest>)) as List <PointOfInterest>;

            //InnerContext
            InnerContext = TryGetValue(info, "InnerContext", typeof(List <InnerContextNode>)) as List <InnerContextNode>;
            //Context
            Context = TryGetValue(info, "Context", typeof(List <OuterContextNode>)) as List <OuterContextNode>;
            if (Context == null)
            {
                //Пробуем прочитать старый формат и преобразовать в новый
                List <List <string> > contextOld = TryGetValue(info, "Context", typeof(List <List <string> >)) as List <List <string> >;
                string C0Type = TryGetString(info, "ParserClassName");
                if (contextOld != null)
                {
                    Context = new List <OuterContextNode>();
                    bool first = true;
                    foreach (List <string> l in contextOld)
                    {
                        OuterContextNode cNew = new OuterContextNode(l, first? C0Type : "");
                        first = false;
                        Context.Add(cNew);
                    }
                }
            }
        }
Beispiel #2
0
        private static OuterContextNode TryReadOuterContextNode(XmlNode Node, dynamic Lexer)
        {
            OuterContextNode Result = new OuterContextNode();

            Result.Type = Node.Attributes["Type"]?.InnerText;
            Result.Name = TokenizeString(Node.InnerText, Lexer);
            return(Result);
        }
Beispiel #3
0
        private static OuterContextNode TryReadOuterContextNode(XmlNode Node)
        {
            OuterContextNode Result = new OuterContextNode();

            foreach (XmlAttribute attr in Node.Attributes)
            {
                if (attr.Name == "Type")
                {
                    Result.Type = attr.InnerText;
                }
            }
            foreach (XmlNode subNode in Node.ChildNodes)
            {
                Result.Name.Add(subNode.InnerText);
            }
            return(Result);
        }