コード例 #1
0
 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;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
ファイル: SettingsPersistor.cs プロジェクト: yvkashyap/PK-Sim
        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);
        }
コード例 #7
0
 public TemplateCreator(IEngineEnvironmentSettings environmentSettings)
 {
     _environmentSettings = environmentSettings;
     _paths = new SettingsFilePaths(environmentSettings);
 }