Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Xml.Serialization;
- namespace TCPAgent
- {
- [XmlRoot("IncomingMessage")]
- public class TcpAgentXmlMessage
- {
- [XmlElement("facilitySMIS")]
- public List<FacilitySmisXml> FacilitiesNodes { get; set; }
- }
- public class FacilitySmisXml
- {
- public FacilitySmisXml()
- {
- FacilityId = null;
- SystemId = null;
- }
- [XmlAttribute("SystemId")]
- public string SystemId { get; set; }
- [XmlAttribute("facilityId")]
- public string FacilityId { get; set; }
- [XmlElement("parameterFacilitySMIS")]
- public ParameterFacilitySMISXml ParameterFacilitySMIS { get; set; }
- }
- public class ParameterFacilitySMISXml
- {
- public ParameterFacilitySMISXml()
- {
- ParamFacilityId = null;
- }
- [XmlAttribute("paramFacilityId")]
- public string ParamFacilityId { get; set; }
- [XmlElement("value")]
- public ValueXml Value { get; set; }
- }
- public class ValueXml
- {
- public ValueXml()
- {
- _dateFixation = new DateTime();
- Value = null;
- Description = null;
- }
- private DateTime _dateFixation;
- [XmlAttribute("dateFixation")]
- public string DateFixationString
- {
- get { return _dateFixation.ToString(); }
- set { DateTime.TryParse(value, out _dateFixation); }
- }
- [XmlIgnore]
- public DateTime DateFixation
- {
- get { return _dateFixation; }
- set { _dateFixation = value; }
- }
- [XmlAttribute("value")]
- public string Value { get; set; }
- [XmlAttribute("valueText")]
- public string Description { get; set; }
- }
- }
- public static T XmlDeserializeFromString<T>(string objectData)
- {
- return (T)XmlDeserializeFromString(objectData, typeof(T));
- }
- private static object XmlDeserializeFromString(string objectData, Type type)
- {
- var serializer = new XmlSerializer(type);
- object result;
- using (TextReader reader = new StringReader(objectData))
- {
- result = serializer.Deserialize(reader);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement