Example #1
0
        public IDisposable StartTransaction()
        {
            var transaction = Transaction.Start(this.persistable, onCloseTransactionCallback: original => this.persistable = original);

            this.persistable = transaction;
            return(transaction);
        }
Example #2
0
        public static Transaction Start(IMergeConfigStore persistable, Action <IMergeConfigStore> onCloseTransactionCallback)
        {
            var transaction = new Transaction(persistable, onCloseTransactionCallback);

            transaction.Init();
            return(transaction);
        }
Example #3
0
        private Transaction(IMergeConfigStore persistable, Action <IMergeConfigStore> onCloseTransactionCallback)
        {
            if (persistable is Transaction)
            {
                throw new InvalidOperationException(
                          "Cannot start new transaction as a transaction is already active. Only one active transaction is allowed.");
            }

            this.persistable = persistable.CheckNotNull(nameof(persistable));
            this.onCloseTransactionCallback = onCloseTransactionCallback.CheckNotNull(nameof(onCloseTransactionCallback));
        }
Example #4
0
        internal static Config <T> CreateInternal <T>(Func <T> createDefault, IMergeConfigStore store)
            where T : class
        {
            createDefault.CheckNotNull(nameof(createDefault));
            store.CheckNotNull(nameof(store));

            var cfg = createDefault();

            store.EnsureExists(Toml.Create(cfg));

            return(new Config <T>(store));
        }
Example #5
0
 internal Config(IMergeConfigStore persistable)
 {
     this.persistable = persistable.CheckNotNull(nameof(persistable));
 }
Example #6
0
 internal Config(IMergeConfigStore persistable)
 {
     this.config = new Config(persistable);
 }
Example #7
0
 public TransactionUnitTests()
 {
     this.persistable = Substitute.For<IMergeConfigStore>();
 }