Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/hkutluay/Ubl-Tr
Browse files Browse the repository at this point in the history
  • Loading branch information
hkutluay committed Apr 19, 2020
2 parents 8258a94 + 92c0fc4 commit 6b279dd
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,19 @@ PM> Install-Package UblTr

## Serialize
```csharp
var invoice = new InvoiceType();
invoice.UUID = new Common.UUIDType() { Value = Guid.NewGuid().ToString() };
invoice.UBLVersionID = new Common.UBLVersionIDType() { Value = "2.1" };
invoice.CustomizationID = new Common.CustomizationIDType() { Value = "TR1.2" };
invoice.ProfileID = new Common.ProfileIDType() { Value = "TEMELFATURA" };
invoice.ID = new Common.IDType() { Value = "INV20200000000001" };
invoice.CopyIndicator = new Common.CopyIndicatorType() { Value = false };

var namespaces = new XmlSerializerNamespaces();
namespaces.Add("cac", "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2");
namespaces.Add("cbc", "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2");
namespaces.Add("ccts", "urn:un:unece:uncefact:documentation:2");
namespaces.Add("ds", "http://www.w3.org/2000/09/xmldsig#");
namespaces.Add("ext", "urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2");
namespaces.Add("ubltr", "urn:oasis:names:specification:ubl:schema:xsd:TurkishCustomizationExtensionComponents");
namespaces.Add("qdt", "urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2");
namespaces.Add("udt", "urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2");
namespaces.Add("xades", "http://uri.etsi.org/01903/v1.3.2#");
namespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
var invoice = new InvoiceType
{
UUID = new Common.UUIDType() { Value = Guid.NewGuid().ToString() },
UBLVersionID = new Common.UBLVersionIDType() { Value = "2.1" },
CustomizationID = new Common.CustomizationIDType() { Value = "TR1.2" },
ProfileID = new Common.ProfileIDType() { Value = "TEMELFATURA" },
ID = new Common.IDType() { Value = "INV20200000000001" },
CopyIndicator = new Common.CopyIndicatorType() { Value = false }
};

XmlSerializer xmlSerializer = new XmlSerializer(typeof(InvoiceType));
TextWriter writer = new StreamWriter(@"C:\Temp\TestInvoice.xml"); //path to document
xmlSerializer.Serialize(writer, invoice, namespaces);
xmlSerializer.Serialize(writer, invoice, new UblTrNamespaces());

```

Expand Down

0 comments on commit 6b279dd

Please sign in to comment.