示例#1
0
        public IDsiElement ImportElement(int id, string name, string type, string source)
        {
            Logger.LogDataModelMessage($"Import element id={id} name={name} type={type} source={source}");

            DsiElement element = new DsiElement(id, name, type, source);
            string     key     = CreateKey(element.Name);

            _elementsByName[key]      = element;
            _elementsById[element.Id] = element;
            IncrementElementTypeCount(element.Type);
            return(element);
        }
示例#2
0
        public void RenameElement(IDsiElement element, string newName)
        {
            Logger.LogDataModelMessage("Rename element id={element.Id} from {element.Name} to {newName}");

            DsiElement e = element as DsiElement;

            if (e != null)
            {
                string oldKey = CreateKey(e.Name);
                _elementsByName.Remove(oldKey);
                e.Name = newName;
                string newKey = CreateKey(e.Name);
                _elementsByName[newKey] = e;
            }
        }
示例#3
0
        public IDsiElement AddElement(string name, string type, string source)
        {
            Logger.LogDataModelMessage($"Add element name={name} type={type} source={source}");

            string key = CreateKey(name);

            if (!_elementsByName.ContainsKey(key))
            {
                IncrementElementTypeCount(type);
                int        id      = _elementsByName.Count + 1;
                DsiElement element = new DsiElement(id, name, type, source);
                _elementsByName[key] = element;
                _elementsById[id]    = element;
                return(element);
            }
            else
            {
                return(null);
            }
        }