internal static FluidityContext EnsureContext(FluidityConfig config, FluidityDataContext data, FluidityServiceContext services, bool replaceContext = false) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (data == null) { throw new ArgumentNullException(nameof(data)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } // if there's already a singleton, and we're not replacing then there's no need to ensure anything if (Current != null) { if (replaceContext == false) { return(Current); } } var fluidityContext = new FluidityContext(config, data, services); // assign the singleton Current = fluidityContext; return(Current); }
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { // Build a configuration var config = new FluidityConfig(); var args = new FluidityStartingEventArgs { Config = config }; OnFluidityStarting(this, args); config = args.Config; config.PostProcess(); // Configure the fluidity context FluidityContext.EnsureContext(config, new FluidityDataContext( new FluidityRepositoryFactory() ), new FluidityServiceContext( new FluidityEntityService() ) ); // Create the sections / trees new UmbracoUiHelper().Build(FluidityContext.Current); //TODO: Cleanup any orphan sections / trees that may be left over from renames }