예제 #1
0
 public ToFileAuditLogger(ToFileAuditLoggerConfig config, IMyDirectory myDirectory, IMyFile myFile, IMyDateTime myDateTime, IOldLogCleaner oldLogCleaner)
 {
     Contract.Requires <ArgumentNullException>(config != null, "options");
     Contract.Requires <ArgumentNullException>(myDirectory != null, "myDirectory");
     Contract.Requires <ArgumentNullException>(myFile != null, "myFile");
     Contract.Requires <ArgumentNullException>(myDateTime != null, "myDateTime");
     Contract.Requires <ArgumentNullException>(oldLogCleaner != null, "oldLogCleaner");
     Contract.Requires <EnvCryptException>(config.NumberOfDaysSinceCreationToKeep >= 1, "number of days to keep audit log files must be >= 1");
     Contract.Requires <EnvCryptException>(!string.IsNullOrWhiteSpace(config.FileNameFormat), "filename format cannot be empty");
     Contract.Requires <EnvCryptException>(!string.IsNullOrWhiteSpace(config.LogDirectory), "log directory cannot be empty");
     //
     _config        = config;
     _myDirectory   = myDirectory;
     _myFile        = myFile;
     _myDateTime    = myDateTime;
     _oldLogCleaner = oldLogCleaner;
 }
        public static IAuditLogger <TKey, TWorkflowOptions> GetToFileAuditLogger <TKey, TWorkflowOptions>(ToFileAuditLoggerConfig config)
            where TKey : KeyBase
            where TWorkflowOptions : DecryptPlainTextEntryWorkflowOptions
        {
            Contract.Requires <ArgumentNullException>(config != null, "config");
            //
            var myDir  = new MyDirectory();
            var myFile = new MyFile();

            return(new ToFileAuditLogger <TKey, TWorkflowOptions>(config, myDir, myFile, new MyDateTime(),
                                                                  new OldLogCleaner(new ToFileAuditLoggerConfig(), myDir, myFile, new MyFileInfoFactory())));
        }