Skip to content

Instantly share code, notes, and snippets.

@ronnieoverby
Created May 7, 2012 02:08
Show Gist options
  • Save ronnieoverby/2625450 to your computer and use it in GitHub Desktop.
Save ronnieoverby/2625450 to your computer and use it in GitHub Desktop.
public class CMSConfiguration
{
private readonly Assembly[] _contentAssemblies;
private readonly IDocumentStore _documentStore;
public CMSConfiguration(IDocumentStore documentStore, Assembly[] contentAssemblies = null)
{
if (documentStore == null) throw new ArgumentNullException("documentStore");
_documentStore = documentStore;
_contentAssemblies = contentAssemblies ?? GetDefaultContentAssemblies();
}
public Assembly[] ContentAssemblies
{
get { return _contentAssemblies; }
}
public IDocumentStore DocumentStore
{
get { return _documentStore; }
}
public static CMSConfiguration Instance { get; private set; }
private Assembly[] GetDefaultContentAssemblies()
{
// by default just use the assembly that's calling the ctor
// it's probably the consuming mvc application
Type type = new StackTrace(2).GetFrame(0).GetMethod().DeclaringType;
return type != null ? new[] {type.Assembly} : null;
}
public void Set()
{
Instance = this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment