Skip to content

Instantly share code, notes, and snippets.

@lars-erik
Created October 14, 2013 16:22
Show Gist options
  • Save lars-erik/6978254 to your computer and use it in GitHub Desktop.
Save lars-erik/6978254 to your computer and use it in GitHub Desktop.
Gist description…
protected static ServiceContext CreateServiceContext(string basePath, string connectionString, string providerName)
{
var serviceContextManagerType = OptimisticType.GetType("Umbraco.Core.Standalone.ServiceContextManager, Umbraco.Core");
if (serviceContextManagerType == null)
throw new Exception("Couldn't get Umbraco.Core.Standalone.ServiceContextManager type");
var serviceContextManager = Activator.CreateInstance(serviceContextManagerType,
connectionString,
providerName,
basePath
);
var serviceContext = (ServiceContext) serviceContextManagerType.GetProperty("Services").GetValue(serviceContextManager);
return serviceContext;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment