b.logrythmik

{ independency injection }

TemplifyWith Extension Method

I created a super-simple extension-method for doing class-based token replacement on strings, using reflection. You can just pass a C# object to this function and it will replace tokens matching the object's property values in a straight-forward, easy way.

So, given this class:

class Car 
{
    public string Name { get; set; }
}
var car = new Car { Name = "Mazda" };
var message = "Hello [Name]!".TemplifyWith(car);

The resulting string (message) will be "Hello Mazda!"

Here's the code:

New Version of NLog.MongoDB Shipped

Long time, no blog.

I finally had some free time to do a little house-keeping on my NLog.MongoDB project.

Changes:

- Added the ability to use a connection string or an existing connection string name.

- Fixed the serialization issue with exceptions.

Feel free to check it out on GitHub here: https://github.com/Logrythmik/NLog.MongoDB

Also, the project is also now available on Nuget!

https://nuget.org/packages/NLog.MongoDB