示例#1
0
        public bool AddData(Data data)
        {
            if (_dataListById.ContainsKey(data.Id))
            {
                LOG.ErrorLine("idspace '{0}' has duplicated id '{1}'", Id, data.Id);
                return(false);
            }
            else if (data.Name != null && _dataListByName.ContainsKey(data.Name))
            {
                LOG.ErrorLine("idspace '{0}' has duplicated id '{1}'", Id, data.Id);
                return(false);
            }

            data.SetOwner(this);
            _dataListById.Add(data.Id, data);
            if (data.Name != null)
            {
                _dataListByName.Add(data.Name, data);
            }
            if (data.Group != null)
            {
                List <Data> groupList = null;
                if (_dataListByGroup.ContainsKey(data.Group))
                {
                    groupList = _dataListByGroup[data.Group];
                }
                else
                {
                    groupList = new List <Data>();
                    _dataListByGroup.Add(data.Group, groupList);
                }
                groupList.Add(data);
            }
            return(true);
        }
示例#2
0
        internal DataList Parse(string filename, string text = null)
        {
            this._filename = filename;

            var doc = new XmlDocument();

            try
            {
                if (string.IsNullOrEmpty(text))
                {
                    doc.Load(filename);
                }
                else
                {
                    doc.LoadXml(text);
                }
            }
            catch (Exception e)
            {
                LOG.ErrorLine(e);
                return(null);
            }

            var dateList = ParseIdspace(doc);

            //if (!ParseHeader(dateList,doc))
            //{
            //    return null;
            //}
            if (!ParseData(dateList, doc))
            {
                return(null);
            }
            return(dateList);
        }
示例#3
0
        private bool ParseHeader(DataList dateList, XmlDocument doc)
        {
            var headers = doc.GetElementsByTagName("header");

            if (headers.Count == 0)
            {
            }
            else if (headers.Count == 1)
            {
                //var header = dateList.Header;
                //var headerTag = headers.Item(0);
                //ParseAttributes(header, headerTag.Attributes);
            }
            else
            {
                LOG.ErrorLine("File " + _filename + " has more than one header tag");
            }
            return(true);
        }