void RefreshArchiveLocation() { var templateService = new TemplateProcessingService(); var archivePath = templateService.ProcessTemplate(LocationPattern); ArchiveLocation = new DirectoryInfo(archivePath); if (!ArchiveLocation.Exists) ArchiveLocation.Create(); }
public void ProcessTemplate_ProcessesTextSubstitutions() { var pattern = "{P1} {P2}"; var s = new TemplateProcessingService(); s.InternalContext.Substitutions.AddOrUpdateSubstitution("P1", "TS1"); s.InternalContext.Substitutions.AddOrUpdateSubstitution("P2", "TS2"); var result = s.ProcessTemplate(pattern); Assert.AreEqual("TS1 TS2", result); }
public void ProcessTemplate_ProcessesFunctions() { var pattern = "{P1:invoke()}"; var s = new TemplateProcessingService(); s.InternalContext.Substitutions.AddOrUpdateSubstitution("P1", (cx) => "TS1"); s.InternalContext.Functions.AddFunction( new Function( "invoke", new Function.FunctionDelegate( (originalValue, input, parameters) => { return input + ":)"; }))); var result = s.ProcessTemplate(pattern); Assert.AreEqual("TS1:)", result); }
public void ProcessTemplate_ProcessesConditionalEvaluatedSubstitutions() { var pattern = "{?P1=>P2}"; var s = new TemplateProcessingService(); s.InternalContext.Substitutions.AddOrUpdateSubstitution("P1", (cx) => true); s.InternalContext.Substitutions.AddOrUpdateSubstitution("P2", (cx) => "TS2"); var result = s.ProcessTemplate(pattern); Assert.AreEqual("TS2", result); }
public void ProcessTemplate_FunctionNameNotMatched_InterpretsNameAsFormattingString() { var pattern = "{DateTime.Now:yyyy-MM-dd}"; var s = new TemplateProcessingService(); var now = new DateTime(1999, 01, 02, 03, 04, 05); s.InternalContext.Substitutions.AddOrUpdateSubstitution("DateTime.Now", (cx) => now); var result = s.ProcessTemplate(pattern); Assert.AreEqual("1999-01-02", result); }
public override void Initialize() { if (Archive != null) Archive.Attach(this); var templateService = new TemplateProcessingService(); var fileDirectoryPath = templateService.ProcessTemplate(FileLocationPattern); var fileName = templateService.ProcessTemplate(FileNamePattern); LogFile = new FileInfo(Path.Combine(fileDirectoryPath, fileName)); Directory.CreateDirectory(fileDirectoryPath); if(FileLockingStrategy == null) { Diagnostics.Log.Warning(() => "File Locking Strategy not specified, Single Process Locking will be used for " + SinkLocation.ToString()); FileLockingStrategy = SingleProcessLockingStrategy.Instance; } if (BeforeInitialized != null) BeforeInitialized(this, EventArgs.Empty); }