示例#1
0
        protected override void AddItem(T item)
        {
            Check.Require(this.parent != null || item.Parent != null,
                          "item of type Pathable must have Parent attribute set when list parent not set");

            Check.Invariant(identifiedLocatables != null, "identifiedLocatables must not be null");

            Locatable locatable = item as Locatable;

            Check.Assert(item != null, "item must not be null");

            if (item.Parent == null)
            {
                item.Parent = this.parent;
            }

            else if (this.parent == null)
            {
                this.parent = item.Parent;
            }

            else if (!Object.ReferenceEquals(item.Parent, this.parent))
            {
                throw new ApplicationException("item parent must have same parent as other items");
            }

            NamedLocatableList <T> namedLocatables;

            if (identifiedLocatables.ContainsKey(item.ArchetypeNodeId))
            {
                namedLocatables = identifiedLocatables[item.ArchetypeNodeId];
            }
            else
            {
                namedLocatables = new NamedLocatableList <T>();
                identifiedLocatables.Add(item.ArchetypeNodeId, namedLocatables);
            }

            DvCodedText codedName = item.Name as DvCodedText;

            if (codedName != null)
            {
                if (namedLocatables.Contains(codedName.DefiningCode.TerminologyId.Value, codedName.DefiningCode.CodeString))
                {
                    throw new ApplicationException(string.Format("locatable ({0}) name ({1}) already existing in the namedLocatable list.",
                                                                 item.ArchetypeNodeId, codedName.ToString()));
                }
            }
            else if (namedLocatables.Contains(item.Name.Value))
            {
                throw new ApplicationException(string.Format("locatable ({0}) name ({1}) already existing in this namedLocatable list",
                                                             item.ArchetypeNodeId, item.Name.Value));
            }

            namedLocatables.Add(item);

            base.AddItem(item);
        }
示例#2
0
        public T this[string nodeId, string nameTerminologyId, string nameCodeString]
        {
            get
            {
                Check.Invariant(identifiedLocatables != null, "identifiedLocatables must not be null");

                NamedLocatableList <T> namedLocatables = identifiedLocatables[nodeId];
                return(namedLocatables[nameTerminologyId, nameCodeString]);
            }
        }