public override bool Equals(System.Object obj) { // If parameter is null or not a DvUri return false. DvUri uri = obj as DvUri; if ((object)uri == null) { return(false); } // Return true if the value match if (this.GetType() == uri.GetType()) { return(this.Value == uri.Value); } else { return(false); } }
private void ReadXml(ArchetypeOntology archetypeOntology) { Check.Require(archetypeOntology!= null, "archetypeOntology must not be null."); reader.ReadStartElement(); reader.MoveToContent(); if (reader.LocalName == "term_definitions") { System.Collections.Generic.Dictionary<string, AssumedTypes.Hash<ArchetypeTerm, string>> termDefinitionsDic = new Dictionary<string, OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>>(); do { string language = reader.GetAttribute("language"); reader.ReadStartElement(); reader.MoveToContent(); Dictionary<string, ArchetypeTerm> termDefimitionItemDic = new Dictionary<string, ArchetypeTerm>(); while (reader.LocalName == "items") { ArchetypeTerm archetypeTerm = new ArchetypeTerm(); this.ReadXml(archetypeTerm); termDefimitionItemDic.Add(archetypeTerm.Code, archetypeTerm); } reader.ReadEndElement(); reader.MoveToContent(); AssumedTypes.Hash<ArchetypeTerm, string> archetypeTermHash = new OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>(termDefimitionItemDic); termDefinitionsDic.Add(language, archetypeTermHash); } while (reader.LocalName == "term_definitions"); DesignByContract.Check.Assert(termDefinitionsDic.Count > 0, "termDefinitionDic must not be emppty."); archetypeOntology.TermDefinitions = new OpenEhr.AssumedTypes.Hash<OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>, string>(termDefinitionsDic); } if (reader.LocalName == "constraint_definitions") { System.Collections.Generic.Dictionary<string, AssumedTypes.Hash<ArchetypeTerm, string>> constraintDefinitionsDic = new Dictionary<string, OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>>(); do { string language = reader.GetAttribute("language"); Dictionary<string, ArchetypeTerm> constraintDefItemDic = new Dictionary<string, ArchetypeTerm>(); reader.ReadStartElement(); reader.MoveToContent(); while (reader.LocalName == "items") { ArchetypeTerm archetypeTerm = new ArchetypeTerm(); this.ReadXml(archetypeTerm); constraintDefItemDic.Add(archetypeTerm.Code, archetypeTerm); } reader.ReadEndElement(); reader.MoveToContent(); AssumedTypes.Hash<ArchetypeTerm, string> constraintDefItemHash = new OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>(constraintDefItemDic); constraintDefinitionsDic.Add(language, constraintDefItemHash); } while (reader.LocalName == "constraint_definitions"); DesignByContract.Check.Assert(constraintDefinitionsDic.Count > 0, "termDefinitionDic must not be emppty."); archetypeOntology.ConstraintDefinitions = new OpenEhr.AssumedTypes.Hash<OpenEhr.AssumedTypes.Hash<ArchetypeTerm, string>, string>(constraintDefinitionsDic); } if (reader.LocalName == "term_bindings") { if (reader.IsEmptyElement) { reader.Skip(); reader.MoveToContent(); } else { System.Collections.Generic.Dictionary<string, AssumedTypes.Hash<CodePhrase, string>> termBindingDic = new Dictionary<string, OpenEhr.AssumedTypes.Hash<CodePhrase, string>>(); do { Dictionary<string, CodePhrase> termBindingItemDic = new Dictionary<string, CodePhrase>(); string terminologyString = reader.GetAttribute("terminology"); DesignByContract.Check.Assert(!string.IsNullOrEmpty(terminologyString), "terminologyString must not be null or empty."); reader.ReadStartElement(); reader.MoveToContent(); while (reader.LocalName == "items") { string hashId = reader.GetAttribute("code"); reader.ReadStartElement(); reader.MoveToContent(); CodePhrase codePhrase = new CodePhrase(); codePhrase.ReadXml(reader); reader.ReadEndElement(); reader.MoveToContent(); termBindingItemDic.Add(hashId, codePhrase); } reader.ReadEndElement(); reader.MoveToContent(); DesignByContract.Check.Assert(termBindingItemDic.Count > 0, "termBindingItemDic must not be empty."); AssumedTypes.Hash<CodePhrase, string> termBindingItemHash = new OpenEhr.AssumedTypes.Hash<CodePhrase, string>(termBindingItemDic); termBindingDic.Add(terminologyString, termBindingItemHash); } while (reader.LocalName == "term_bindings"); DesignByContract.Check.Assert(termBindingDic.Count > 0, "termBindingDic must not be empty."); archetypeOntology.TermBindings = new OpenEhr.AssumedTypes.Hash<OpenEhr.AssumedTypes.Hash<CodePhrase, string>, string>(termBindingDic); } } if (reader.LocalName == "constraint_bindings") { System.Collections.Generic.Dictionary<string, AssumedTypes.Hash<DvUri, string>> constraintBindingDic = new Dictionary<string, OpenEhr.AssumedTypes.Hash<DvUri, string>>(); do { Dictionary<string, DvUri> constraintBindingItemDic = new Dictionary<string, DvUri>(); string terminologyString = reader.GetAttribute("terminology"); DesignByContract.Check.Assert(!string.IsNullOrEmpty(terminologyString), "terminologyString must not be null or empty."); reader.ReadStartElement(); reader.MoveToContent(); while (reader.LocalName == "items") { string hashId = reader.GetAttribute("code"); DvUri dvUri = new DvUri(); dvUri.ReadXml(reader); constraintBindingItemDic.Add(hashId, dvUri); } reader.ReadEndElement(); reader.MoveToContent(); DesignByContract.Check.Assert(constraintBindingItemDic.Count > 0, "constraintBindingItemDic must not be empty."); AssumedTypes.Hash<DvUri, string> constraintBindingItemHash = new OpenEhr.AssumedTypes.Hash<DvUri, string>(constraintBindingItemDic); constraintBindingDic.Add(terminologyString, constraintBindingItemHash); } while (reader.LocalName == "constraint_bindings"); DesignByContract.Check.Assert(constraintBindingDic.Count > 0, "termBindingDic must not be empty."); archetypeOntology.ConstraintBindings = new OpenEhr.AssumedTypes.Hash<OpenEhr.AssumedTypes.Hash<DvUri, string>, string>(constraintBindingDic); } DesignByContract.Check.Assert(reader.NodeType == System.Xml.XmlNodeType.EndElement, "Expected endElement"); reader.ReadEndElement(); reader.MoveToContent(); }