2 FromAssembly
Simon Gockner edited this page 7 years ago

The FromAssembly class is a static helper class that supplies methods to find the wanted Assembly for an IAssemblyInstaller.
It acts similar to a factory in the way that its methods return a new instance of an IAssemblyInstaller with the assembly that they provide.

There are two different methods that create IAssemblyInstallers:

This()

The This() method creates an IAssemblyInstaller that installs from the Assembly that calls the method.
This is done by using the Assembly.GetCallingAssembly() method:

public static IAssemblyInstaller This()
{
    Assembly assembly = Assembly.GetCallingAssembly();
    return new AssemblyInstaller(assembly);
}

Instance()

The Instance() method creates an IAssemblyInstaller that installs from the Assembly instance that is given to the method.
This is done by straightforwardly creating an IAssemblyInstaller:

public static IAssemblyInstaller Instance(Assembly assembly)
{
    return new AssemblyInstaller(assembly);
}