Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autofac with F#

How would I convert the existing C# code

_containerBuilder = new ContainerBuilder();
_containerBuilder.RegisterGeneric(typeof(CommandObserver<>)).As(typeof(ICommandObserver<>));
_containerBuilder.RegisterGeneric(typeof(PropertyProvider<>)).As(typeof(IPropertyProvider<>)); 

into F#?

like image 714
fitims Avatar asked Mar 27 '12 23:03

fitims


People also ask

What does Autofac mean?

Autofac is an addictive IoC container for . NET. It manages the dependencies between classes so that applications stay easy to change as they grow in size and complexity. This is achieved by treating regular .

Should I use Autofac in .NET core?

Autofac is the most widely used DI/IoC container for ASP.NET, and it is fully compatible with.NET Core as well. . NET Core has a built-in dependency injection framework that is ready to use. Even though the default DI may provide sufficient functionality, there are several limitations when using it.

How do I register an Autofac service?

Register by Type var builder = new ContainerBuilder(); builder. RegisterType<ConsoleLogger>(); builder. RegisterType(typeof(ConfigReader)); When using reflection-based components, Autofac automatically uses the constructor for your class with the most parameters that are able to be obtained from the container.


1 Answers

open Autofac
let _containerBuilder = new ContainerBuilder()

_containerBuilder.RegisterGeneric(typedefof<CommandObserver<_>>)
    .As(typedefof<ICommandObserver<_>>);

_containerBuilder.RegisterGeneric(typedefof<PropertyProvider<_>>)
    .As(typedefof<IPropertyProvider<_>>);
like image 104
Chris Fulstow Avatar answered Sep 28 '22 07:09

Chris Fulstow