GreanTech / AtomEventStore

A server-less .NET Event Store based on the Atom syndication format
MIT License
117 stars 14 forks source link

Scan an assembly in order to create a XmlContentSerializer #101

Closed ploeh closed 10 years ago

ploeh commented 10 years ago

Now that XmlContentSerializer has a CreateTypeResolver method, it's possible to create an instance like this:

var serializer = new XmlContentSerializer(
    XmlContentSerializer.CreateTypeResolver(
        typeof(UserCreated).Assembly));

This is better than having to manually create an instance of TypeResolutionTable, but now that the building blocks are in place, it'd be nice with an even easier short-cut:

XmlContentSerializer serializer =
    XmlContentSerializer.Scan(typeof(UserCreated).Assembly);

In the above example, this method is called Scan, but other alternatives are possible:

moodmosaic commented 10 years ago

Hm... Scan is easy to understand, if you already know about this:

var serializer = new XmlContentSerializer(
    XmlContentSerializer.CreateTypeResolver(
        typeof(UserCreated).Assembly));

Create makes it easier to understand what the return type is.

ploeh commented 10 years ago

Yes, but Scan provides a hint about what's actually going on.

My concern about Create is that, based on an Assembly as input, it sounds a bit magical.

moodmosaic commented 10 years ago

Agreed. And it's probably more important to know what's actually going on (vs what's returned).