autofac / Autofac.ServiceFabric

Autofac integration for Azure Service Fabric. Provides service factory implementations for Actors, Stateful Services and Stateless Services.
MIT License
26 stars 27 forks source link

Autowired Properties #20

Closed MonDeveloper closed 6 years ago

MonDeveloper commented 6 years ago

In another project where we use Autofac we massively used the "WithAutoWiredProperties" concept, we also customize the properties resolutor in order to drive the choice of the properties to AutoWire using a custom Attribute. Everything worked fine and we were happy. As far as I've understood, it is not possible to do the same with this Extension, I mean, it is not possible to add some "With" to the ServiceFabric services/actors registration. What can be the solution to add such a behavior?

alexmg commented 6 years ago

@MonDeveloper It looks like I could return the IRegistrationBuilder from the RegisterActor, RegisterStatelessService, and RegisterStatefulService methods. This would allow for additional configuration to be performed, but it would also make it possible for someone to break the registrations, such as if the lifetime was changed from InstancePerLifetimeScope.

I personally prefer constructor injection to property injection as it makes the required dependencies clear and incurs a lower runtime performance cost. Is there another example of registration configuration that you feel would be beneficial to be able to configure on the service registrations?

alexmg commented 6 years ago

The RegisterActor, RegisterStatefulService and RegisterStatelessService methods now return an IRegistrationBuilder allowing for further configuration of the registration. This will be included in the next release.

alexmg commented 6 years ago

I have pushed a 1.1.0 package to NuGet.