Beispiel #1
0
        public L3PDUList(string file)
        {
            XmlTextReader reader = new XmlTextReader(file);

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if ("pdudesc".Equals(reader.Name))
                    {
                        L3PDUInfo info = ParseL3PDUInfo(reader);
                        Map.Add(info.Reference, info);
                    }
                    break;

                case XmlNodeType.Text:
                    break;

                case XmlNodeType.EndElement:
                    break;
                }
            }
        }
Beispiel #2
0
        private L3PDUInfo ParseL3PDUInfo(XmlTextReader reader)
        {
            bool      fields = false;
            L3PDUInfo info   = new L3PDUInfo();

            while (reader.MoveToNextAttribute())
            {
                if ("type".Equals(reader.Name))
                {
                    info.Type = int.Parse(reader.Value);
                }

                if ("set".Equals(reader.Name))
                {
                    info.SetField = reader.Value;
                }

                if ("trigger-pre".Equals(reader.Name))
                {
                    info.TriggerPre = reader.Value;
                }

                if ("trigger-post".Equals(reader.Name))
                {
                    info.TriggerPost = reader.Value;
                }

                if ("ref".Equals(reader.Name))
                {
                    info.Reference = reader.Value;
                }

                if ("length".Equals(reader.Name))
                {
                    info.Length = int.Parse(reader.Value);
                }

                if ("name".Equals(reader.Name))
                {
                    info.Name = reader.Value;
                }

                if ("fields".Equals(reader.Name))
                {
                    if ("true".Equals(reader.Value))
                    {
                        fields = true;
                    }
                }
            }

            while (fields && reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if ("field".Equals(reader.Name))
                    {
                        L3PDUField field = ParseL3PDUField(reader);
                        info.Fields.Add(field);
                    }
                    break;

                case XmlNodeType.Text:
                    break;

                case XmlNodeType.EndElement:
                    return(info);
                }
            }

            return(info);
        }