UnityRegistry.Scan vs. UnityContainer.RegisterTypes

I have an application that uses Unity. In one area of the application, the code scans the assembly to register the types (auto-registration) using this code:

public class CommonRegistry : UnityRegistry
    public CommonRegistry()
        const StringComparison strCmp = StringComparison.InvariantCultureIgnoreCase;

        Register<ITenantStore, TenantStore>();

        Scan(scanner =>
            scanner.AssembliesInBaseDirectory(asm => asm.GetName().Name.StartsWith(@"Infrastructure", strCmp));

The above code uses the UnityRegistry class of the UnityConfiguration assembly.

But in the Unity documentation, the example shows this code:

unityContainer.RegisterTypes(AllClasses.FromLoadedAssemblies(), ...

What is the difference between the two?


I think its same with here. register dependency Unity the difference is the UnityRegistry is for lower versions. while the other one is for 3.5 up. but both are to register dependencies.

Need Your Help

Google Api Exception Unhandled by User Code: Request Error

google-api google-calendar-api google-oauth google-api-dotnet-client

A local VS2015 ASP.NET 4.5 application throws this exception when I attempt to request events from my Google Calendar:

Do you know any run-time differences between Compact and Full Framework code?

.net compact-framework

There are a number of run-time differences in compatible code between these two versions of .NET.