/// <summary> /// Writes the lab test result value type data to the specified XmlWriter. /// </summary> /// /// <param name="nodeName"> /// The name of the node to write the XML.</param> /// /// <param name="writer"> /// The XmlWriter to write the lab test result value type data to. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> is <b> null </b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b> null </b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Measurement"/> is <b> null </b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_measurement, Resources.LabTestResultValueTypeMeasurementNotSet); // <lab-test-result-value-type> writer.WriteStartElement(nodeName); // measurement _measurement.WriteXml("measurement", writer); // ranges for (int index = 0; index < _ranges.Count; ++index) { XmlWriterHelper.WriteOpt( writer, "ranges", _ranges[index]); } // flag for (int index = 0; index < _flag.Count; ++index) { XmlWriterHelper.WriteOpt( writer, "flag", _flag[index]); } // </lab-test-result-value-type> writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the AssociatedTypeInfo into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the associated type info. /// </param> /// /// <param name="writer"> /// The XML writer into which the AssociatedTypeInfo should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { if (string.IsNullOrEmpty(nodeName)) { throw new ArgumentException( Resources.WriteXmlEmptyNodeName, nameof(nodeName)); } if (writer == null) { throw new ArgumentNullException( nameof(writer), Resources.WriteXmlNullWriter); } writer.WriteStartElement(nodeName); if (_thingTypeVersionId.Equals(Guid.Empty)) { throw new InvalidOperationException(Resources.AssociatedThingTypeVersionIdNullorEmpty); } XmlWriterHelper.WriteOptGuid(writer, "thing-type-version-id", _thingTypeVersionId); XmlWriterHelper.WriteOptString(writer, "thing-type-value-xpath", _thingTypeValueXPath); XmlWriterHelper.WriteOptString(writer, "thing-type-display-xpath", _thingTypeDisplayXPath); writer.WriteEndElement(); }
internal void WriteXml(string nodeName, XmlWriter writer) { if (ItemKey == null && string.IsNullOrEmpty(ClientId)) { throw new ThingSerializationException(Resources.RelationshipItemKeyOrClientIdNotSpecified); } writer.WriteStartElement(nodeName); if (ItemKey != null) { writer.WriteElementString("thing-id", ItemKey.Id.ToString()); if (ItemKey.VersionStamp != Guid.Empty) { writer.WriteElementString("version-stamp", ItemKey.VersionStamp.ToString()); } } else { writer.WriteElementString("client-thing-id", ClientId); } XmlWriterHelper.WriteOptString(writer, "relationship-type", RelationshipType); writer.WriteEndElement(); }
/// <summary> /// Writes the contraindication data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the contraindication data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// The <see cref="Substance"/> or <see cref="Status"/> property has not been set. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_substance, Resources.ContraindicationSubstanceNotSet); Validator.ThrowSerializationIfNull(_status, Resources.ContraindicationStatusNotSet); // <contraindication> writer.WriteStartElement("contraindication"); // <substance> _substance.WriteXml("substance", writer); // <status> _status.WriteXml("status", writer); // <source> XmlWriterHelper.WriteOpt(writer, "source", _source); // <documenter> XmlWriterHelper.WriteOpt(writer, "documenter", _documenter); // <documented-date> XmlWriterHelper.WriteOpt(writer, "documented-date", _documentedDate); // </contraindication> writer.WriteEndElement(); }
/// <summary> /// Writes the family history relative data to the specified XmlWriter. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the family history relative item. /// </param> /// /// <param name="writer"> /// The XmlWriter to write the family history relative data to. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> is <b> null </b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b> null </b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Name"/> is <b> null </b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); // <family-history-relative> writer.WriteStartElement(nodeName); // relative-name XmlWriterHelper.WriteOpt( writer, "relative-name", _relativeName); // relationship XmlWriterHelper.WriteOpt( writer, "relationship", _relationship); // date-of-birth XmlWriterHelper.WriteOpt( writer, "date-of-birth", _dateOfBirth); // date-of-death XmlWriterHelper.WriteOpt( writer, "date-of-death", _dateOfDeath); // </family-history-relative> writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the CarePlanGoal into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the medical image study series. /// </param> /// /// <param name="writer"> /// The XML writer into which the CarePlanGoal should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Name"/> is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter); Validator.ThrowSerializationIfNull(_name, Resources.CarePlanGoalNameNull); writer.WriteStartElement("goal"); { _name.WriteXml("name", writer); XmlWriterHelper.WriteOptString(writer, "description", _description); XmlWriterHelper.WriteOpt(writer, "start-date", _startDate); XmlWriterHelper.WriteOpt(writer, "end-date", _endDate); XmlWriterHelper.WriteOpt(writer, "target-completion-date", _targetCompletionDate); XmlWriterHelper.WriteOpt(writer, "associated-type-info", _goalAssociatedTypeInfo); XmlWriterHelper.WriteOpt(writer, "target-range", _targetRange); if (_goalAdditionalRanges != null && _goalAdditionalRanges.Count != 0) { foreach (GoalRange goalRange in _goalAdditionalRanges) { goalRange.WriteXml("goal-additional-ranges", writer); } } XmlWriterHelper.WriteOpt(writer, "recurrence", _recurrence); XmlWriterHelper.WriteOptString(writer, "reference-id", _referenceId); } writer.WriteEndElement(); }
/// <summary> /// Writes the vital signs data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the vital signs data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// The <see cref="When"/> property has not been set. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.VitalSignsWhenNotSet); // <vital-signs> writer.WriteStartElement("vital-signs"); // <when> _when.WriteXml("when", writer); foreach (VitalSignsResultType vitalSignResult in _vitalSignsResults) { vitalSignResult.WriteXml("vital-signs-results", writer); } // <site> XmlWriterHelper.WriteOptString( writer, "site", _site); // <position> XmlWriterHelper.WriteOptString( writer, "position", _position); // </vital-signs> writer.WriteEndElement(); }
/// <summary> /// Gets the raw message internal. /// </summary> /// <param name="helper"></param> /// <returns></returns> /// <value>The raw message internal.</value> internal override string RawMessageDataInternal(XmlWriterHelper helper) { string result = string.Empty; using (XmlWriterHelper helper2 = XmlWriterHelper.GetHelper()) { try { helper2 .WriteStartElement("Polled_Event") .WriteElementString("Site_Code", this.SiteCode) .WriteElementString("Bar_Pos", this.BarPosition) .WriteElementString("Fault_Source", this.FaultSource) .WriteElementString("Fault_Type", this.FaultType) .WriteElementString("Installation", this.InstallationNo) .WriteElementString("Serial_No", this.SerialNo) .WriteElementString("Fault_Message", this.FaultMessage) .WriteElementString("Date", this.Date, DATE_TIME_FORMAT) .WriteElementString("Event_Value", this.EventValue) .WriteAction((h) => { this.Meters.RawMessageDataInternal(h); }) .WriteElementString("Description", this.Description) .WriteEndElement(); } catch { } finally { result = helper2.ToString(); } } return(result); }
/// <summary> /// Writes the application specific data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the application specific data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="ApplicationId"/>, <see cref="SubtypeTag"/>, or <see cref="Description"/> is <b>null</b> or empty. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter); Validator.ThrowSerializationIfNull(ApplicationId, Resources.AppSpecificAppIdMandatory); Validator.ThrowSerializationIfNull(SubtypeTag, Resources.AppSpecificTagMandatory); Validator.ThrowSerializationIfNull(Description, Resources.AppSpecificDescriptionMandatory); // <app-specific> writer.WriteStartElement("app-specific"); // <format-appid> writer.WriteElementString("format-appid", ApplicationId); // <format-tag> writer.WriteElementString("format-tag", SubtypeTag); // <when> XmlWriterHelper.WriteOpt( writer, "when", _when); // <summary> writer.WriteElementString("summary", Description); // the any node WriteApplicationSpecificXml(writer); // </app-specific> writer.WriteEndElement(); }
/// <summary> /// Writes the health problem data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the health problem data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// The <see cref="When"/> property has not been set. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.ProblemWhenNotSet); // <problem> writer.WriteStartElement("problem"); // <when> _when.WriteXml("when", writer); // <diagnosis> foreach (CodableValue value in _diagnosis) { value.WriteXml("diagnosis", writer); } // <duration> foreach (DurationValue value in _duration) { value.WriteXml("duration", writer); } // <importance> XmlWriterHelper.WriteOptInt( writer, "importance", _importance); // </problem> writer.WriteEndElement(); }
/// <summary> /// Writes the dose to the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer element for the dose. /// </param> /// /// <param name="writer"> /// The XmlWriter to write the dose to. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="nodeName"/> parameter is null or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="writer"/> parameter is null. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); writer.WriteStartElement(nodeName); XmlWriterHelper.WriteOptString( writer, "description", _description); XmlWriterHelper.WriteOptDouble( writer, "exact-dose", _exactDose); XmlWriterHelper.WriteOptDouble( writer, "min-dose", _minDose); XmlWriterHelper.WriteOptDouble( writer, "max-dose", _maxDose); writer.WriteEndElement(); }
/// <summary> /// Writes the body composition data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the body composition data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="When"/>, <see cref="MeasurementName"/> or <see cref="Value"/> is <b>null</b>. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue); Validator.ThrowSerializationIfNull(_measurementName, Resources.BodyCompositionMeasurementNameNotSet); Validator.ThrowSerializationIfNull(_value, Resources.BodyCompositionValueNotSet); // <body-composition> writer.WriteStartElement("body-composition"); // <when> _when.WriteXml("when", writer); // <measurement-name> _measurementName.WriteXml("measurement-name", writer); // <value> _value.WriteXml("value", writer); // <measurement-method> XmlWriterHelper.WriteOpt( writer, "measurement-method", _measurementMethod); // <site> XmlWriterHelper.WriteOpt( writer, "site", _site); // </body-composition> writer.WriteEndElement(); }
/// <summary> /// Writes the vocabulary item to the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer element for the code value. /// </param> /// /// <param name="writer"> /// The XmlWriter to write the code description to. /// </param> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// The Value or VocabularyName property /// is <b>null</b> or empty. /// </exception> /// internal void WriteXmlInternal(string nodeName, XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowIfStringNullOrEmpty(Value, "Value"); if (nodeName != null) { writer.WriteStartElement(nodeName); } writer.WriteElementString("code-value", Value); XmlWriterHelper.WriteOptString(writer, "display-text", DisplayText); XmlWriterHelper.WriteOptString(writer, "abbreviation-text", AbbreviationText); if (_infoXml != null) { writer.WriteStartElement("info-xml"); { writer.WriteRaw(_infoXml.CreateNavigator().InnerXml); } writer.WriteEndElement(); } if (nodeName != null) { writer.WriteEndElement(); } }
/// <summary> /// Writes the XML representation of the medical image study series into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the medical image study series. /// </param> /// /// <param name="writer"> /// The XML writer into which the medical image study series should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="AcquisitionDateTime"/> is <b>null</b>. /// If <see cref="Images"/> is <b>null</b> or doesn't contain any image. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); if (_images == null || _images.Count == 0) { throw new ThingSerializationException(Resources.ImagesMandatory); } writer.WriteStartElement(nodeName); XmlWriterHelper.WriteOpt(writer, "acquisition-datetime", _acquisitionDateTime); XmlWriterHelper.WriteOptString(writer, "description", _description); foreach (MedicalImageStudySeriesImage image in _images) { XmlWriterHelper.WriteOpt(writer, "images", image); } XmlWriterHelper.WriteOpt(writer, "institution-name", _institutionName); XmlWriterHelper.WriteOpt(writer, "modality", _modality); XmlWriterHelper.WriteOpt(writer, "body-part", _bodyPart); XmlWriterHelper.WriteOptString(writer, "preview-blob-name", _previewBlobName); XmlWriterHelper.WriteOptString(writer, "series-instance-uid", _seriesInstanceUID); writer.WriteEndElement(); }
public static bool SerializeDataContract <T>([NotNull] this TextWriter thisValue, T value, DataContractSerializerSettings settings = null, XmlWriterSettings xmlOptions = null) { XmlWriterSettings opt = xmlOptions ?? XmlWriterHelper.CreateSettings(); using (XmlWriter writer = XmlWriter.Create(thisValue, opt)) return(writer.SerializeDataContract(value, settings)); }
/// <summary> /// Writes the XML representation of the CarePlan into /// the specified XML writer. /// </summary> /// /// <param name="writer"> /// The XML writer into which the CarePlan should be /// written. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Name"/> is <b>null</b> or empty or contains only whitespace. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter); if (string.IsNullOrEmpty(_name) || string.IsNullOrEmpty(_name.Trim())) { throw new ThingSerializationException(Resources.CarePlanNameNullOrEmpty); } writer.WriteStartElement("care-plan"); { writer.WriteElementString("name", _name); XmlWriterHelper.WriteOpt(writer, "start-date", _startDate); XmlWriterHelper.WriteOpt(writer, "end-date", _endDate); XmlWriterHelper.WriteOpt(writer, "status", _status); XmlWriterHelper.WriteXmlCollection(writer, "care-team", _careTeam, "person"); XmlWriterHelper.WriteOpt(writer, "care-plan-manager", _carePlanManager); XmlWriterHelper.WriteXmlCollection(writer, "tasks", _tasks, "task"); XmlWriterHelper.WriteXmlCollection(writer, "goal-groups", _goalGroups, "goal-group"); } writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the delivery into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the delivery. /// </param> /// /// <param name="writer"> /// The XML writer into which the delivery should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); writer.WriteStartElement(nodeName); XmlWriterHelper.WriteOpt(writer, "location", _location); XmlWriterHelper.WriteOpt(writer, "time-of-delivery", _timeOfDelivery); XmlWriterHelper.WriteOptDouble(writer, "labor-duration", _laborDuration); foreach (CodableValue complication in _complications) { complication.WriteXml("complications", writer); } foreach (CodableValue anesthesia in _anesthesia) { anesthesia.WriteXml("anesthesia", writer); } XmlWriterHelper.WriteOpt(writer, "delivery-method", _deliveryMethod); XmlWriterHelper.WriteOpt(writer, "outcome", _outcome); XmlWriterHelper.WriteOpt(writer, "baby", _baby); XmlWriterHelper.WriteOptString(writer, "note", _note); writer.WriteEndElement(); }
/// <summary> /// Writes the blood oxygen saturation data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the blood oxygen saturation data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="When"/> is <b>null</b>. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue); // <blood-oxygen-saturation> writer.WriteStartElement("blood-oxygen-saturation"); // <when> _when.WriteXml("when", writer); // <value> writer.WriteElementString( "value", XmlConvert.ToString(_value)); // <measurement-method> XmlWriterHelper.WriteOpt( writer, "measurement-method", _measurementMethod); // <measurement-flags> XmlWriterHelper.WriteOpt( writer, "measurement-flags", _measurementFlags); // </blood-oxygen-saturation> writer.WriteEndElement(); }
/// <summary> /// Writes the lab test type data to the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer element for the lab test type. /// </param> /// /// <param name="writer"> /// The XmlWriter to write the lab test type to. /// </param> /// /// <exception cref="ArgumentException"> /// The <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// The <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); writer.WriteStartElement(nodeName); _when = new HealthServiceDateTime(); _when.WriteXml("when", writer); XmlWriterHelper.WriteOptString(writer, "name", _name); XmlWriterHelper.WriteOpt(writer, "substance", _substance); XmlWriterHelper.WriteOpt(writer, "collection-method", _collectionMethod); XmlWriterHelper.WriteOptString(writer, "abbreviation", _abbreviation); XmlWriterHelper.WriteOptString(writer, "description", _description); foreach (CodableValue codeValue in _code) { codeValue.WriteXml("code", writer); } XmlWriterHelper.WriteOpt(writer, "result", _result); XmlWriterHelper.WriteOpt(writer, "status", _status); writer.WriteEndElement(); }
public static void SaveFile([NotNull] this XDocument thisValue, [NotNull] string filename, XmlWriterSettings settings) { XmlWriterSettings options = settings ?? XmlWriterHelper.CreateSettings(); using (XmlWriter writer = XmlWriter.Create(filename, options)) thisValue.Save(writer); }
public static bool SaveAs([NotNull] this DataSet thisValue, [NotNull] string fileName, bool includeSchema = true, XmlWriterSettings options = null) { if (!IsValid(thisValue, true)) { return(false); } XmlWriterSettings opt = options ?? XmlWriterHelper.CreateSettings(); bool result; try { using (XmlWriter writer = XmlWriter.Create(File.OpenWrite(fileName), opt)) { thisValue.WriteXml(writer, includeSchema ? XmlWriteMode.WriteSchema : XmlWriteMode.IgnoreSchema); } result = true; } catch { result = false; } return(result); }
/// <summary> /// Writes the XML representation of the Service into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the Service. /// </param> /// /// <param name="writer"> /// The XML writer into which the Service should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="ServiceType"/> is <b>null</b>. /// If <see cref="ServiceDates"/> is <b>null</b>. /// If <see cref="ClaimAmounts"/> is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { Validator.ThrowIfStringNullOrEmpty(nodeName, "nodeName"); Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_serviceType, Resources.ServiceTypeNullValue); Validator.ThrowSerializationIfNull(_serviceDates, Resources.ServiceDatesNullValue); Validator.ThrowSerializationIfNull(_claimAmounts, Resources.ClaimAmountsNullValue); writer.WriteStartElement(nodeName); _serviceType.WriteXml("service-type", writer); XmlWriterHelper.WriteOpt(writer, "diagnosis", _diagnosis); XmlWriterHelper.WriteOpt(writer, "billing-code", _billingCode); _serviceDates.WriteXml("service-dates", writer); _claimAmounts.WriteXml("claim-amounts", writer); foreach (string note in _notes) { writer.WriteElementString("notes", note); } writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the GoalRecurrence into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the medical image study series. /// </param> /// /// <param name="writer"> /// The XML writer into which the GoalRecurrence should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Interval"/> is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { if (string.IsNullOrEmpty(nodeName)) { throw new ArgumentException( Resources.WriteXmlEmptyNodeName, nameof(nodeName)); } if (writer == null) { throw new ArgumentNullException( nameof(writer), Resources.WriteXmlNullWriter); } if (_interval == null) { throw new ThingSerializationException( Resources.GoalRecurrenceIntervalNullValue); } writer.WriteStartElement(nodeName); _interval.WriteXml("interval", writer); XmlWriterHelper.WriteOptInt(writer, "times-in-interval", _timesInInterval); writer.WriteEndElement(); }
/// <summary> /// Write the serialized version of the data to the specified writer. /// </summary> /// <param name="writer">The writer</param> public void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); if (string.IsNullOrEmpty(Name)) { throw new InvalidOperationException(Resources.VocabularyNameNullOrEmpty); } writer.WriteElementString("vocabulary-format-version", "1"); writer.WriteElementString("name", Name); XmlWriterHelper.WriteOptString(writer, "family", Family); XmlWriterHelper.WriteOptString(writer, "version", Version); if (Count == 0) { return; } writer.WriteStartElement("items"); { foreach (KeyValuePair <string, VocabularyItem> item in this) { item.Value.WriteXmlInternal("item", writer); } } writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the GoalRange into /// the specified XML writer. /// </summary> /// /// <param name="nodeName"> /// The name of the outer node for the medical image study series. /// </param> /// /// <param name="writer"> /// The XML writer into which the GoalRange should be /// written. /// </param> /// /// <exception cref="ArgumentException"> /// If <paramref name="nodeName"/> parameter is <b>null</b> or empty. /// </exception> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Name"/> is <b>null</b>. /// </exception> /// public override void WriteXml(string nodeName, XmlWriter writer) { if (string.IsNullOrEmpty(nodeName)) { throw new ArgumentException( Resources.WriteXmlEmptyNodeName, nameof(nodeName)); } if (writer == null) { throw new ArgumentNullException( nameof(writer), Resources.WriteXmlNullWriter); } if (_name == null) { throw new ThingSerializationException( Resources.GoalRangeNameNullValue); } writer.WriteStartElement(nodeName); _name.WriteXml("name", writer); XmlWriterHelper.WriteOptString(writer, "description", _description); XmlWriterHelper.WriteOpt(writer, "minimum", _minimum); XmlWriterHelper.WriteOpt(writer, "maximum", _maximum); writer.WriteEndElement(); }
/// <summary> /// Writes the appointment data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the appointment data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfArgumentNull(writer, nameof(writer), Resources.WriteXmlNullWriter); Validator.ThrowSerializationIfNull(_when, Resources.AppointmentWhenNotSet); // <appointment> writer.WriteStartElement("appointment"); // <when> _when.WriteXml("when", writer); // <duration> XmlWriterHelper.WriteOpt( writer, "duration", _duration); // <service> Service?.WriteXml("service", writer); // <clinic> Clinic?.WriteXml("clinic", writer); // <specialty> Specialty?.WriteXml("specialty", writer); // <status> Status?.WriteXml("status", writer); // <care-class> CareClass?.WriteXml("care-class", writer); // </appointment> writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the HealthGoal into /// the specified XML writer. /// </summary> /// /// <param name="writer"> /// The XML writer into which the HealthGoal should be /// written. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="Name"/> is <b>null</b>. /// </exception> /// public override void WriteXml(XmlWriter writer) { if (writer == null) { throw new ArgumentNullException( nameof(writer), Resources.WriteXmlNullWriter); } if (_name == null) { throw new ThingSerializationException( Resources.GoalNameNullValue); } writer.WriteStartElement("health-goal"); _name.WriteXml("name", writer); XmlWriterHelper.WriteOptString(writer, "description", _description); XmlWriterHelper.WriteOpt(writer, "start-date", _startDate); XmlWriterHelper.WriteOpt(writer, "end-date", _endDate); XmlWriterHelper.WriteOpt(writer, "associated-type-info", _associatedTypeInfo); XmlWriterHelper.WriteOpt(writer, "target-range", _targetRange); if (_goalAdditionalRanges != null && _goalAdditionalRanges.Count != 0) { foreach (GoalRange goalRange in _goalAdditionalRanges) { goalRange.WriteXml("goal-additional-ranges", writer); } } XmlWriterHelper.WriteOpt(writer, "recurrence", _recurrence); writer.WriteEndElement(); }
/// <summary> /// Writes the radiology laboratory results data to the specified XmlWriter. /// </summary> /// /// <param name="writer"> /// The XmlWriter to write the radiology laboratory results data to. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// The <see cref="When"/> property has not been set. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.RadiologyLabResultsWhenNotSet); // <radiology-lab-results> writer.WriteStartElement("radiology-lab-results"); // <when> _when.WriteXml("when", writer); // <title> XmlWriterHelper.WriteOptString( writer, "title", _title); // <anatomic-site> XmlWriterHelper.WriteOptString( writer, "anatomic-site", _anatomicSite); // <result-text> XmlWriterHelper.WriteOptString( writer, "result-text", _resultText); // </radiology-lab-result> writer.WriteEndElement(); }
/// <summary> /// Writes the XML representation of the medical image study into /// the specified XML writer. /// </summary> /// /// <param name="writer"> /// The XML writer into which the medical image study series should be /// written. /// </param> /// /// <exception cref="ArgumentNullException"> /// If <paramref name="writer"/> parameter is <b>null</b>. /// </exception> /// /// <exception cref="ThingSerializationException"> /// If <see cref="When"/> is <b>null</b>. /// If <see cref="Series"/> collection is <b>null</b> or empty. /// </exception> /// public override void WriteXml(XmlWriter writer) { Validator.ThrowIfWriterNull(writer); Validator.ThrowSerializationIfNull(_when, Resources.WhenNullValue); if (_series == null || _series.Count == 0) { throw new ThingSerializationException(Resources.MedicalImageStudySeriesMandatory); } writer.WriteStartElement("medical-image-study"); _when.WriteXml("when", writer); XmlWriterHelper.WriteOptString(writer, "patient-name", _patientName); XmlWriterHelper.WriteOptString(writer, "description", _description); foreach (MedicalImageStudySeries imageStudySeries in _series) { imageStudySeries.WriteXml("series", writer); } XmlWriterHelper.WriteOpt(writer, "reason", _reason); XmlWriterHelper.WriteOptString(writer, "preview-blob-name", _previewBlobName); foreach (MedicalImageStudySeriesImage image in _keyImages) { image.WriteXml("key-images", writer); } XmlWriterHelper.WriteOptString(writer, "study-instance-uid", _studyInstanceUID); writer.WriteEndElement(); }
private void interfaceXmlWriter() { Console.WriteLine("Writing XML > Write using XmlWriter Class"); Console.WriteLine("==========="); Console.WriteLine("1. Simple Writing"); Console.WriteLine("2. Writing Attributes"); Console.WriteLine("3. Formatting"); Console.WriteLine("4. Write to StringBuilder"); Console.Write("Select: "); var input = Console.ReadLine(); switch (input) { case "1": XmlWriterHelper.GetInstance().SimpleWriting(); break; case "2": XmlWriterHelper.GetInstance().WritingAttributes(); break; case "3": XmlWriterHelper.GetInstance().Formatting(); break; case "4": XmlWriterHelper.GetInstance().WriteToStringBuilder(); break; } }