first commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Configuration;
|
||||
|
||||
namespace CRIF.ACTion.Common.Builders
|
||||
{
|
||||
public abstract class BuilderBase : IBuildable
|
||||
{
|
||||
public readonly XNamespace CrifRequestSectionNamespace;
|
||||
|
||||
private protected CrifSettings _settings;
|
||||
|
||||
public BuilderBase(XNamespace mainSectionNamespace, CrifSettings settings)
|
||||
{
|
||||
CrifRequestSectionNamespace = mainSectionNamespace;
|
||||
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public virtual XElement Build(params XElement[] content)
|
||||
{
|
||||
return new XElement(CrifNamespaces.Empty + "actionAPI",
|
||||
new XAttribute("version", 1),
|
||||
new XAttribute("xmlns", ""),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.Common.Prefix, CrifNamespaces.Common.ToString()),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.App.Prefix, CrifNamespaces.App.ToString()),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.Messages.Prefix, CrifNamespaces.Messages.ToString()),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.QO.Prefix, CrifNamespaces.QO.ToString()),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.Maint.Prefix, CrifNamespaces.Maint.ToString()),
|
||||
new XAttribute(XNamespace.Xmlns + CrifNamespaces.XSI.Prefix, CrifNamespaces.XSI.ToString()),
|
||||
content);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace CRIF.ACTion.Common.Builders
|
||||
{
|
||||
public class BuilderUtils
|
||||
{
|
||||
public static string FormatCrifData(string data)
|
||||
{
|
||||
return data?.ToUpper();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Xml.Linq;
|
||||
using CRIF.ACTion.Configuration;
|
||||
|
||||
namespace CRIF.ACTion.Common.Builders
|
||||
{
|
||||
public class CrifRequestSection : IBuildable
|
||||
{
|
||||
private readonly XNamespace SectionNamespace;
|
||||
private readonly string SectionName;
|
||||
private readonly List<XObject> Content;
|
||||
private readonly List<XObject> Attributes;
|
||||
|
||||
private protected readonly CrifSettings _settings;
|
||||
|
||||
private protected CrifRequestSection(XNamespace sectionNamespace, string sectionName, CrifSettings settings)
|
||||
{
|
||||
SectionNamespace = sectionNamespace;
|
||||
SectionName = sectionName;
|
||||
|
||||
Content = [];
|
||||
Attributes = [];
|
||||
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public XElement Build(params XElement[] content)
|
||||
{
|
||||
var element = new XElement(SectionNamespace + SectionName, Attributes);
|
||||
element.Add([.. Content]);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public void AddContent(XObject element)
|
||||
{
|
||||
Content.Add(element);
|
||||
}
|
||||
|
||||
public void AddAttribute(XObject attribute)
|
||||
{
|
||||
Attributes.Add(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CRIF.ACTion.Common.Builders
|
||||
{
|
||||
public interface IBuildable
|
||||
{
|
||||
XElement Build(params XElement[] content);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user