Skip to content

autofac/Autofac.Extras.DomainServices

Repository files navigation

Autofac.Extras.DomainServices

Autofac Domain Service factory for WCF RIA Services.

Build status

⚠️ MAINTENANCE MODE: This package is in maintenance-only mode. Bug fixes may be addressed and Autofac compatibility may be checked but no new features will be added.

Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.

Quick Start

To get Autofac integrated with RIA/domain services app you need to reference the Domain Services integration NuGet package, register services, and register the integration module.

public class Global : HttpApplication, IContainerProviderAccessor
{
  // The IContainerProviderAccessor and IContainerProvider
  // interfaces are part of the web integration and are used
  // for registering/resolving dependencies on a per-request
  // basis.
  private static IContainerProvider _containerProvider;

  public IContainerProvider ContainerProvider
  {
    get { return _containerProvider; }
  }

  protected void Application_Start(object sender, EventArgs e)
  {
    var builder = new ContainerBuilder();

    // Register your domain services.
    builder
      .RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
      .AssignableTo<DomainService>();

    // Add the RIA Services module so the "Initialize"
    // method gets called on your resolved services.
    builder.RegisterModule<AutofacDomainServiceModule>();

    // Build the container and set the container provider
    // as in standard web integration.
    var container = builder.Build();
    _containerProvider = new ContainerProvider(container);

    // Replace the DomainService.Factory with
    // AutofacDomainServiceFactory so things get resolved.
    var factory = new AutofacDomainServiceFactory(_containerProvider);
    DomainService.Factory = factory;
  }
}

When you write your domain services, use constructor injection and other standard patterns just like any other Autofac/IoC usage.

Example

The Autofac examples repository (at tag v3.5.2) has a Domain Services project that is consumed by a Silverlight application.

About

Autofac Domain Service Factory for RIA Services

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages