我将如何转换现有的C#代码

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

进入F#?

最佳答案

open Autofac
let _containerBuilder = new ContainerBuilder()

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

_containerBuilder.RegisterGeneric(typedefof<PropertyProvider<_>>)
    .As(typedefof<IPropertyProvider<_>>);

关于c# - 带有F#的Autofac,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9899364/

10-10 10:24