List<string> nameSpaceSuffixes = GetSuffixes();
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
foreach(var suffix in nameSpaceSuffixes)
{
if (assembly.GetName().Name.EndsWith(suffix))
Register(container, assembly, suffix);
}
}
List<string> nameSpaceSuffixes = GetSuffixes(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach(var suffix in nameSpaceSuffixes)
Share
As a query expression:
I haven’t gone down Ani’s route of using
List<T>.ForEach– I personally prefer to use a normalforeachstatement. LINQ is great for the declarative querying;foreachis godo for the imperative action taken on each element.Note that my query expression is almost equivalent to Ani’s dot notation; the C# compiler would use a slightly different overload of
SelectMany, that’s all. In this particular case I think the query expression is easier to understand; in simpler cases I prefer dot notation.