RockFramework/Rock.Core — pull request #17 by bfriesen (2014-10-17 15:46:23+00:00)
Title: Version 0.0.2

Included in this version:
- Add `XmlSerializerSectionHandler` class
- Includes inheritors:
- `XmlSerializerSectionHandler`
- `XSerializerSectionHandler`
- `XSerializerSectionHandler`
- Allow easy creation of configuration-related objects via *.config files.
- Deserializes the xml from the *.config file as a plain old CLR object (poco).
- Fix the configuration object for `XSerializerSerializer`
- Need to be able to specify the root element name for any arbitrary type.
- Exposed as `IReadOnlyDictionary`.

##### XmlSerializerSectionHandler

*packages: Rock.Core, Rock.Core.XSerializer*

Given this set of config types:

```c#
public class FooConfig
{
public int Bar { get; set; }
public BazConfig Baz { get; set; }
}

public class BazConfig
{
[XmlAttribute]
public Qux Qux { get; set; }

[XmlText]
public string Corge { get; set; }
}

public enum Qux
{
First, Second, Third
}
```

Create a *.config file that looks like this:

```xml

234
abc

```

There are other ways of using a *.config file to use this serialization mechanism. The [app.config](https://github.com/bfriesen/Rock.Core/blob/41c39f89576d8d5678cfa955cadd74313e66e194/Rock.Core.IntegrationTests/App.config) used to test the various inheritors of `XmlSerializerSectionHandler` shows these different mechanisms. Also check out the [test and config classes](https://github.com/bfriesen/Rock.Core/blob/41c39f89576d8d5678cfa955cadd74313e66e194/Rock.Core.IntegrationTests/Configuration/XmlSerializerSectionHandlerTests.cs) for more details.

From application code, obtain the configured instance of `FooConfig` like this:

```c#
FooConfig config = (FooConfig)ConfigurationManager.GetSection("MyConfig");

Console.WriteLine(config.Bar); // Writes "234"
Console.WriteLine(config.Baz.Qux); // Writes "Second"
Console.WriteLine(config.Baz.Corge); // Writes "abc"
```

##### XSerializerSerializerConfiguration

*packages: Rock.Core.XSerializer*

`XSerializerSerializerConfiguration.RootElementNameMap` can be initialized like this:

```c#
var config = new XSerializerSerializerConfiguration
{
RootElementNameMap = new Dictionary
{
// An xml element named "Thing1" will be deserialized as a FooConfig and an
// object of type FooConfig will be serialized with a root element of "Thing1".
{ typeof (FooConfig), "Thing1" },

// An xml element named "Thing2" will be deserialized as a BarConfig and an
// object of type BarConfig will be serialized with a root element of "Thing2".
{ typeof (BarConfig), "Thing2" }
}
};
```