Using Autofac Aggregate Services

Tuesday, September 13, 2016

I really like using Autofac, it’s one of the most productive libraries I know, and it’s so much fun to discover new features. Aggregate Services is Autofac feature that allows you to wrap a set of dependencies into a single aggregate without the need to implement a concrete type for it. Consider the following case where you have a base class that has dependencies on a few other services, and two derived classes: class BaseLicenseGenerator:ILicenseGenerator { //members public BaseLicenseGenerator(ILogger logger, IUserRepository userRepository, ILicenseRepository licenseRepository) { ...
no comments

Automatically inject log4net named logger using Ninject

Wednesday, February 25, 2015

When working with log4net you usually want that each class will have a named logger with the class full name (Namespace+Name). the Log4Net examples shows this pattern:public class MyClass { // Define a static logger variable so that it references the // Logger instance named "MyClass". private static readonly ILog log = LogManager.GetLogger(typeof(MyClass)); //Rest of the Class }   this will create a logger instance with the class name and now in my log4net configuration I can write something like this:   <log4net> <!-- A1 is set to be a ConsoleAppender...
tags: , , , ,
3 comments