HolisticWare.NetBike.Xml
0.0.1-alpha-202409272252
Prefix Reserved
This is a prerelease version of HolisticWare.NetBike.Xml.
dotnet add package HolisticWare.NetBike.Xml --version 0.0.1-alpha-202409272252
NuGet\Install-Package HolisticWare.NetBike.Xml -Version 0.0.1-alpha-202409272252
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HolisticWare.NetBike.Xml" Version="0.0.1-alpha-202409272252" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HolisticWare.NetBike.Xml --version 0.0.1-alpha-202409272252
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HolisticWare.NetBike.Xml, 0.0.1-alpha-202409272252"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HolisticWare.NetBike.Xml as a Cake Addin #addin nuget:?package=HolisticWare.NetBike.Xml&version=0.0.1-alpha-202409272252&prerelease // Install HolisticWare.NetBike.Xml as a Cake Tool #tool nuget:?package=HolisticWare.NetBike.Xml&version=0.0.1-alpha-202409272252&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NetBike.Xml
Fast, flexible and high customizable XML serializer for converting between .NET objects and XML.
- Flexible model of contracts via IXmlContractResolver
- Custom formatting and construction of objects via IXmlConverter
- Built-in support for the Nullable<>, List<>, Dictionary<> and more
- Supports for base and derived types via IXmlTypeResolver
- Compatibility with XML attributes of System.Xml.XmlSerializer
- .NET Standard 2.0
Install
Install via NuGet package:
PM> Install-Package NetBike.Xml
Install media type formatter for Web API via NuGet package:
PM> Install-Package NetBike.Xml.Formatting
Documentation
A long time ago in a galaxy far, far away..
Examples
A simple object serialization:
var serializer = new XmlSerializer();
serializer.Settings.Namespaces.Clear();
serializer.Settings.OmitXmlDeclaration = true;
/*
Output XML:
<Foo><Id>1</Id><Name>test</Name></Foo>
*/
serializer.Serialize(Console.Out, new Foo
{
Id = 1,
Name = "test"
});
A simple object deserialization:
var serializer = new XmlSerializer();
var xml = "<Foo><Id>1</Id><Name>test</Name></Foo>";
var foo = serializer.Deserialize<Foo>(new StringReader(xml));
An advanced object serialization:
public class Bar
{
[XmlAttribute]
public int Id { get; set; }
public string Name { get; set; }
public Dictionary<int, string> Numbers { get; set; }
}
public static void Example()
{
var keyValuePairContract = new XmlObjectContractBuilder<KeyValuePair<int, string>>()
.SetProperty(x => x.Key, "id", XmlMappingType.Attribute)
.SetProperty(x => x.Value, "value", XmlMappingType.InnerText)
.Build();
var contractResolver = new XmlCustomContractResolver(
new XmlContract[] { keyValuePairContract },
fallbackResolver: new XmlContractResolver(NamingConventions.CamelCase))
var settings = new XmlSerializationSettings
{
Indent = true,
OmitXmlDeclaration = true,
NullValueHandling = XmlNullValueHandling.Include,
ContractResolver = contractResolver
};
var serializer = new XmlSerializer(settings);
var bar = new Bar
{
Id = 1,
Name = null,
Numbers = new Dictionary<int, string>
{
{ 1, "one" },
{ 2, "two" }
}
};
/*
Output XML:
<bar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="1">
<name xsi:nil="true" />
<numbers>
<item id="1">one</item>
<item id="2">two</item>
</numbers>
</bar>
*/
serializer.Serialize(Console.Out, bar);
}
License
Copyright (c) 2015 NetBike
The MIT License
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- System.Reflection.Emit (>= 4.7.0)
- System.Reflection.Emit.Lightweight (>= 4.7.0)
- ZString (>= 2.6.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.1-alpha-202409272252 | 69 | 9/27/2024 |
0.0.1-alpha-202409260927 | 62 | 9/26/2024 |