{"id":37531550,"url":"https://github.com/globallightingdata/gldf.net","last_synced_at":"2026-01-16T08:32:51.427Z","repository":{"id":65775702,"uuid":"385528083","full_name":"globallightingdata/gldf.net","owner":"globallightingdata","description":".NET library for the Global Lighting Data Format GLDF","archived":false,"fork":false,"pushed_at":"2025-12-04T13:44:53.000Z","size":1129,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-12-07T21:51:27.173Z","etag":null,"topics":["gldf","serializer","xml"],"latest_commit_sha":null,"homepage":"https://gldf.io","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/globallightingdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-07-13T08:12:35.000Z","updated_at":"2025-12-04T13:44:57.000Z","dependencies_parsed_at":"2024-07-24T08:10:56.332Z","dependency_job_id":null,"html_url":"https://github.com/globallightingdata/gldf.net","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":"0.016949152542372836","last_synced_commit":"ed64492aea6476161ce9010d346f94d8b698aa4a"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/globallightingdata/gldf.net","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globallightingdata%2Fgldf.net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globallightingdata%2Fgldf.net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globallightingdata%2Fgldf.net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globallightingdata%2Fgldf.net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/globallightingdata","download_url":"https://codeload.github.com/globallightingdata/gldf.net/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/globallightingdata%2Fgldf.net/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gldf","serializer","xml"],"created_at":"2026-01-16T08:32:51.308Z","updated_at":"2026-01-16T08:32:51.389Z","avatar_url":"https://github.com/globallightingdata.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GLDF .NET library\n\n![GLDF Logo](/img/logo.png)\n\n[![OnPublishedRelease](https://github.com/globallightingdata/gldf.net/actions/workflows/OnPublishedRelease.yml/badge.svg)](https://github.com/globallightingdata/gldf.net/actions/workflows/OnPublishedRelease.yml)  \n[![OnPush develop](https://github.com/globallightingdata/gldf.net/actions/workflows/OnPushDevelop.yml/badge.svg)](https://github.com/globallightingdata/gldf.net/actions/workflows/OnPushDevelop.yml)  \n[![NuGet Status](https://img.shields.io/nuget/v/GLDF.Net.svg)](https://www.nuget.org/packages/GLDF.Net/)\n\n## Intro\n\n.NET library for the Global Lighting Data Format [GLDF](https://gldf.io)\n\nFeatures\n\n- Serialize and deserialize GLDF XML\n- 100% format coverage of [version 1.0-rc3](https://github.com/globallightingdata/gldf/releases)\n- Validate GLDF XML with the GLDF XmlSchema (XSD)\n- Read and write .gldf container files, including all assets and meta-information.xml\n- Validate .gldf container files\n- Parse XML/container either into 1:1 .NET POCOs or alternatively with resolved references\n- No dependencies, small footprint (~1MB)\n- Windows \u0026 Unix compatible\n\nIf you would like to read the GLDF L3D format as well, have a look on [GLDF.L3d](https://github.com/globallightingdata/l3d.net)\n\n## How to get started\n\n### Requirements\n\n- [.NET 8/9/10](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) compatible project\n\n### Nuget package\n\nAdd the package within your IDE or using the CLI\n\n```bash\ndotnet add package GLDF.Net\n```\n\n---\n\n### GLDF XML Serialization\n\n#### Serialize GLDF domain DTOs to XML string\n\nAll models in the following examples are incomplete. For valid GLDF luminaires/sensors read the docs.\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nRoot root = new Root {Header = new Header {Author = \"Github Example\"}};\nstring xml = serializer.SerializeToXml(root);\n```\n\n#### Serialize GLDF domain DTOs to .xml file\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nRoot root = new Root {Header = new Header {Author = \"Github Example\"}};\nserializer.SerializeToXmlFile(root, @\"c:\\some\\file\\path\\product.xml\");\n```\n\n#### Serialize GLDF domain DTOs to XML stream\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nRoot root = new Root {Header = new Header {Author = \"Github Example\"}};\nusing Stream stream = new MemoryStream();\nserializer.SerializeToXmlStream(root, stream);\n```\n\n#### Deserialize GLDF XML string to domain DTOs\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nstring xml = @\"\u003cRoot\u003e\u003cHeader\u003e\u003cAuthor\u003eGithub Example\u003c/Author\u003e\u003c/Header\u003e\u003c/Root\u003e\";\nRoot root = serializer.DeserializeFromXml(xml);\n```\n\n#### Deserialize GLDF .xml file to domain DTOs\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nstring filePath = @\"c:\\some\\file\\path\\product.xml\";\nRoot root = serializer.DeserializeFromXmlFile(filePath);\n```\n\n#### Deserialize GLDF stream to domain DTOs\n\n```CSharp\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\nstring filePath = @\"c:\\some\\file\\path\\product.xml\";\nusing Stream stream = new FileStream(filePath, FileMode.Open);\nRoot root = serializer.DeserializeFromXmlStream(stream);\n```\n\n#### Set custom XML Serializer settings\n\n```CSharp\nXmlWriterSettings settings = new XmlWriterSettings();\nsettings.Encoding = Encoding.UTF32; // UTF-8 by default\nsettings.Indent = false; // true by default\n// ...more settings\nIGldfXmlSerializer serializer = new GldfXmlSerializer(settings);\n```\n\n---\n\n### GLDF XML validation\n\n#### Validate XML string with GLDF XmlSchema\n\n```CSharp\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\nstring xml = @\"\u003cRoot\u003e\u003cHeader\u003e\u003cAuthor\u003eGithub Example\u003c/Author\u003e\u003c/Header\u003e\u003c/Root\u003e\";\nIEnumerable\u003cValidationHint\u003e validationResult = gldfXmlValidator.ValidateXml(xml);\n\nforeach (var validationHint in validationResult)\n{\n    Console.Write(validationHint.Severity); // Error/Info/Warning\n    Console.Write(validationHint.ErrorType); // For XML validation its always XmlSchema\n    Console.Write(validationHint.Message); // E.g. missing XML Elements etc.\n    Console.Write(Environment.NewLine);\n}\n```\n\n#### Validate a .xml file with GLDF XmlSchema\n\n```CSharp\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\nstring filePath = @\"c:\\some\\file\\path\\product.xml\";\nIEnumerable\u003cValidationHint\u003e validationResult = gldfXmlValidator.ValidateXmlFile(filePath);\n```\n\n#### Validate a .xml Stream with GLDF XmlSchema\n\n```CSharp\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\nstring filePath = @\"c:\\some\\file\\path\\product.xml\";\nusing Stream stream = new FileStream(filePath, FileMode.Open);\nIEnumerable\u003cValidationHint\u003e validationResult = gldfXmlValidator.ValidateXmlStream(stream, leaveOpen:false);\n```\n\n#### Validate a .gldf container file with GLDF XmlSchema (the product.xml inside the zip)\n\n```CSharp\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nIEnumerable\u003cValidationHint\u003e validationResult = gldfXmlValidator.ValidateGldfFile(filePath);\n```\n\n#### Validate a .gldf container Stream with GLDF XmlSchema (the product.xml inside the zip)\n\n```CSharp\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nusing Stream stream = new FileStream(filePath, FileMode.Open);\nIEnumerable\u003cValidationHint\u003e validationResult = gldfXmlValidator.ValidateGldfStream(stream, leaveOpen:false);\n```\n\n#### Set Encoding for validation\n\n```CSharp\nvar encoding = Encoding.UTF32;\nvar gldfXmlValidator = new GldfXmlValidator(encoding);\nvar filePath = @\"c:\\some\\file\\path\\product.xml\";\ngldfXmlValidator.ValidateFile(filePath);\n```\n\n---\n\n### GLDF container read/write\n\n#### Create a .gldf container file\n\n```CSharp\nIGldfContainerWriter containerWriter = new GldfContainerWriter();\nGldfContainer gldf = new GldfContainer\n{\n    Product = new Root {Header = new Header {Author = \"Github example\"}},\n    Assets = new GldfAssets(),\n    MetaInformation = new MetaInformation()\n};\nvar filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\ncontainerWriter.WriteToGldfFile(filePath, gldf);\n```\n\n#### Write to a .gldf container Stream\n\n```CSharp\nIGldfContainerWriter containerWriter = new GldfContainerWriter();\nGldfContainer gldf = new GldfContainer\n{\n    Product = new Root {Header = new Header {Author = \"Github example\"}},\n    Assets = new GldfAssets(),\n    MetaInformation = new MetaInformation()\n};\nusing Stream stream = new MemoryStream();\ncontainerWriter.WriteToGldfStream(stream, leaveOpen:false, gldf);\n```\n\n#### Read a .gldf container file\n\n```CSharp\nIGldfContainerReader containerReader = new GldfContainerReader();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nGldfContainer container = containerReader.ReadFromGldfFile(filePath);\nConsole.WriteLine($\"GLDF author: {container.Product.Header.Author}\");\n```\n\n#### Read a .gldf container file with `ContainerLoadSettings`\n\n```CSharp\nIGldfContainerReader containerReader = new GldfContainerReader();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nvar settings = new ContainerLoadSettings\n{\n    ProductLoadBehaviour = ProductLoadBehaviour.Load,\n    AssetLoadBehaviour = AssetLoadBehaviour.FileNamesOnly,\n    MetaInfoLoadBehaviour = MetaInfoLoadBehaviour.Skip\n};\nGldfContainer container = containerReader.ReadFromGldfFile(filePath, settings);\nConsole.WriteLine($\"GLDF author: {container.Product.Header.Author}\");\n```\n\n#### Read from a .gldf container Stream\n\n```CSharp\nIGldfContainerReader containerReader = new GldfContainerReader();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nusing Stream stream = new FileStream(filePath, FileMode.Open);\nGldfContainer container = containerReader.ReadFromGldfStream(stream, leaveOpen:false);\nConsole.WriteLine($\"GLDF author: {container.Product.Header.Author}\");\n```\n\n#### Extract a .gldf container content to a directory\n\n```CSharp\nIGldfContainerReader containerReader = new GldfContainerReader();\nstring sourceFilePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nstring targetFolder = @\"c:\\some\\file\\path\\extractedContent\\\";\ncontainerReader.ExtractToDirectory(sourceFilePath, targetFolder);\n```\n\n#### Create a .gldf container from content in a directory\n\n```CSharp\nIGldfContainerWriter containerWriter = new GldfContainerWriter();\nstring sourceDirectory = @\"c:\\some\\file\\path\\extractedContent\\\";\nstring targetFile = @\"c:\\some\\file\\path\\luminaire.gldf\";\ncontainerWriter.CreateFromDirectory(sourceDirectory, targetFile);\n```\n\n---\n\n### GLF container validation\n\n#### Validate a GLDF container\n\n```CSharp\nIGldfValidator validator = new GldfValidator();\nGldfContainer gldfContainer = new GldfContainer\n{\n    Product = new Root {Header = new Header {Author = \"Github example\"}},\n    Assets = new GldfAssets(),\n    MetaInformation = new MetaInformation()\n};\nIEnumerable\u003cValidationHint\u003e validationResult = validator.ValidateGldf(gldfContainer);\n\nforeach (var validationHint in validationResult)\n{\n    Console.Write(validationHint.Severity); // Enum: Error/Info/Warning\n    Console.Write(validationHint.ErrorType); // Enum: E.g. InvalidZipFile\n    Console.Write(validationHint.Message); // E.g. Not a valid ZIP file etc.\n    Console.Write(Environment.NewLine);\n}\n```\n\n#### Validate a GLDF container file\n\n```CSharp\nIGldfValidator validator = new GldfValidator();\nvar filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nvar result = validator.ValidateGldfFile(filePath, ValidationFlags.All);\n```\n\n#### Validate GLDF partially with `ValidationFlags`\n\n```CSharp\nIGldfValidator validator = new GldfValidator();\nvar filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nvar flags = ValidationFlags.Schema | ValidationFlags.Zip;\nvar result = validator.ValidateGldfFile(filePath, flags);\n```\n\nSee [source](https://github.com/globallightingdata/gldf.net/tree/master/src/Gldf.Net/Validation/Rules) for individual Rules\n\n#### Validate a GLDF container Stream\n\n```CSharp\nIGldfValidator validator = new GldfValidator();\nstring filePath = @\"c:\\some\\file\\path\\luminaire.gldf\";\nusing Stream stream = new FileStream(filePath, FileMode.Open); \nvar result = validator.ValidateGldfStream(stream, leaveOpen:false, ValidationFlags.All);\n```\n\n---\n\n### Deserialize GLDF with resolved references\n\nThe `GldfXmlSerializer` and `GldfContainerReader` classes produce an exact 1:1 representation of the GLDF XML in .NET (`Root`). Which implies that any references such as Variant ➜ Emitter ➜ Equipment ➜ LightSource ➜ Photometry ➜ File are mapped in the form of Ids, which have to be resolved manually in your application. With the `GldfParser` you have an option to let it resolve during deserialisation for you. And optionally load the GLDF `File` element content as well:\n\n#### Parse into POCOs with resolved references\n\n```CSharp\nvar parserSettings = new ParserSettings\n{\n    LocalFileLoadBehaviour = LocalFileLoadBehaviour.Skip,\n    OnlineFileLoadBehaviour = OnlineFileLoadBehaviour.Load,\n    HttpClient = new HttpClient()\n};\nIGldfParser gldfParser = new GldfParser(parserSettings);\n\nvar rootTyped = gldfParser.ParseFromXml(/* GLDF XML string */);\n// Or\nvar rootTyped = gldfParser.ParseFromXmlFile(/* GLDF XML filepath */);\n// Or\nvar rootTyped = gldfParser.ParseFromXmlStream(/* GLDF XML stream */);\n// Or\nvar rootTyped = gldfParser.ParseFromRoot(/* Root POCO */);\n// Or\nvar rootTyped = gldfParser.ParseFromGldf(/* GldfContainer POCO */);\n// Or\nvar rootTyped = gldfParser.ParseFromGldfFile(/* GLDF container filepath */);\n// Or\nvar rootTyped = gldfParser.ParseFromGldfStream(/* GLDF container stream */);\n```\n\n---\n\n### Meta-Information XML Serialization\n\nSee [gldf.io](https://gldf.io/docs/container/meta-information) to learn more about meta-information.xml\n\n#### Serialize Meta-Information DTO to XML string\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nvar metaInformation = new MetaInformation();\nstring xml = serializer.SerializeToXml(metaInformation);\n```\n\n#### Serialize Meta-Information DTO to XML file\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nvar metaInformation = new MetaInformation();\nvar filePath = @\"c:\\some\\file\\path\\meta-information.xml\";\nserializer.SerializeToXmlFile(metaInformation, filePath);\n```\n\n#### Serialize Meta-Information DTO to XML Stream\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nvar metaInformation = new MetaInformation();\nusing Stream stream = new MemoryStream();\nserializer.SerializeToXmlStream(metaInformation, stream);\n```\n\n#### Deserialize Meta-Information from XML string\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nvar xml = \"\u003cMetaInformation\u003e\u003c/MetaInformation\u003e\";\nMetaInformation metaInformation = serializer.DeserializeFromXml(xml);\n```\n\n#### Deserialize Meta-Information from XML file\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nvar filePath = @\"c:\\some\\file\\path\\meta-information.xml\";\nMetaInformation metaInformation = serializer.DeserializeFromXmlFile(filePath);\n```\n\n#### Deserialize Meta-Information from XML stream\n\n```CSharp\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\nstring xml = \"\u003cMetaInformation\u003e\u003c/MetaInformation\u003e\";\nusing Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(xml));\nMetaInformation metaInformation = serializer.DeserializeFromXmlStream(stream);\n```\n\n### Other\n\n#### Read [`FormatVersion`](https://gldf.io/docs/structure/header) from GLDF XML string or XML file. Or from GLDF container  \n\n```CSharp\nconst string xml = \"\u003cRoot\u003e\u003cHeader\u003e\u003cFormatVersion major='1' minor='2'/\u003e\u003c/Header\u003e\u003c/Root\u003e\";\nvar formatVersion = GldfFormatVersionReader.GetFromXml(xml);\n// or\nconst string filePath = @\"c:\\path\\product.xml\";\nvar formatVersion = GldfFormatVersionReader.GetFromXmlFile(filePath);\n// or\nconst string filePath = @\"c:\\path\\product.gldf\";\nvar formatVersion = GldfFormatVersionReader.GetFromGldfFile(filePath);\n// or\nusing var stream = File.OpenRead(@\"c:\\path\\product.gldf\");\nvar formatVersion = GldfFormatVersionReader.GetFromGldfStream(stream, leaveOpen: false);\n```\n\n#### Get all embedded XSD versions\n\n```CSharp\nforeach (var knownVersion in GldfEmbeddedXsdLoader.KnownVersions)\n    Console.WriteLine(\n        $\"{knownVersion.Major}.\" +\n        $\"{knownVersion.Minor}.\" +\n        $\"{(knownVersion.PreReleaseSpecified ? knownVersion.PreRelease : string.Empty)}\");\n```\n\n#### Load embedded GLDF XSD in specific version\n``````CSharp\n// On unknown versions, the latest embedded will be loaded\nvar formatVersion = new FormatVersion(1, 0, 2);\nstring xsd = GldfEmbeddedXsdLoader.Load(formatVersion);\n``````\n\n---\n\n### Interfaces\n\nIn summary, you can use the following interfaces\n\n```CSharp\n// 1) Serialize GLDF XML\nIGldfXmlSerializer serializer = new GldfXmlSerializer();\n// 2) Validate GLDF XML\nIGldfXmlValidator gldfXmlValidator = new GldfXmlValidator();\n\n// 3) Read GLDF container\nIGldfContainerReader containerReader = new GldfContainerReader();\n// 4) Write GLDF container\nIGldfContainerWriter containerWriter = new GldfContainerWriter();\n// 5) Validate GLDF Container\nIGldfValidator validator = new GldfValidator();\n\n// 6) Parse GLDF with resolved references\nIGldfParser parser = new GldfParser();\n\n// 7) Serialize Meta-Information XML\nIMetaInfoSerializer serializer = new MetaInfoSerializer();\n```\n\n---\n\n## Questions, Issues \u0026 Contribution\n\nPlease use the discussion section for questions or create issues, when something seems to be wrong. PRs are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgloballightingdata%2Fgldf.net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgloballightingdata%2Fgldf.net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgloballightingdata%2Fgldf.net/lists"}