using System.Xml.Linq; using Deltares.Standard.IO.DtoAssembler; namespace Deltares.Standard { public class FileIdentificationAssembler : IDtoAssembler { private const string elementName = "FileIdentification"; private const string elementNamespace = "http://deltares.nl/2008/FileIdentificationDefinition"; private readonly DtoPropertyAttributeMap map = new DtoPropertyAttributeMap(); public FileIdentificationAssembler() { const string attApplication = "Application"; this.map.Add(attApplication, new DtoPropertyAttriubteMapping() { PropertyName = attApplication, AttributeName = attApplication, Importance = DtoPropertyImportance.Required }); const string attVersion = "Version"; this.map.Add(attVersion, new DtoPropertyAttriubteMapping() { PropertyName = attVersion, AttributeName = attVersion, Importance = DtoPropertyImportance.Required }); const string attCreated = "Created"; this.map.Add(attCreated, new DtoPropertyAttriubteMapping() { PropertyName = attCreated, AttributeName = attCreated, Importance = DtoPropertyImportance.Required }); const string attCompany = "Company"; this.map.Add(attCompany, new DtoPropertyAttriubteMapping() { PropertyName = attCompany, AttributeName = attCompany, Importance = DtoPropertyImportance.Required }); const string attLicense = "License"; this.map.Add(attLicense, new DtoPropertyAttriubteMapping() { PropertyName = attLicense, AttributeName = attLicense, Importance = DtoPropertyImportance.Optional }); const string attDescription = "Description"; this.map.Add(attDescription, new DtoPropertyAttriubteMapping() { PropertyName = attDescription, AttributeName = attDescription, Importance = DtoPropertyImportance.Optional }); } /// /// Gets or sets the namespace value for the element /// public string ElementNamespace { get { return elementNamespace; } } #region IDtoAssembler Members /// /// Gets the xml element name /// public string ElementName { get { return elementName; } } /// /// Assembles a FieldIdentification object from an Dto (XElement) /// /// The data transfer object /// The materialized domain object public FileIdentification CreateDomainObject(XElement dtoObj) { return new FileIdentification() .Materialize(dtoObj); } public XElement CreateDataTransferObject(FileIdentification domainObj) { XElement el = new XElement(elementName) .Materialize(domainObj, this.map); return el; } #endregion public XElement CreateDataTransferObject(FileIdentification domainObj, XNamespace elementNamespace) { return new XElement(elementNamespace + elementName) .Materialize(domainObj, this.map); } } }