/// <summary> /// Constructs a new persistence manager object using a custom serializer /// </summary> /// <param name="configName">A filename-friendly string that will be used as the basis of the configuration filename (usually a plugin name or other simple string with no special characters)</param> /// <param name="serializer">The object that will handle serialization of the config object to and from a string</param> /// <param name="createConfigObject">A delegate that allows control over how the persistence object is constructed and initialized</param> /// <param name="settingsPath">The directory that will contain the saved file</param> public PersistenceManager(string configName, Func <T> createConfigObject, IPersistenceSerializer <T> serializer, string settingsPath = null) { _createConfigObject = createConfigObject; _serializer = serializer; _settingsPath = settingsPath ?? ConfigurationManager.AppSettings["DataDirectory"]; bool isNew; _mutex = new Mutex(false, "Global.ServerX.PersistenceManager", out isNew, _mutexsecurity); _mutexCfgFile = new Mutex(false, "Global.ServerX.PersistenceManager." + configName, out isNew, _mutexsecurity); _mutex.WaitOne(); try { var dir = new DirectoryInfo(_settingsPath ?? string.Format("{0}\\Config", ConfigurationManager.AppSettings["DataDirectory"] ?? Environment.CurrentDirectory)); if (!dir.Exists) { dir.Create(); } _cfgFilePath = Path.Combine(dir.FullName, configName + ".cfg"); _fileInfo = new FileInfo(_cfgFilePath); } finally { _mutex.ReleaseMutex(); } Reload(); }
public CosmosOutboxRepository(IDbContext dbContext, IPersistenceSerializer serializer, CosmosOutboxRepositoryOptions options) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
public MongoSagaStateRepository(IDbContext dbContext, IPersistenceSerializer serializer, MongoSagaStateRepositoryOptions options) { _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); _options = options ?? throw new ArgumentNullException(nameof(options)); }
/// <summary> /// Constructs a new persistence manager object using a custom serializer /// </summary> /// <param name="configName">A filename-friendly string that will be used as the basis of the configuration filename (usually a plugin name or other simple string with no special characters)</param> /// <param name="serializer">The object that will handle serialization of the config object to and from a string</param> /// <param name="settingsPath">The directory that will contain the saved file</param> public PersistenceManager(string configName, IPersistenceSerializer <T> serializer, string settingsPath = null) : this(configName, Activator.CreateInstance <T>, serializer, settingsPath : settingsPath) { }