Created
May 7, 2012 02:08
-
-
Save ronnieoverby/2625450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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