Check this page out: https://alexmg.com/introducing-the-autofac-integration-for-service-fabric/
Right from the maker of Autofac. You'll need to import the Autofac.ServiceFabric NuGet package, which is currently in beta.
Note: As of the current version (1.0.0-beta1) the InternalsVisibleTo functionality mentioned in the article doesn't work, so you ** HAVE TO ** set your registered Actors and Reliable Services to "public" visibility.
Note 2: The dependencies on the Autofac.ServiceFabric NuGet package aren't set correctly, so you'll have to "Update-Package Autofac -Version 4.6.0" since 4.5.0 isn't good enough.
Showing posts with label dependency. Show all posts
Showing posts with label dependency. Show all posts
Thursday, July 27, 2017
Adding Dependency Injection support for Service Fabric Stateless API applications
Turns out that it's pretty easy (for Stateless Services anyway).
In your Package Manager Console:
Install-Package Autofac.WebApi2 -Version 4.0.1
In your Startup.cs file (assuming you're using the Visual Studio Project templates):
Startup.cs:
public static void ConfigureApp(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterModule<MyApiModule>();
config.DependencyResolver = new AutofacWebApiDependencyResolver(containerBuilder.Build());
appBuilder.UseWebApi(config);
}
In your Package Manager Console:
Install-Package Autofac.WebApi2 -Version 4.0.1
In your Startup.cs file (assuming you're using the Visual Studio Project templates):
Startup.cs:
public static void ConfigureApp(IAppBuilder appBuilder)
{
// Configure Web API for self-host.
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
var containerBuilder = new ContainerBuilder();
containerBuilder.RegisterModule<MyApiModule>();
config.DependencyResolver = new AutofacWebApiDependencyResolver(containerBuilder.Build());
appBuilder.UseWebApi(config);
}
And, assuming you've built an Autofac Module, it should look something vaguely like this:
public class PlayDatesApiModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
base.Load(builder);
builder.RegisterType<MyDependencyConcreteType>().As<IMyDependency>();
builder.RegisterType<ValuesController>();
}
}
Thursday, April 03, 2014
Waiting for the network to be up on the BeagleBone Black
It finally hit me today as I was reading over this article, and it should have hit me sooner. The article mentions that in order to get past the network startup hurdles in systemd, you need to wait on the NetworkManager service. However, I use connman. It didn't occur to me until today that they provide exactly the same functionality, and I just needed to swap one with the other. Now, I have all my network dependent programs simply After=connman.service in the systemd service descriptor files, and they're golden.
Subscribe to:
Posts (Atom)