本文整理汇总了C#中ErrorList.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorList.Clear方法的具体用法?C# ErrorList.Clear怎么用?C# ErrorList.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorList
的用法示例。
在下文中一共展示了ErrorList.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseEmptyPrimitive
public void ParseEmptyPrimitive()
{
string xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' />";
ErrorList errors = new ErrorList();
FhirString result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.IsNotNull(result);
Assert.IsNull(result.Value);
Assert.AreEqual("4", result.LocalId.ToString());
xmlString = "<someString xmlns='http://hl7.org/fhir' id='4' value='' />";
errors.Clear();
result = (FhirString)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.IsNotNull(result);
Assert.IsNull(result.Value);
Assert.AreEqual("4", result.LocalId.ToString());
string jsonString = "{ \"someString\" : { \"_id\" : \"4\" } }";
errors.Clear();
result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.IsNotNull(result);
Assert.IsNull(result.Value);
Assert.AreEqual("4", result.LocalId.ToString());
jsonString = "{ \"someString\" : { \"_id\" : \"4\", \"value\" : \"\" } }";
errors.Clear();
result = (FhirString)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.IsNotNull(result);
Assert.IsNull(result.Value);
Assert.AreEqual("4", result.LocalId.ToString());
}
示例2: BinaryParsing
public void BinaryParsing()
{
string xmlString = @"<Binary id='pic1' contentType='image/gif' xmlns='http://hl7.org/fhir'>R0lGODlhEwARAPcAAAAAAAAA/+9aAO+1AP/WAP/eAP/eCP/eEP/eGP/nAP/nCP/nEP/nIf/nKf/nUv/nWv/vAP/vCP/vEP/vGP/vIf/vKf/vMf/vOf/vWv/vY//va//vjP/3c//3lP/3nP//tf//vf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAAEALAAAAAATABEAAAi+AAMIDDCgYMGBCBMSvMCQ4QCFCQcwDBGCA4cLDyEGECDxAoAQHjxwyKhQAMeGIUOSJJjRpIAGDS5wCDly4AALFlYOgHlBwwOSNydM0AmzwYGjBi8IHWoTgQYORg8QIGDAwAKhESI8HIDgwQaRDI1WXXAhK9MBBzZ8/XDxQoUFZC9IiCBh6wEHGz6IbNuwQoSpWxEgyLCXL8O/gAnylNlW6AUEBRIL7Og3KwQIiCXb9HsZQoIEUzUjNEiaNMKAAAA7</Binary>";
ErrorList errors = new ErrorList();
Binary result = (Binary)FhirParser.ParseResourceFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual("image/gif", result.ContentType);
Assert.AreEqual(993, result.Content.Length);
Assert.IsTrue(Encoding.ASCII.GetString(result.Content).StartsWith("GIF89a"));
byte[] data = result.Content;
File.WriteAllBytes(@"c:\temp\test.gif", data);
string json = "{ Binary: { contentType : \"image/gif\", " +
"content: \"R0lGODlhEwARAPcAAAAAAAAA/+9aAO+1AP/WAP/eAP/eCP/eEP/eGP/nAP/nCP/nEP/nIf/nKf/nUv/nWv/vAP/vCP/vEP/vGP/vIf/vKf/vMf/vOf/vWv/vY//va//vjP/3c//3lP/3nP//tf//vf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEAAAEALAAAAAATABEAAAi+AAMIDDCgYMGBCBMSvMCQ4QCFCQcwDBGCA4cLDyEGECDxAoAQHjxwyKhQAMeGIUOSJJjRpIAGDS5wCDly4AALFlYOgHlBwwOSNydM0AmzwYGjBi8IHWoTgQYORg8QIGDAwAKhESI8HIDgwQaRDI1WXXAhK9MBBzZ8/XDxQoUFZC9IiCBh6wEHGz6IbNuwQoSpWxEgyLCXL8O/gAnylNlW6AUEBRIL7Og3KwQIiCXb9HsZQoIEUzUjNEiaNMKAAAA7\" } }";
errors.Clear();
result = (Binary)FhirParser.ParseResourceFromJson(json, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual("image/gif", result.ContentType);
Assert.AreEqual(993, result.Content.Length);
Assert.IsTrue(Encoding.ASCII.GetString(result.Content).StartsWith("GIF89a"));
}
示例3: NarrativeParsing
public void NarrativeParsing()
{
string xmlString = @"<testNarrative xmlns='http://hl7.org/fhir'>
<status value='generated' />
<div xmlns='http://www.w3.org/1999/xhtml'>Whatever</div>
</testNarrative>";
ErrorList errors = new ErrorList();
Narrative result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value);
Assert.IsTrue(result.Div != null);
xmlString = @"<testNarrative xmlns='http://hl7.org/fhir'>
<status value='generated' />
<xhtml:div xmlns:xhtml='http://www.w3.org/1999/xhtml'>Whatever</xhtml:div>
</testNarrative>";
errors.Clear();
result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value);
Assert.IsTrue(result.Div != null);
xmlString = @"<testNarrative xmlns='http://hl7.org/fhir' xmlns:xhtml='http://www.w3.org/1999/xhtml'>
<status value='generated' />
<xhtml:div>Whatever</xhtml:div>
</testNarrative>";
errors.Clear();
result = (Narrative)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value);
Assert.IsTrue(result.Div != null);
string jsonString = "{ \"testNarrative\" : {" +
"\"status\" : { \"value\" : \"generated\" }, " +
"\"div\" : " +
"\"<div xmlns='http://www.w3.org/1999/xhtml'>Whatever</div>\" } }";
errors.Clear();
result = (Narrative)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(Narrative.NarrativeStatus.Generated, result.Status.Value);
Assert.IsTrue(result.Div != null);
}
示例4: CatchTagListParseErrors
public void CatchTagListParseErrors()
{
ErrorList errors = new ErrorList();
var tl = FhirParser.ParseTagListFromXml(xmlTagListE1, errors);
Assert.IsTrue(errors.Count != 0, errors.ToString());
errors.Clear();
tl = FhirParser.ParseTagListFromXml(xmlTagListE2, errors);
Assert.IsTrue(errors.Count != 0, errors.ToString());
errors.Clear();
tl = FhirParser.ParseTagListFromJson(jsonTagListE1, errors);
Assert.IsTrue(errors.Count != 0, errors.ToString());
errors.Clear();
tl = FhirParser.ParseTagListFromJson(jsonTagListE2, errors);
Assert.IsTrue(errors.Count != 0, errors.ToString());
errors.Clear();
}
示例5: ParsePrimitive
public void ParsePrimitive()
{
string xmlString = "<someBoolean xmlns='http://hl7.org/fhir' value='true' id='3141' />";
ErrorList errors = new ErrorList();
FhirBoolean result = (FhirBoolean)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count == 0, errors.ToString());
Assert.AreEqual(true, result.Value);
Assert.AreEqual("3141", result.Id.ToString());
string jsonString = "{\"someBoolean\": { \"value\" : true, \"_id\" : \"3141\" } }";
errors.Clear();
result = (FhirBoolean)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count == 0, errors.ToString());
Assert.AreEqual(true, result.Value);
Assert.AreEqual("3141", result.Id.ToString());
}
示例6: CompositeWithRepeatingElement
public void CompositeWithRepeatingElement()
{
string xmlString = @"
<testCodeableConcept xmlns='http://hl7.org/fhir'>
<coding>
<system value=""http://hl7.org/fhir/sid/icd-10"" />
<code value=""R51"" />
</coding>
<coding id='1'>
<system value=""http://snomed.info/id"" />
<code value=""25064002"" />
</coding>
</testCodeableConcept>";
ErrorList errors = new ErrorList();
CodeableConcept result = (CodeableConcept)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(2, result.Coding.Count);
Assert.AreEqual("R51", result.Coding[0].Code);
Assert.AreEqual("25064002", result.Coding[1].Code);
Assert.AreEqual("http://snomed.info/id", result.Coding[1].System.ToString());
Assert.AreEqual("1", result.Coding[1].LocalId.ToString());
string jsonString = @"{ ""testCodeableConcept"" :
{ ""coding"" : [
{ ""system"" : { ""value"" : ""http://hl7.org/fhir/sid/icd-10"" },
""code"" : { ""value"" : ""R51"" } },
{ ""_id"" : ""1"",
""system"": { ""value"" : ""http://snomed.info/id"" },
""code"" : { ""value"" : ""25064002"" } } ]
} }";
errors.Clear();
result = (CodeableConcept)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual(2, result.Coding.Count);
Assert.AreEqual("R51", result.Coding[0].Code);
Assert.AreEqual("25064002", result.Coding[1].Code);
Assert.AreEqual("http://snomed.info/id", result.Coding[1].System.ToString());
Assert.AreEqual("1", result.Coding[1].LocalId.ToString());
}
示例7: ParseUnknownMembersAndRecover
public void ParseUnknownMembersAndRecover()
{
string xmlString = @"<testCodeableConcept xmlns='http://hl7.org/fhir'>
<coding>
<system value='http://hl7.org/fhir/sid/icd-10' />
<ewout>bla</ewout>
<code value='R51' />
</coding>
<coding id='1'>
<system value='http://snomed.info/id' />
<code value='25064002' />
</coding>
<grahame></grahame>
</testCodeableConcept>";
ErrorList errors = new ErrorList();
CodeableConcept result = (CodeableConcept)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.AreEqual(2,errors.Count);
Assert.IsTrue(errors[0].ToString().Contains("ewout"));
Assert.IsTrue(errors[1].ToString().Contains("grahame"));
string jsonString = @"{ ""testCodeableConcept"" :
{ ""coding"" : [
{ ""system"": { ""value"" : ""http://hl7.org/fhir/sid/icd-10"" },
""ewout"" : ""bla"",
""code"" : { ""value"" : ""R51"" }
},
{ ""_id"" : ""1"",
""system"": { ""value"" : ""http://snomed.info/id"" },
""code"" : { ""value"" : ""25064002"" }
} ],
""grahame"" : { ""value"" : ""x"" } } }";
errors.Clear();
result = (CodeableConcept)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.AreEqual(2, errors.Count);
Assert.IsTrue(errors[0].ToString().Contains("ewout"));
Assert.IsTrue(errors[1].ToString().Contains("grahame"));
}
示例8: ParseSimpleComposite
public void ParseSimpleComposite()
{
string xmlString = @"<testCoding id='x4' xmlns='http://hl7.org/fhir'>
<system value='http://hl7.org/fhir/sid/icd-10' />
<code value='G44.1' />
</testCoding>";
ErrorList errors = new ErrorList();
Coding result = (Coding)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual("x4", result.LocalId.ToString());
Assert.AreEqual("G44.1", result.Code);
Assert.AreEqual("http://hl7.org/fhir/sid/icd-10", result.System.ToString());
Assert.IsNull(result.Display);
string jsonString = "{ \"testCoding\" : { \"_id\" : \"x4\", " +
"\"system\": { \"value\" : \"http://hl7.org/fhir/sid/icd-10\" }, " +
"\"code\": { \"value\" : \"G44.1\" } } }";
errors.Clear();
result = (Coding)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.AreEqual("x4", result.LocalId);
Assert.AreEqual("G44.1", result.Code);
Assert.AreEqual("http://hl7.org/fhir/sid/icd-10", result.System.ToString());
Assert.IsNull(result.Display);
}
示例9: ParsePerformance
public void ParsePerformance()
{
//string file = @"..\..\..\loinc.json";
string file = @"..\..\..\..\..\publish\diagnosticreport-example.xml";
int repeats = 20;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
ErrorList errors = new ErrorList();
for (int i = 0; i < repeats; i++)
{
errors.Clear();
var xmlr = XmlReader.Create(file);
//var jsonr = new JsonTextReader(new System.IO.StreamReader(file));
//var rep = FhirParser.ParseResource(jsonr, errors);
var rep = FhirParser.ParseResource(xmlr, errors);
}
Assert.IsTrue(errors.Count == 0, errors.ToString());
sw.Stop();
FileInfo f = new FileInfo(file);
long bytesPerMs = f.Length * repeats / sw.ElapsedMilliseconds;
File.WriteAllText(@"c:\temp\speedtest.txt", bytesPerMs.ToString() + " bytes per ms");
// Assert.IsTrue(bytesPerMs > 10*1024); // > 10k per ms (Speed is of course very dependent on debug/release and machine)
}
示例10: ParseLargeComposite
public void ParseLargeComposite()
{
XmlReader xr = XmlReader.Create(new StreamReader(@"..\..\..\..\..\publish\diagnosticreport-example.xml"));
ErrorList errors = new ErrorList();
DiagnosticReport rep = (DiagnosticReport)FhirParser.ParseResource(xr, errors);
validateDiagReportAttributes(errors, rep);
JsonTextReader jr = new JsonTextReader(new StreamReader(@"..\..\..\..\..\publish\diagnosticreport-example.json"));
errors.Clear();
rep = (DiagnosticReport)FhirParser.ParseResource(jr, errors);
validateDiagReportAttributes(errors, rep);
}
示例11: ParseJsonNativeTypes
public void ParseJsonNativeTypes()
{
string json = "{ testExtension: { url: { value : \"http://bla.com\" }," +
"isModifier: { value: true }, valueInteger: { value: 14 } } }";
var errors = new ErrorList();
var result = (Extension)FhirParser.ParseElementFromJson(json, errors);
Assert.IsTrue(errors.Count() == 0, errors.ToString());
Assert.IsTrue(result.IsModifier.Value);
Assert.AreEqual(14, ((Integer)result.Value).Value.Value);
string jsonWrong = "{ testExtension: { url: { value : \"http://bla.com\" }," +
"isModifier: { value: \"true\" }, valueInteger: { value: \"14\" } } }";
errors.Clear();
result = (Extension)FhirParser.ParseElementFromJson(jsonWrong, errors);
Assert.IsTrue(errors.Count() > 0);
Assert.IsTrue(errors.ToString().Contains("Expected") &&
errors.ToString().Contains("Boolean"),errors.ToString());
}
示例12: JsonDivZonderNamespace
public void JsonDivZonderNamespace()
{
string jsonString = "{ \"testNarrative\" : {" +
"\"status\" : { \"value\" : \"generated\" }, " +
"\"div\" : " +
"\"<div>Whatever</div>\" } }";
var errors = new ErrorList();
var result = (Narrative)FhirParser.ParseElementFromJson(jsonString, errors);
var xml = FhirSerializer.SerializeElementAsXml(result, "testNarrative");
Assert.IsTrue(xml.Contains("w3.org/1999/xhtml"));
jsonString = "{ \"testNarrative\" : {" +
"\"status\" : { \"value\" : \"generated\" }, " +
"\"div\" : " +
"\"<div xmlns='http://www.w3.org/1999/xhtml'>Whatever</div>\" } }";
errors.Clear();
result = (Narrative)FhirParser.ParseElementFromJson(jsonString, errors);
xml = FhirSerializer.SerializeElementAsXml(result, "testNarrative");
Assert.IsTrue(xml.Contains("w3.org/1999/xhtml"));
}
示例13: HandleCrapInFhirParser
public void HandleCrapInFhirParser()
{
var errors = new ErrorList();
FhirParser.ParseResourceFromJson("Crap!", errors);
Assert.IsTrue(errors.Count > 0);
errors.Clear();
FhirParser.ParseResourceFromJson("{ \" Crap!", errors);
Assert.IsTrue(errors.Count > 0);
errors.Clear();
FhirParser.ParseResourceFromXml("Crap", errors);
Assert.IsTrue(errors.Count > 0);
errors.Clear();
FhirParser.ParseResourceFromXml("<Crap><cra", errors);
Assert.IsTrue(errors.Count > 0);
}
示例14: ParseExtendedPrimitiveWithOtherElements
public void ParseExtendedPrimitiveWithOtherElements()
{
string xmlString =
@"<birthDate xmlns='http://hl7.org/fhir' value='1972-11-30'>
<crap />
<extension>
<url value='http://hl7.org/fhir/profile/@iso-21090#nullFlavor' />
<valueCode value='UNK' />
</extension>
</birthDate>";
ErrorList errors = new ErrorList();
Date result = (Date)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.AreNotEqual(0, errors.Count);
Assert.IsTrue(errors.ToString().Contains("crap"));
xmlString =
@"<birthDate xmlns='http://hl7.org/fhir' value='1972-11-30'>
<crap xmlns=""http://furore.com"" />
<extension>
<url value='http://hl7.org/fhir/profile/@iso-21090#nullFlavor' />
<valueCode value='UNK' />
</extension>
</birthDate>";
errors.Clear();
result = (Date)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.AreNotEqual(0, errors.Count);
Assert.IsTrue(errors.ToString().Contains("crap"));
string jsonString = @"{ ""birthDate"" :
{
""value"" : ""1972-11-30"",
""crap"" : {},
""extension"" : [
{
""url"" : { ""value"" : ""http://hl7.org/fhir/profile/@iso-21090#nullFlavor"" },
""valueCode"" : { ""value"" : ""UNK"" }
} ]
}
}";
errors.Clear();
result = (Date)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.AreNotEqual(0, errors.Count);
Assert.IsTrue(errors.ToString().Contains("crap"));
}
示例15: ParseExtendedPrimitive
public void ParseExtendedPrimitive()
{
string xmlString =
@"<birthDate xmlns='http://hl7.org/fhir' value='1972-11-30'>
<extension>
<url value='http://hl7.org/fhir/profile/@iso-21090#nullFlavor' />
<valueCode value='UNK' />
</extension>
</birthDate>";
ErrorList errors = new ErrorList();
Date result = (Date)FhirParser.ParseElementFromXml(xmlString, errors);
Assert.AreEqual(0, errors.Count, errors.ToString());
verifyParseExtendedPrimitive(result);
string jsonString = @"{ ""birthDate"" :
{
""value"" : ""1972-11-30"",
""extension"" : [
{
""url"" : { ""value"" : ""http://hl7.org/fhir/profile/@iso-21090#nullFlavor"" },
""valueCode"" : { ""value"" : ""UNK"" }
} ]
}
}";
errors.Clear();
result = (Date)FhirParser.ParseElementFromJson(jsonString, errors);
Assert.AreEqual(0, errors.Count);
verifyParseExtendedPrimitive(result);
}