Skip to content

Instantly share code, notes, and snippets.

@takeshik
Created February 13, 2011 09:16
Show Gist options
  • Save takeshik/824558 to your computer and use it in GitHub Desktop.
Save takeshik/824558 to your computer and use it in GitHub Desktop.
public IModule Add(String key, String typeName, IList<String> options, FileInfo configFile)
{
this.CheckIfDisposed();
Tuple<String, String> id = Tuple.Create(key, typeName);
return this.Modules.ContainsKey(id)
? this.Modules[id]
: Activator.CreateInstance(
this.AppDomain,
this.GetAssemblyByName(typeName).FullName,
typeName
).Unwrap()
.If(
o => o is Storage,
s => ((StorageModule) Activator.CreateInstance(
this.AppDomain,
typeof(StorageModule).Assembly.FullName,
typeof(StorageModule).FullName,
false,
BindingFlags.Default,
null,
Make.Array(s),
null,
null
).Unwrap()),
o => (IModule) o
)
.Apply(
m => m.Register(this, key, options),
this.Modules.Add,
m => this.Log.Info(Resources.ModuleAssemblyLoaded, this.Key, key, typeName),
m => m.Configure(configFile),
m => m.Initialize()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment