dependency-injectionkephas

Is there a possibility to specify a service metadata attribute to be applied to all services in Kephas?


Currently there is the possibility to declare the metadata attribute collected for service implementations at service contract level. In my case, I have a pattern for a bunch of services and I need to use the same metadata attribute for all of them. Can I somehow declare the metadata attribute globally, so that the service contract definition looks cleaner?


Solution

  • Yes, you can. Just do the following:

    AppServiceContractAttribute.RegisterDefaultMetadataAttributeTypes(typeof(MyGreatMetadataAttribute));

    Check https://github.com/kephas-software/kephas/wiki/Application-Services#registering-global-service-metadata-attributes for more details on that matter. I'll copy two notes from the wiki: