public FileSystemDirectory(IMountPoint mountPoint, string fullPath, string name, string physicalPath) : base(mountPoint, EnsureTrailingSlash(fullPath), name) { _physicalPath = physicalPath; _paths = new SettingsFilePaths(mountPoint.EnvironmentSettings); _fileSystem = mountPoint.EnvironmentSettings.Host.FileSystem; }
public void CanHandlePostActions() { IEngineEnvironmentSettings environmentSettings = _environmentSettingsHelper.CreateEnvironment(virtualize: true); SettingsFilePaths paths = new SettingsFilePaths(environmentSettings); Guid postAction1 = Guid.NewGuid(); Guid postAction2 = Guid.NewGuid(); ITemplate template = A.Fake <ITemplate>(); A.CallTo(() => template.Identity).Returns("testIdentity"); A.CallTo(() => template.Name).Returns("testName"); A.CallTo(() => template.ShortNameList).Returns(new[] { "testShort" }); A.CallTo(() => template.MountPointUri).Returns("testMount"); A.CallTo(() => template.ConfigPlace).Returns(".template.config/template.json"); A.CallTo(() => template.PostActions).Returns(new[] { postAction1, postAction2 }); IMountPoint mountPoint = A.Fake <IMountPoint>(); A.CallTo(() => mountPoint.MountPointUri).Returns("testMount"); ScanResult result = new ScanResult(mountPoint, new[] { template }, Array.Empty <ILocalizationLocator>(), Array.Empty <(string AssemblyPath, Type InterfaceType, IIdentifiedComponent Instance)>()); TemplateCache templateCache = new TemplateCache(new[] { result }, new Dictionary <string, DateTime>(), NullLogger.Instance); WriteObject(environmentSettings.Host.FileSystem, paths.TemplateCacheFile, templateCache); var readCache = new TemplateCache(ReadObject(environmentSettings.Host.FileSystem, paths.TemplateCacheFile), NullLogger.Instance); Assert.Single(readCache.TemplateInfo); var readTemplate = readCache.TemplateInfo[0]; Assert.Equal(new[] { postAction1, postAction2 }, readTemplate.PostActions); }
internal FileSystemMountPoint(IEngineEnvironmentSettings environmentSettings, IMountPoint?parent, string mountPointUri, string mountPointRootPath) { MountPointUri = mountPointUri; MountPointRootPath = mountPointRootPath; EnvironmentSettings = environmentSettings; _paths = new SettingsFilePaths(environmentSettings); Root = new FileSystemDirectory(this, "/", "", MountPointRootPath); }
public GlobalSettings(IEngineEnvironmentSettings environmentSettings, string globalSettingsFile) { _environmentSettings = environmentSettings ?? throw new ArgumentNullException(nameof(environmentSettings)); _globalSettingsFile = globalSettingsFile ?? throw new ArgumentNullException(nameof(globalSettingsFile)); _paths = new SettingsFilePaths(environmentSettings); environmentSettings.Host.FileSystem.CreateDirectory(Path.GetDirectoryName(_globalSettingsFile)); _watcher = environmentSettings.Host.FileSystem.WatchFileChanges(_globalSettingsFile, FileChanged); }
public GlobalSettings(IEngineEnvironmentSettings environmentSettings, string globalSettingsFile) { _environmentSettings = environmentSettings ?? throw new ArgumentNullException(nameof(environmentSettings)); _globalSettingsFile = globalSettingsFile ?? throw new ArgumentNullException(nameof(globalSettingsFile)); _paths = new SettingsFilePaths(environmentSettings); environmentSettings.Host.FileSystem.CreateDirectory(Path.GetDirectoryName(_globalSettingsFile)); if (environmentSettings.Environment.GetEnvironmentVariable("TEMPLATE_ENGINE_DISABLE_FILEWATCHER") != "1") { _watcher = environmentSettings.Host.FileSystem.WatchFileChanges(_globalSettingsFile, FileChanged); } }
public virtual TSettings Load() { try { foreach (var filePath in SettingsFilePaths.Where(FileHelper.FileExists)) { var xmlContent = XmlHelper.XmlContentFromFile(filePath); return(_stringSerializer.Deserialize <TSettings>(xmlContent)); } } //We do not want to have a crash if the user has edited the configuration by hand catch (Exception) { return(_defaultSettings); } return(_defaultSettings); }
public TemplateCreator(IEngineEnvironmentSettings environmentSettings) { _environmentSettings = environmentSettings; _paths = new SettingsFilePaths(environmentSettings); }