/// <summary> /// Builds a list of telecoms for a patient. /// </summary> /// <param name="patient">The patient for which to build the telecoms.</param> /// <returns>Returns a list of telecoms for a patient.</returns> private static LIST <TEL> BuildTelecoms(Demographic patient) { var telecoms = new LIST <TEL>(); if (patient.TelecomOptions.EmailAddresses.Count == 0) { // TODO: supply random email address telecoms.Add(new TEL("*****@*****.**", TelecommunicationAddressUse.Direct)); } if (patient.TelecomOptions.PhoneNumbers.Count == 0) { // TODO: supply random telephone number telecoms.Add(new TEL("9055751212", TelecommunicationAddressUse.WorkPlace)); } foreach (var email in patient.TelecomOptions.EmailAddresses) { telecoms.Add(new TEL(email, TelecommunicationAddressUse.Direct)); } foreach (var phone in patient.TelecomOptions.PhoneNumbers) { telecoms.Add(new TEL(phone)); } return(telecoms); }
/// <summary> /// Builds a list of addresses for a patient. /// </summary> /// <param name="patient">The patient for which to build the addresses.</param> /// <returns>Returns a list of addresses for a patient.</returns> private static LIST <AD> BuildAddresses(Demographic patient) { var addresses = new LIST <AD>(); foreach (var item in patient.Addresses) { var city = item.City == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.City, AddressPartType.City); var country = item.Country == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.Country, AddressPartType.Country); var postal = item.ZipPostalCode == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.ZipPostalCode, AddressPartType.PostalCode); var state = item.StateProvince == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.StateProvince, AddressPartType.State); var street = item.StreetAddress == null ? new ADXP { NullFlavor = NullFlavor.NoInformation } : new ADXP(item.StreetAddress, AddressPartType.StreetAddressLine); addresses.Add(new AD(new[] { city, country, postal, state, street })); } return(addresses); }
public void IncExAllTest05() { LIST <INT> aList = new LIST <INT>(10); aList.Add(1); aList.NullFlavor = NullFlavor.Other; Assert.IsFalse(aList.Validate()); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Parse the base data ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Host = this.Host; LIST <IGraphable> retVal = baseFormatter.Parse <LIST <IGraphable> >(s); // parse items // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { // Numerator if (s.LocalName == "item") { var parseResult = Host.Parse(s, GenericArguments[0]); result.Code = parseResult.Code; result.AddResultDetail(parseResult.Details); retVal.Add(parseResult.Structure); } else if (s.NodeType == System.Xml.XmlNodeType.Element) { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } } catch (MessageValidationException e) { result.AddResultDetail(new ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } } #endregion // Validate baseFormatter.Validate(retVal, s.ToString(), result); return(retVal); }
protected IfcBSplineSurface(DatabaseIfc db, IfcBSplineSurface s, DuplicateOptions options) : base(db, s, options) { mUDegree = s.mUDegree; mVDegree = s.mVDegree; foreach(LIST<IfcCartesianPoint> ps in s.ControlPointsList) mControlPointsList.Add(new LIST<IfcCartesianPoint>(ps.ConvertAll(x=>db.Factory.Duplicate(x) as IfcCartesianPoint))); mSurfaceForm = s.mSurfaceForm; mUClosed = s.mUClosed; mVClosed = s.mVClosed; mSelfIntersect = s.mSelfIntersect; }
/// <summary> /// Builds a list of name for a patient. /// </summary> /// <param name="patient">The patient for which to build the names.</param> /// <returns>Returns a list of name for a patient.</returns> private static LIST <PN> BuildNames(Demographic patient) { var personNames = new LIST <PN>(); foreach (var item in patient.Names) { personNames.Add(new PN(EntityNameUse.Legal, new[] { new ENXP(item.FirstName, EntityNamePartType.Given), new ENXP(item.LastName, EntityNamePartType.Family) })); } return(personNames); }
public void IncExAllTest02() { LIST <INT> aList = new LIST <INT>(), bList = new LIST <INT>(), cList = new LIST <INT>(); for (INT i = 1; i <= 5; i++) { aList.Add(i); bList.Add(i + 1); cList.Add(i * 10); } // Returns true as aList contains none of the items of cList var containsVal = aList.ExcludesAll(bList); Console.WriteLine("aList Excludes All bList: " + containsVal.ToString()); Assert.AreEqual(containsVal, false); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to read from</param> public virtual object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Get the current element name string currentElementName = s.LocalName; LIST <IGraphable> retVal = new LIST <IGraphable>(); // Read until the current name is exhausted while (s.LocalName == currentElementName && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.Element) { // Correct the XSI attribute //if (Util.CreateXSITypeName(GenericArguments[0]) != s.GetAttribute("type", DatatypeFormatter.NS_XSI) && // s is XmlStateReader && !String.IsNullOrEmpty(s.GetAttribute("type", DatatypeFormatter.NS_XSI))) // (s as XmlStateReader).AddFakeAttribute("type", Util.CreateXSITypeName(GenericArguments[0])); var hostResult = Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); retVal.Add(hostResult.Structure); } // Read until the next element s.Read(); while (s.NodeType != System.Xml.XmlNodeType.Element && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.EndElement && s.LocalName != currentElementName) { return(retVal); } s.Read(); } } // Return the array return(retVal); }
public void IncExAllTest01() { // create new empty lists of integers LIST <INT> aList = new LIST <INT>(10), bList = new LIST <INT>(10), cList = new LIST <INT>(10); // populate all lists for (INT i = 1; i <= 5; i++) { aList.Add(i); // Items: 1,2,3,4,5 bList.Add(i + 1); // Items: 2,3,4,5,6 cList.Add(i * 10); // Items: 10,20,30,40,50 } // Returns true as aList contains all of the items of aList var containsVal = aList.IncludesAll(aList); Console.WriteLine("aList Includes All aList: " + containsVal.ToString()); Assert.AreEqual(containsVal, true); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to read from</param> public virtual object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Get the current element name string currentElementName = s.LocalName; LIST<IGraphable> retVal = new LIST<IGraphable>(); // Read until the current name is exhausted while (s.LocalName == currentElementName && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.Element) { // Correct the XSI attribute //if (Util.CreateXSITypeName(GenericArguments[0]) != s.GetAttribute("type", DatatypeFormatter.NS_XSI) && // s is XmlStateReader && !String.IsNullOrEmpty(s.GetAttribute("type", DatatypeFormatter.NS_XSI))) // (s as XmlStateReader).AddFakeAttribute("type", Util.CreateXSITypeName(GenericArguments[0])); var hostResult = Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); retVal.Add(hostResult.Structure); } // Read until the next element s.Read(); while (s.NodeType != System.Xml.XmlNodeType.Element && !s.EOF) { if (s.NodeType == System.Xml.XmlNodeType.EndElement && s.LocalName != currentElementName) return retVal; s.Read(); } } // Return the array return retVal; }
/// <summary> /// Parse from wire level format /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Any formatter for the base attributes ANYFormatter baseFormatter = new ANYFormatter(); // Create the types Type qsiType = typeof(QSU <>); Type qsiGenericType = qsiType.MakeGenericType(GenericArguments); // Create an instance of rto from the rtoType object instance = qsiGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); DatatypeR2Formatter.CopyBaseAttributes(baseFormatter.Parse(s, result) as ANY, instance as ANY); // Read internal elements if ((instance as ANY).NullFlavor != null) { return(instance); } // Now process the elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; LIST <IGraphable> termList = new LIST <IGraphable>(4); s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.NodeType == System.Xml.XmlNodeType.Element) { switch (s.LocalName) { case "originalText": { var hostResult = this.Host.Parse(s, typeof(ED)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); (instance as IOriginalText).OriginalText = hostResult.Structure as ED; break; } case "term": { var hostResult = this.Host.Parse(s, typeof(IGraphable)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); termList.Add(hostResult.Structure as IGraphable); break; } default: result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); break; } } } catch (MessageValidationException e) // Message validation error { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } // Set term list ((IListContainer)instance).ContainedList = termList; } #endregion // Validate baseFormatter.Validate(instance as ANY, s.ToString(), result); return(instance); }
internal void addSegment(IfcSegmentIndexSelect segment) { mSegments.Add(segment); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Create the types Type sxprType = typeof(SXPR<>); Type sxprGenericType = sxprType.MakeGenericType(GenericArguments); // Details // Create an instance of rto from the rtoType object instance = sxprGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); if (s.GetAttribute("nullFlavor") != null) ((ANY)instance).NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); // Try get operator if (s.GetAttribute("operator") != null) sxprGenericType.GetProperty("Operator").SetValue(instance, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator?)), null); if (s.GetAttribute("specializationType") != null) { if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) sxprGenericType.GetProperty("Flavor").SetValue(instance, s.GetAttribute("specializationType"), null); else result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Flavor", "SXPR", s.ToString())); } #region Element Processing // List of components LIST<IGraphable> componentList = new LIST<IGraphable>(); // Parse elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "comp") // component { // Now determine the type of GTS //string typeName = s.GetAttribute("type", DatatypeFormatter.NS_XSI); //IDatatypeFormatter formatter = DatatypeFormatter.GetFormatter(typeName); //if (formatter == null) //{ // result.AddResultDetail(new ResultDetail(String.Format("Cannot parse a SXPR member of type '{0}'", typeName))); // return null; //} //else //{ // // Graph the Hull // formatter.Host = this.Host; // formatter.GenericArguments = GenericArguments; // componentList.Add(formatter.Parse(s, result) as IGraphable); //} var hostResult = this.Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); componentList.Add(hostResult.Structure as IGraphable); } } catch (MessageValidationException e) // Message validation error { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) s.Read(); } } } ((IListContainer)instance).ContainedList = componentList; #endregion // Validate ANYFormatter validation = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; validation.Validate(instance as ANY, pathName, result); return instance; }
public void IncExAllTest04() { LIST<INT> aList = new LIST<INT>(10), bList = new LIST<INT>(10), cList = new LIST<INT>(10); for (INT i = 1; i <= 5; i++) { aList.Add(i); bList.Add(i + 1); cList.Add(i * 10); } // Returns false as aList contains none of the items of bList var containsVal = aList.IncludesAll(bList); Console.WriteLine("aList Includes All bList: " + containsVal.ToString()); Assert.IsTrue(containsVal.Validate()); Assert.AreEqual(containsVal, false); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public override object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Create the types Type sxprType = typeof(SXPR <>); Type sxprGenericType = sxprType.MakeGenericType(GenericArguments); // Details // Create an instance of rto from the rtoType object instance = sxprGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); if (s.GetAttribute("nullFlavor") != null) { ((ANY)instance).NullFlavor = (NullFlavor)Util.FromWireFormat(s.GetAttribute("nullFlavor"), typeof(NullFlavor)); } // Try get operator if (s.GetAttribute("operator") != null) { sxprGenericType.GetProperty("Operator").SetValue(instance, Util.FromWireFormat(s.GetAttribute("operator"), typeof(SetOperator?)), null); } if (s.GetAttribute("specializationType") != null) { if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { sxprGenericType.GetProperty("Flavor").SetValue(instance, s.GetAttribute("specializationType"), null); } else { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Flavor", "SXPR", s.ToString())); } } #region Element Processing // List of components LIST <IGraphable> componentList = new LIST <IGraphable>(); // Parse elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "comp") // component { // Now determine the type of GTS //string typeName = s.GetAttribute("type", DatatypeFormatter.NS_XSI); //IDatatypeFormatter formatter = DatatypeFormatter.GetFormatter(typeName); //if (formatter == null) //{ // result.AddResultDetail(new ResultDetail(String.Format("Cannot parse a SXPR member of type '{0}'", typeName))); // return null; //} //else //{ // // Graph the Hull // formatter.Host = this.Host; // formatter.GenericArguments = GenericArguments; // componentList.Add(formatter.Parse(s, result) as IGraphable); //} var hostResult = this.Host.Parse(s, GenericArguments[0]); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); componentList.Add(hostResult.Structure as IGraphable); } } catch (MessageValidationException e) // Message validation error { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } } ((IListContainer)instance).ContainedList = componentList; #endregion // Validate ANYFormatter validation = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; validation.Validate(instance as ANY, pathName, result); return(instance); }
/// <summary> /// Parse from wire level format /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Any formatter for the base attributes ANYFormatter baseFormatter = new ANYFormatter(); // Create the types Type qsiType = typeof(QSU<>); Type qsiGenericType = qsiType.MakeGenericType(GenericArguments); // Create an instance of rto from the rtoType object instance = qsiGenericType.GetConstructor(Type.EmptyTypes).Invoke(null); DatatypeR2Formatter.CopyBaseAttributes(baseFormatter.Parse(s, result) as ANY, instance as ANY); // Read internal elements if ((instance as ANY).NullFlavor != null) return instance; // Now process the elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; LIST<IGraphable> termList = new LIST<IGraphable>(4); s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.NodeType == System.Xml.XmlNodeType.Element) { switch (s.LocalName) { case "originalText": { var hostResult = this.Host.Parse(s, typeof(ED)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); (instance as IOriginalText).OriginalText = hostResult.Structure as ED; break; } case "term": { var hostResult = this.Host.Parse(s, typeof(IGraphable)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); termList.Add(hostResult.Structure as IGraphable); break; } default: result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); break; } } } catch (MessageValidationException e) // Message validation error { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) s.Read(); } } // Set term list ((IListContainer)instance).ContainedList = termList; } #endregion // Validate baseFormatter.Validate(instance as ANY, s.ToString(), result); return instance; }
public void IncExAllTest05() { LIST<INT> aList = new LIST<INT>(10); aList.Add(1); aList.NullFlavor = NullFlavor.Other; Assert.IsFalse(aList.Validate()); }
/// <summary> /// Parse a CD as a particular type /// </summary> internal T Parse <T>(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) where T : ANY, ICodedValue, new() { // Instantiate the genericized T ANYFormatter baseFormatter = new ANYFormatter(); T retVal = baseFormatter.Parse <T>(s); if (s.GetAttribute("codeSystem") != null) { retVal.CodeSystem = s.GetAttribute("codeSystem"); } if (s.GetAttribute("codeSystemName") != null) { retVal.CodeSystemName = s.GetAttribute("codeSystemName"); } if (s.GetAttribute("codeSystemVersion") != null) { retVal.CodeSystemVersion = s.GetAttribute("codeSystemVersion"); } if (s.GetAttribute("valueSet") != null) { retVal.ValueSet = s.GetAttribute("valueSet"); } if (s.GetAttribute("valueSetVersion") != null) { retVal.ValueSetVersion = s.GetAttribute("valueSetVersion"); } // Now parse our data out... Attributes if (s.GetAttribute("code") != null) { string codeString = s.GetAttribute("code"); if (retVal is IConceptDescriptor) { var cdExpr = ParseCodeExpression(codeString, retVal); retVal.CodeValue = cdExpr.Code; retVal.DisplayName = cdExpr.DisplayName; if (cdExpr.Qualifier != null && !cdExpr.Qualifier.IsEmpty) { (retVal as IConceptDescriptor).Qualifier = new LIST <IGraphable>(cdExpr.Qualifier); } } else { retVal.CodeValue = codeString; } } // Elements #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; LIST <IGraphable> translations = new LIST <IGraphable>(10); s.Read(); // string Name while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "originalText") // Format using ED { var hostResult = this.Host.Parse(s, typeof(ED)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); retVal.OriginalText = hostResult.Structure as ED; } else if (s.LocalName == "displayName") // display name { var hostResult = this.Host.Parse(s, typeof(ST)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); retVal.DisplayName = hostResult.Structure as ST; } else if (s.LocalName == "translation") // Translation { var hostResult = Host.Parse(s, typeof(CD <String>)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); translations.Add(hostResult.Structure); } else if (s.NodeType == System.Xml.XmlNodeType.Element) { result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null)); } } catch (VocabularyException e) { result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Error, e.Message, e)); } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e)); } finally { if (s.Name == oldName) { s.Read(); } } } // Translations if (!translations.IsEmpty) { if (retVal is ICodedEquivalents) { (retVal as ICodedEquivalents).Translation = translations; } else { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, String.Format("Type does not support translations, '{0}' translations will not be included", translations.Count), s.ToString(), null)); } } } #endregion // Validate baseFormatter.Validate(retVal, s.ToString(), result); // Add validation to details return(retVal); }
/// <summary> /// Parse IHTSDO Expression CR List /// </summary> private LIST <CR <String> > ParseCodeExpressionQualifier(string expression, ICodedValue context) { if (expression.StartsWith("{") && expression.EndsWith("}")) { expression = expression.Substring(1, expression.Length - 2); } else if (expression.StartsWith("{")) { throw new InvalidOperationException(); } List <String> crExpressions = new List <string>(10); Regex splitReg = new Regex("^([0-9]*.*?)([=,{}():])(.*?)$", RegexOptions.Multiline); int bDepth = 0; string cExpr = String.Empty; while (expression.Length > 0) { var splitMatch = splitReg.Match(expression); // Successful match? if (!splitMatch.Success) { break; } // Determine the delimiter switch (splitMatch.Groups[2].Value) { case "{": // Increases scope case "(": bDepth++; cExpr += splitMatch.Groups[1].Value + splitMatch.Groups[2].Value; break; case "}": // Decreases scope case ")": bDepth--; cExpr += splitMatch.Groups[1].Value + splitMatch.Groups[2].Value; break; case ",": // Seperator if (bDepth == 0) { cExpr += splitMatch.Groups[1].Value; crExpressions.Add(cExpr); cExpr = String.Empty; } else { cExpr += splitMatch.Groups[1].Value + splitMatch.Groups[2].Value; } break; default: cExpr += splitMatch.Groups[1].Value + splitMatch.Groups[2].Value; break; } expression = splitMatch.Groups[3].Value; } // Last match? splitReg = new Regex("([0-9]+.*)"); var lastMatch = splitReg.Match(expression); // Successful match? if (lastMatch.Success) { cExpr += lastMatch.Groups[1].Value; } // Depth if (bDepth > 1) { throw new InvalidOperationException("Missing closing bracket in expression"); } crExpressions.Add(cExpr); // Prepare return value LIST <CR <String> > retVal = new LIST <CR <string> >(crExpressions.Count); // Now Process each expression splitReg = new Regex("^([0-9]+)[|]?(.*?)[|]?=([(]?.*)$", RegexOptions.Multiline); Regex codeMnemReg = new Regex("^([0-9]+)[|](.*?)[|]$", RegexOptions.Multiline); foreach (var expr in crExpressions) { // Each expression must match var exprMatch = splitReg.Match(expr); if (!exprMatch.Success) { throw new InvalidOperationException("Qualifier expression does not follow format of name=value"); } // Process the name CV <String> name = new CV <string>(exprMatch.Groups[1].Value, context.CodeSystem, context.CodeSystemName, context.CodeSystemVersion) { DisplayName = String.IsNullOrEmpty(exprMatch.Groups[2].Value) ? null : exprMatch.Groups[2].Value, ValueSet = context.ValueSet, ValueSetVersion = context.ValueSetVersion }; // Process value CD <String> value = null; decimal id; // Try to match the exact pattern of a code with description var codeMnemMatch = codeMnemReg.Match(exprMatch.Groups[3].Value); if (codeMnemMatch.Success) { value = new CD <string>(codeMnemMatch.Groups[1].Value, context.CodeSystem, context.CodeSystemName, context.CodeSystemVersion) { DisplayName = String.IsNullOrEmpty(codeMnemMatch.Groups[2].Value) ? null : codeMnemMatch.Groups[2].Value, ValueSet = context.ValueSet, ValueSetVersion = context.ValueSetVersion } } ; else if (decimal.TryParse(exprMatch.Groups[3].Value, out id)) // Simple code { value = new CD <string>(exprMatch.Groups[3].Value, context.CodeSystem, context.CodeSystemName, context.CodeSystemVersion) { ValueSet = context.ValueSet, ValueSetVersion = context.ValueSetVersion } } ; else // IHTSDO expression tree { string valueExpression = exprMatch.Groups[3].Value; value = ParseCodeExpression(valueExpression, context); } retVal.Add(new CR <string>(name, value)); } return(retVal); }
public void IncExAllTest01() { // create new empty lists of integers LIST<INT> aList = new LIST<INT>(10), bList = new LIST<INT>(10), cList = new LIST<INT>(10); // populate all lists for (INT i=1; i <= 5; i++) { aList.Add(i); // Items: 1,2,3,4,5 bList.Add(i + 1); // Items: 2,3,4,5,6 cList.Add(i * 10); // Items: 10,20,30,40,50 } // Returns true as aList contains all of the items of aList var containsVal = aList.IncludesAll(aList); Console.WriteLine("aList Includes All aList: " + containsVal.ToString()); Assert.AreEqual(containsVal,true); }