// Copyright (C) Stichting Deltares 2023. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System.Xml.Linq;
namespace Deltares.DamEngine.Calculators.KernelWrappers.Assemblers
{
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";
map.Add(attApplication, new DtoPropertyAttributeMapping
{
PropertyName = attApplication,
AttributeName = attApplication,
Importance = DtoPropertyImportance.Required
});
const string attVersion = "Version";
map.Add(attVersion, new DtoPropertyAttributeMapping
{
PropertyName = attVersion,
AttributeName = attVersion,
Importance = DtoPropertyImportance.Required
});
const string attCreated = "Created";
map.Add(attCreated, new DtoPropertyAttributeMapping
{
PropertyName = attCreated,
AttributeName = attCreated,
Importance = DtoPropertyImportance.Required
});
const string attCompany = "Company";
map.Add(attCompany, new DtoPropertyAttributeMapping
{
PropertyName = attCompany,
AttributeName = attCompany,
Importance = DtoPropertyImportance.Required
});
const string attLicense = "License";
map.Add(attLicense, new DtoPropertyAttributeMapping
{
PropertyName = attLicense,
AttributeName = attLicense,
Importance = DtoPropertyImportance.Optional
});
const string attDescription = "Description";
map.Add(attDescription, new DtoPropertyAttributeMapping
{
PropertyName = attDescription,
AttributeName = attDescription,
Importance = DtoPropertyImportance.Optional
});
}
///
/// Gets or sets the namespace value for the element
///
public string ElementNamespace
{
get
{
return elementNamespace;
}
}
public XElement CreateDataTransferObject(FileIdentification domainObj, XNamespace elementNamespace)
{
return new XElement(elementNamespace + elementName)
.Materialize(domainObj, map);
}
#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, map);
return el;
}
#endregion
}
}