public void Clear_ShouldDisposeAllDisposables()
        {
            var firstOverrideDisposable  = new SomeDisposable();
            var secondOverrideDisposable = new SomeDisposable();
            var firstDefaultDisposable   = new SomeDisposable();
            var secondDefaultDisposable  = new SomeDisposable();

            var all = new[]
            {
                firstDefaultDisposable,
                secondDefaultDisposable,
                firstOverrideDisposable,
                secondOverrideDisposable
            };

            var settings = new SettingsHolder();

            settings.Set("1.Override", firstOverrideDisposable);
            settings.Set("2.Override", secondOverrideDisposable);
            settings.SetDefault("1.Default", firstDefaultDisposable);
            settings.SetDefault("2.Default", secondDefaultDisposable);

            settings.Clear();

            Assert.IsTrue(all.All(x => x.Disposed));
        }
            /// <summary>
            /// Sets the default timeout period for the transaction.
            /// </summary>
            /// <param name="defaultTimeout">A <see cref="T:System.TimeSpan" /> value that specifies the default timeout period for the transaction.</param>
            public TransactionAdvancedSettings DefaultTimeout(TimeSpan defaultTimeout)
            {
                if (defaultTimeout > maxTimeout)
                {
                    throw new ConfigurationErrorsException(
                              "Timeout requested is longer than the maximum value for this machine. Please override using the maxTimeout setting of the system.transactions section in machine.config");
                }

                SettingsHolder.Set("Transactions.DefaultTimeout", defaultTimeout);
                return(this);
            }
        public void Merge_ShouldMergeContentFromSource()
        {
            var settings = new SettingsHolder();

            settings.SetDefault("SomeDefaultSetting", "Value1");
            settings.Set("SomeSetting", "Value1");

            var mergeFrom = new SettingsHolder();

            mergeFrom.SetDefault("SomeDefaultSettingThatGetsMerged", "Value1");
            mergeFrom.Set("SomeSettingThatGetsMerged", "Value1");

            settings.Merge(mergeFrom);

            var result1 = settings.Get <string>("SomeDefaultSettingThatGetsMerged");
            var result2 = settings.Get <string>("SomeSettingThatGetsMerged");

            Assert.AreEqual("Value1", result1);
            Assert.AreEqual("Value1", result2);
        }
 /// <summary>
 /// Configures the <see cref="ITransport" /> not to enlist in Distributed Transactions.
 /// </summary>
 public TransactionAdvancedSettings DisableDistributedTransactions()
 {
     SettingsHolder.Set("Transactions.SuppressDistributedTransactions", true);
     return(this);
 }
            /// <summary>
            ///    Sets the isolation level of the transaction.
            /// </summary>
            /// <param name="isolationLevel">A <see cref="T:System.Transactions.IsolationLevel" /> enumeration that specifies the isolation level of the transaction.</param>
            public TransactionAdvancedSettings IsolationLevel(IsolationLevel isolationLevel)
            {
                SettingsHolder.Set("Transactions.IsolationLevel", isolationLevel);

                return(this);
            }
 /// <summary>
 ///     Configures this endpoint to not use transactions.
 /// </summary>
 /// <remarks>
 ///     Turning transactions off means that the endpoint won't do retries and messages are lost on exceptions.
 /// </remarks>
 public TransactionSettings Disable()
 {
     SettingsHolder.Set("Transactions.Enabled", false);
     return(this);
 }
 /// <summary>
 ///     Configures this endpoint to use transactions.
 /// </summary>
 /// <remarks>
 ///     A transactional endpoint means that we don't remove a message from the queue until it has been successfully processed.
 /// </remarks>
 public TransactionSettings Enable()
 {
     SettingsHolder.Set("Transactions.Enabled", true);
     return(this);
 }
 /// <summary>
 /// Configures this endpoint so that <see cref="IHandleMessages{T}">handlers</see> not wrapped in a <see cref="TransactionScope" />.
 /// </summary>
 public TransactionAdvancedSettings WrapHandlersExecutionInATransactionScope()
 {
     SettingsHolder.Set("Transactions.DoNotWrapHandlersExecutionInATransactionScope", false);
     return(this);
 }
Beispiel #9
0
 /// <summary>
 /// Configures endpoint with messages that are not guaranteed to be delivered in the event of a computer failure or network problem.
 /// </summary>
 /// <returns></returns>
 public EndpointAdvancedSettings DisableDurableMessages()
 {
     SettingsHolder.Set("Endpoint.DurableMessages", false);
     return(this);
 }
Beispiel #10
0
 /// <summary>
 ///     Configures this endpoint as a send only endpoint.
 /// </summary>
 /// <remarks>
 ///     Use this in endpoints whose only purpose is sending messages, websites are often a good example of send only endpoints.
 /// </remarks>
 public Endpoint AsSendOnly()
 {
     SettingsHolder.Set("Endpoint.SendOnly", true);
     Feature.Disable <TimeoutManager>();
     return(this);
 }