Assembly Scanning Default Convention - TylerBrinks/Snap GitHub Wiki

Assembly Scanning – Default Convention

Snap can be configured to scan assemblies with the default convention. The default convention attempts to pair interceptors and attributes to make configuration simple and brief.

Configuring Scanning

The default scanning convention is easy to set up.

SnapConfiguration.For<StructureMapAspectContainer>(c =>
        {
             c.IncludeNamespaceRoot("My.Test");
             c.Scan(s => s.ThisAssembly().WithDefaults());
        });

This configuration scans the current assembly (the one that’s running this code) with the default conventions. Each interceptor found with a matching attribute will be automatically bound.

e.g. MySampleInterceptor and MySampleAttribute would be paired together

Obviously the current assembly is not always the one needing to be scanned. In such cases, the following configuration syntax registers an external assembly for scanning with the default convention.

SnapConfiguration.For<StructureMapAspectContainer>(c =>
        {
             c.IncludeNamespaceRoot("My.Test");
             c.Scan(s => s.Assembly(someOtherAssembly).WithDefaults());
        });

Happy coding!

⚠️ **GitHub.com Fallback** ⚠️