Skip to content

souzara/Fluent.Xml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

version 1.2.3

Nuget Packages

Install-Package Fluent.Xml

Introduction

Library to make easy manipulation of xml files.

Getting Started - Usage

using Fluent.Xml;

namespace FluentXmlSample
{
    class Program
    {
        private static string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                   @"<FluentXml>
                                      <Author>Ricardo Alves</Author>
                                      <PackageName>FluentXml</PackageName>
                                      <Description>This library is awesome = D </Description>
                                    </FluentXml>";
        static Program()
        {
            FluentXml.RegisterMap<FluentXmlMappingConfiguration>();
        }
        static void Main(string[] args)
        {
            //Deserialize
            var obj = FluentXml.Deserialize<FluentXmlModel>(xml);

            //Serialize
          
            var fluentXml = FluentXml.Serialize(obj);
        }
    }


    public class FluentXmlModel
    {
        public string Author { get; set; }
        public string PackageName { get; set; }
        public string Description { get; set; }
    }


    public class FluentXmlMappingConfiguration : Fluent.Xml.XmlMappingConfiguration<FluentXmlModel>
    {
        public FluentXmlMappingConfiguration() : base("FluentXml")
        {
            //WithName configuration
            HasElement(x => x.Author).WithName("Author");
            //Without WithName, the property name will be used with element name
            HasElement(x => x.PackageName);
            HasElement(x => x.Description).WithName("Description");
        }
    }
}

Contribute

This version was developed for a simple serialization and deserialization project, contributions and suggestions are welcome.

About

A LIbrary to make easy work with xml.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages