コード例 #1
0
 public NmeaDictionary(string path)
 {
     _dictionaryByName = new Dictionary<string, NmeaSentenceType>();
     _dictionaryByCode = new Dictionary<string, NmeaSentenceType>();
     _dictionaryPath = path;
     XmlDocument doc = new XmlDocument();
     doc.Load(path);
     XmlElement sentences = (XmlElement)doc.ChildNodes[0];
     foreach (XmlElement sentence in sentences.ChildNodes)
     {
         string name = sentence.Attributes["name"].Value;
         string code = sentence.Attributes["code"].Value;
         bool ignore = false;
         if (sentence.Attributes["ignore"] != null)
         {
             ignore = bool.Parse(sentence.Attributes["ignore"].Value);
         }
         NmeaSentenceType t = new NmeaSentenceType(name, code, ignore);
         XmlElement parts = (XmlElement)sentence.ChildNodes[0];
         foreach (XmlElement part in parts.ChildNodes)
         {
             int position = int.Parse(part.Attributes["position"].Value);
             string partName = part.Attributes["name"].Value;
             NmeaSentenceTypePart p = new NmeaSentenceTypePart(position, partName, t);
             t.AddPart(p);
         }
         _dictionaryByName[t.Name] = t;
         _dictionaryByCode[t.Code] = t;
     }
 }
コード例 #2
0
        public NmeaDictionary(string path)
        {
            _dictionaryByName = new Dictionary <string, NmeaSentenceType>();
            _dictionaryByCode = new Dictionary <string, NmeaSentenceType>();
            _dictionaryPath   = path;
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
            XmlElement sentences = (XmlElement)doc.ChildNodes[0];

            foreach (XmlElement sentence in sentences.ChildNodes)
            {
                string name   = sentence.Attributes["name"].Value;
                string code   = sentence.Attributes["code"].Value;
                bool   ignore = false;
                if (sentence.Attributes["ignore"] != null)
                {
                    ignore = bool.Parse(sentence.Attributes["ignore"].Value);
                }
                NmeaSentenceType t     = new NmeaSentenceType(name, code, ignore);
                XmlElement       parts = (XmlElement)sentence.ChildNodes[0];
                foreach (XmlElement part in parts.ChildNodes)
                {
                    int    position        = int.Parse(part.Attributes["position"].Value);
                    string partName        = part.Attributes["name"].Value;
                    NmeaSentenceTypePart p = new NmeaSentenceTypePart(position, partName, t);
                    t.AddPart(p);
                }
                _dictionaryByName[t.Name] = t;
                _dictionaryByCode[t.Code] = t;
            }
        }
コード例 #3
0
 public void AddPart(NmeaSentenceTypePart part)
 {
     while (_partsByPosition.Count - 1 < part.Position)
     {
         _partsByPosition.Add(null);
     }
     _partsByPosition[part.Position] = part;
     _partsByName[part.Name]         = part;
 }
コード例 #4
0
 public void AddPart(NmeaSentenceTypePart part)
 {
     while (_partsByPosition.Count-1<part.Position)
     {
         _partsByPosition.Add(null);
     }
     _partsByPosition[part.Position] = part;
     _partsByName[part.Name] = part;
 }