Including Namespaces - TylerBrinks/Snap GitHub Wiki
There are two ways namespaces can be configured with Snap.
- Adding a root namespace
- Adding an explicit namespace
Adding a namespace root allows you to include all namespaces that start with a given string. Including “My.Test” would, by convention, inclusively look up a type with the namespace “My.Test.Namespace.With.SomeType”
SnapConfiguration.For<StructureMapAspectContainer>(c =>
{
// Finds everything under My.Test
c.IncludeNamespaceRoot("My.Test");
});
Adding an explicit namespace allows you to specify exactly which type to target. Including an explicit namespace “My.Test.Namespace.With.SomeType” only finds instances of SomeType. All other types will be excluded.
SnapConfiguration.For<StructureMapAspectContainer>(c =>
{
// Finds only under SomeType
c.IncludeNamespace("My.Test.Namespace.With.SomeType");
});
Explicit namespaces do allow for a wildcard “*” suffix. Adding a wildcard forces the namespace to behave like a root namespace, and includes all types in all sub-namespaces.
SnapConfiguration.For<StructureMapAspectContainer>(c =>
{
// Finds everything under My.Test
c.IncludeNamespace("My.Test*");
});
Happy coding!