public override List<object> ItemsAtPath(string path)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(path), "Path must not be null or empty.");

            object itemInDictionary = null;
            if (this.itemAtPathDictionary != null && this.itemAtPathDictionary.ContainsKey(path))
                itemInDictionary = itemAtPathDictionary[path];
            else
                itemInDictionary = ItemAtPathUtil(path);

            if (itemInDictionary == null)
                throw new PathNotExistException(path);

            //// CM: 07/07/09 the path must be unique path. Need to create a list and add the object to the list.
            //// Even though the spec shows the the precondition should be that the path must not be unique path, but this
            //// may be too restrictive. So for the moment, when the path is unique, then need to create a list instance
            //// and add the single object to the list rather than throw an exception.

            List<object> items = itemInDictionary as List<object>;
            if (items == null)
            {
                Check.Assert(!(itemInDictionary is IList), "itemInDiction must not be of type IList");

                items = new OpenEhr.AssumedTypes.List<object>();
                items.Add(itemInDictionary);
            }
            Check.Ensure(items != null, "items must not be null");

            return items;
        }
        public override List <object> ItemsAtPath(string path)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(path), "Path must not be null or empty.");

            object itemInDictionary = null;

            if (this.itemAtPathDictionary != null && this.itemAtPathDictionary.ContainsKey(path))
            {
                itemInDictionary = itemAtPathDictionary[path];
            }
            else
            {
                itemInDictionary = ItemAtPathUtil(path);
            }

            if (itemInDictionary == null)
            {
                throw new PathNotExistException(path);
            }

            //// CM: 07/07/09 the path must be unique path. Need to create a list and add the object to the list.
            //// Even though the spec shows the the precondition should be that the path must not be unique path, but this
            //// may be too restrictive. So for the moment, when the path is unique, then need to create a list instance
            //// and add the single object to the list rather than throw an exception.

            List <object> items = itemInDictionary as List <object>;

            if (items == null)
            {
                Check.Assert(!(itemInDictionary is IList), "itemInDiction must not be of type IList");

                items = new OpenEhr.AssumedTypes.List <object>();
                items.Add(itemInDictionary);
            }
            Check.Ensure(items != null, "items must not be null");

            return(items);
        }
Exemplo n.º 3
0
        private void ReadXml(CCodePhrase cDomainType)
        {
            reader.ReadStartElement();
            reader.MoveToContent();

            this.ReadXmlBase((CObject)cDomainType);

            if (reader.LocalName == "assumed_value")
            {
                CodePhrase assumedValue = new CodePhrase();
                assumedValue.ReadXml(reader);
                cDomainType.AssumedValue = assumedValue;
            }

            if (reader.LocalName == "terminology_id")
            {
                cDomainType.TerminologyId = new TerminologyId();
                cDomainType.TerminologyId.ReadXml(reader);
            }

            if (reader.LocalName == "code_list")
            {
                OpenEhr.AssumedTypes.List<string> codeList = new OpenEhr.AssumedTypes.List<string>();
                do
                {
                    string codeString = reader.ReadElementContentAsString("code_list", OpenEhrNamespace);
                    reader.MoveToContent();
                    codeList.Add(codeString);
                } while (reader.LocalName == "code_list");

                Check.Assert(!codeList.IsEmpty(), "codeList must not be empty.");

                cDomainType.CodeList = codeList;
            }

            reader.ReadEndElement();
            reader.MoveToContent();
        }