Exemplo n.º 1
0
 public LiveModelsProvider(ILogger logger, IModelsBuilderConfig config, ModelsGenerator modelGenerator, ModelsGenerationError mbErrors)
 {
     _logger         = logger;
     _config         = config ?? throw new ArgumentNullException(nameof(config));
     _modelGenerator = modelGenerator;
     _mbErrors       = mbErrors;
 }
Exemplo n.º 2
0
        public PureLiveModelFactory(Lazy <UmbracoServices> umbracoServices, IProfilingLogger logger, IModelsBuilderConfig config)
        {
            _umbracoServices = umbracoServices;
            _logger          = logger;
            _config          = config;
            _errors          = new ModelsGenerationError(config);
            _ver             = 1;  // zero is for when we had no version
            _skipver         = -1; // nothing to skip

            RazorBuildProvider.CodeGenerationStarted += RazorBuildProvider_CodeGenerationStarted;

            if (!HostingEnvironment.IsHosted)
            {
                return;
            }

            var modelsDirectory = _config.ModelsDirectory;

            if (!Directory.Exists(modelsDirectory))
            {
                Directory.CreateDirectory(modelsDirectory);
            }

            // BEWARE! if the watcher is not properly released then for some reason the
            // BuildManager will start confusing types - using a 'registered object' here
            // though we should probably plug into Umbraco's MainDom - which is internal
            HostingEnvironment.RegisterObject(this);
            _watcher                     = new FileSystemWatcher(modelsDirectory);
            _watcher.Changed            += WatcherOnChanged;
            _watcher.EnableRaisingEvents = true;

            // get it here, this need to be fast
            _debugLevel = _config.DebugLevel;
        }