Example #1
0
 /// <summary>
 /// Register all services
 /// </summary>
 /// <param name="registrar">Registrar used for the registration</param>
 public void Register(IContainerRegistrar registrar)
 {
     registrar.RegisterService(x => _store.OpenSession(), Lifetime.Scoped);
     registrar.RegisterConcrete<UowAdapter>(Lifetime.Scoped);
     //registrar.RegisterService(x => new UowAdapter(x.Resolve<IDocumentSession>(), _observer), Lifetime.Scoped);
     registrar.RegisterInstance(typeof (IUnitOfWorkObserver), _observerAdapter);
     registrar.RegisterInstance(typeof (IUnitOfWorkAdapter), this);
 }
        /// <summary>
        /// Scan specified assembly after WebApi controllers.
        /// </summary>
        /// <param name="registrar">Container registrar to register the controllers in.</param>
        /// <param name="assembly">Assembly to scan</param>
        /// <example>
        /// <code>
        /// registrar.RegisterApiControllers(typeof(WebApiApplication).Assembly);
        /// </code>
        /// </example>
        public static void RegisterApiControllers(this IContainerRegistrar registrar, Assembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            var controllers =
                assembly.GetTypes().Where(
                    x => typeof(ApiController).IsAssignableFrom(x));

            foreach (var controller in controllers)
            {
                // no public constructors. A base class?
                if (controller.GetConstructors().Length == 0 || controller.IsAbstract)
                {
                    continue;
                }

                registrar.RegisterConcrete(controller, Lifetime.Transient);
            }
        }
Example #3
0
 public void Register(IContainerRegistrar registrar)
 {
     registrar.RegisterConcrete <MySelf>(Lifetime.Transient);
 }
 /// <summary>
 /// Register the class in the container
 /// </summary>
 /// <param name="concrete">Class which has been decorated with the attribute.</param>
 /// <param name="registrar">The container registrar.</param>
 public void Register(Type concrete, IContainerRegistrar registrar)
 {
     registrar.RegisterConcrete(concrete, Lifetime.Default);
 }
 public void Register(IContainerRegistrar registrar)
 {
     registrar.RegisterConcrete<MySelf>(Lifetime.Transient);
 }
 /// <summary>
 /// Register the class in the container
 /// </summary>
 /// <param name="concrete">Class which has been decorated with the attribute.</param>
 /// <param name="registrar">The container registrar.</param>
 public void Register(Type concrete, IContainerRegistrar registrar)
 {
     registrar.RegisterConcrete(concrete, Lifetime.Default);
 }