void EnablingSla(Configure configure)
 {
     #region enable-sla
     // in this version there was no granular control over individual counters
     configure.EnablePerformanceCounters();
     #endregion
 }
        protected override void Initialize(Configure config)
        {
            connectionStringFunc = () => "Url = http://localhost:8080; DefaultDatabase=MyDB";
            database = "CustomDatabase";

            config.RavenPersistence(connectionStringFunc, database);
        }
 private void ConfigurePublishingInfrastructure(Configure config, AzureServiceBusQueueConfig configSection)
 {
     config.Configurer.ConfigureComponent<AzureServiceBusTopicPublisher>(DependencyLifecycle.InstancePerCall);
     config.Configurer.ConfigureProperty<AzureServiceBusTopicPublisher>(t => t.MaxDeliveryCount, configSection.MaxDeliveryCount);
     
     config.Configurer.ConfigureComponent<AzureServiceBusTopicSubscriptionManager>(DependencyLifecycle.InstancePerCall);
 }
 void EnablingCriticalTime(Configure configure)
 {
     #region enable-criticaltime
     // in this version there was no granular control over individual counters
     configure.EnablePerformanceCounters();
     #endregion
 }
        public void Configure(Configure config)
        {
            this.Builder = config.Builder;
            this.Configurer = config.Configurer;

            this.config = Configurer.ConfigureComponent<RabbitMqTransport>(ComponentCallModelEnum.Singleton);
            var cfg = NServiceBus.Configure.GetConfigSection<RabbitMqTransportConfig>();

            if(cfg != null)
            {
                this.config.ConfigureProperty(t => t.NumberOfWorkerThreads, cfg.NumberOfWorkerThreads);
                this.config.ConfigureProperty(t => t.MaximumNumberOfRetries, cfg.MaxRetries);
                this.config.ConfigureProperty(t => t.InputBroker, cfg.InputBroker);
                this.config.ConfigureProperty(t => t.InputExchange, cfg.InputExchange);
                this.config.ConfigureProperty(t => t.InputExchangeType, cfg.InputExchangeType);
                this.config.ConfigureProperty(t => t.InputQueue, cfg.InputQueue);
                this.config.ConfigureProperty(t => t.InputRoutingKeys, cfg.InputRoutingKeys);
                this.config.ConfigureProperty(t => t.DoNotCreateInputExchange, cfg.DoNotCreateInputExchange);
                this.config.ConfigureProperty(t => t.DoNotCreateInputQueue, cfg.DoNotCreateInputQueue);
                this.config.ConfigureProperty(t => t.ErrorBroker, cfg.ErrorBroker);
                this.config.ConfigureProperty(t => t.ErrorExchange, cfg.ErrorExchange);
                this.config.ConfigureProperty(t => t.ErrorExchangeType, cfg.ErrorExchangeType);
                this.config.ConfigureProperty(t => t.ErrorQueue, cfg.ErrorQueue);
                this.config.ConfigureProperty(t => t.ErrorRoutingKeys, cfg.ErrorRoutingKeys);
                this.config.ConfigureProperty(t => t.DoNotCreateErrorExchange, cfg.DoNotCreateErrorExchange);
                this.config.ConfigureProperty(t => t.DoNotCreateErrorQueue, cfg.DoNotCreateErrorQueue);

                this.config.ConfigureProperty(t => t.TransactionTimeout, TimeSpan.FromMinutes(cfg.TransactionTimeout));
                this.config.ConfigureProperty(t => t.SendAcknowledgement, cfg.SendAcknowledgement);
            }
        }
Example #6
0
        /// <summary>
        /// The run method
        /// </summary>
        /// <param name="config">
        /// The config.
        /// </param>
        public void Run(Configure config)
        {
            Logger.Info("Statup.Run()");

            var initMessage = new MyMessage
                                  {
                                      SomeId = "carlos",
                                      LargeBlob = new DataBusProperty<byte[]>(Guid.NewGuid().ToByteArray())
                                  };
            var anotherMessage = new AnotherSagaCommand { SomeId = initMessage.SomeId, SleepHowLong = 2000 };

            Thread.Sleep(5000);
            this.bus.Send(initMessage);

            Thread.Sleep(1000);

            for (var i = 0; i < 5; i++)
            {
                anotherMessage.SleepHowLong = i;
                this.bus.SendLocal(anotherMessage);
            }

            anotherMessage.SleepHowLong = 0;
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
            this.bus.SendLocal(anotherMessage);
        }
 public SerializationMapper(IMessageMapper mapper, Conventions conventions, Configure configure)
 {
     jsonSerializer = new JsonMessageSerializer(mapper);
     xmlSerializer = new XmlMessageSerializer(mapper, conventions);
     List<Type> messageTypes = configure.TypesToScan.Where(conventions.IsMessageType).ToList();
     xmlSerializer.Initialize(messageTypes);
 }
        /// <summary>
        /// Wraps the given configuration object but stores the same 
        /// builder and configurer properties.
        /// </summary>
        /// <param name="config"></param>
        public void Configure(Configure config)
        {
            Builder = config.Builder;
            Configurer = config.Configurer;

            transportConfig = Configurer.ConfigureComponent<XmsTransport>(ComponentCallModelEnum.Singleton);

            var cfg = GetConfigSection<XmsTransportConfig>();

            var dictionary = new Dictionary<string, string>();
            if (cfg != null)
            {
                transportConfig.ConfigureProperty(t => t.InputQueue, cfg.InputQueue);
                transportConfig.ConfigureProperty(t => t.NumberOfWorkerThreads, cfg.NumberOfWorkerThreads);
                transportConfig.ConfigureProperty(t => t.ErrorQueue, cfg.ErrorQueue);
                transportConfig.ConfigureProperty(t => t.MaxRetries, cfg.MaxRetries);

                if(cfg.Aliases!=null)
                {
                    dictionary = cfg.Aliases.ToDictionary(x => x.Name, y => y.Value);
                }
            }

            transportConfig.ConfigureProperty(t => t.Aliases, dictionary);

            var unicastConfig = GetConfigSection<UnicastBusConfig>();

            if (unicastConfig != null)
            {
                if (!string.IsNullOrEmpty(unicastConfig.ForwardReceivedMessagesTo))
                    transportConfig.ConfigureProperty(t => t.ForwardReceivedMessagesTo, unicastConfig.ForwardReceivedMessagesTo);
            }
        }
 public void SetUp()
 {
     config = Configure.With(new[] { typeof(MySaga).Assembly})
         .DefaultBuilder()
         .Sagas()
         .NHibernateSagaPersisterWithSQLiteAndAutomaticSchemaGeneration();
 }
        public void SetUp()
        {
            config = Configure.With()
          .SpringBuilder()
          .DBSubcriptionStorage();

        }
 public void SetUp()
 {
     config = Configure.With(new Type[] { })
                         .DefineEndpointName("Foo")
                         .DefaultBuilder()
                         .UseNHibernateSubscriptionPersister();
 }
Example #12
0
        void CustomConnectionString(Configure configure)
        {
            #region rabbitmq-config-connectionstring-in-code

            configure.UseTransport<RabbitMQ>(() => "My custom connection string");
            #endregion
        }
#pragma warning disable 1591 // Xml Comments
		public void Initialize(Configure configure)
        {
            var section = _configurationManager.GetSection("BifrostConfig") as BifrostConfig;
            if( section != null )
            {
                if( section.Commands != null )
                {
                    
                }
                if( section.DefaultStorage != null )
                {
                    var configuration = section.DefaultStorage.GetConfiguration();
                    configure.Container.Bind<IEntityContextConfiguration>(configuration);
                    configure.Container.Bind(configuration.Connection.GetType(), configuration.Connection);
                    configure.Container.Bind(typeof(IEntityContext<>), section.DefaultStorage.EntityContextType);
                }

                if( section.Events != null )
                {
                    configure.Events.RepositoryType = section.Events.RepositoryType;
                }
				if( section.Sagas != null )
				{
					configure.Sagas.LibrarianType = section.Sagas.LibrarianType;
				}
            }
		}
 void RenamePrincipalHack(Configure configure)
 {
     #region 3to4RenamePrincipalHack
     var unicastBus = configure.UnicastBus();
     unicastBus.RunHandlersUnderIncomingPrincipal(true);
     #endregion
 }
        public static BrokeredMessage ToBrokeredMessage(this TransportMessage message, SendOptions options, SettingsHolder settings, bool expectDelay, Configure config)
        {
            var brokeredMessage = BrokeredMessageBodyConversion.InjectBody(message.Body);

            SetHeaders(message, options, settings, config, brokeredMessage);

            var timeToSend = DelayIfNeeded(options, expectDelay);
                        
            if (timeToSend.HasValue)
                brokeredMessage.ScheduledEnqueueTimeUtc = timeToSend.Value;

            TimeSpan? timeToLive = null;
            if (message.TimeToBeReceived < TimeSpan.MaxValue)
            {
                timeToLive = message.TimeToBeReceived;
            }
            else if (options.TimeToBeReceived.HasValue && options.TimeToBeReceived < TimeSpan.MaxValue)
            {
                timeToLive = options.TimeToBeReceived.Value;
            }

            if (timeToLive.HasValue)
            {
                if (timeToLive.Value <= TimeSpan.Zero) return null;

                brokeredMessage.TimeToLive = timeToLive.Value;
            }
            GuardMessageSize(brokeredMessage);

            return brokeredMessage;
        }
        CustomRavenConfig(Configure configure)
        {
            #region OldRavenDBPersistenceInitialization

            configure.RavenPersistence();
            configure.RavenSagaPersister();
            configure.RavenSubscriptionStorage();
            configure.UseRavenTimeoutPersister();
            configure.UseRavenGatewayDeduplication();
            configure.UseRavenGatewayPersister();

            #endregion

            #region Version2_5RavenDBPersistenceInitialization

            // Need to call this method
            configure.RavenDBStorage();
            // Call this method to use Raven saga storage
            configure.UseRavenDBSagaStorage();
            // Call this method to use Raven subscription storage
            configure.UseRavenDBSubscriptionStorage();
            // Call this method to use Raven timeout storage
            configure.UseRavenDBTimeoutStorage();
            // Call this method to use Raven deduplication storage for the Gateway
            configure.UseRavenDBGatewayDeduplicationStorage();
            // Call this method to use the  Raven Gateway storage method
            configure.UseRavenDBGatewayStorage();

            #endregion
        }
Example #17
0
        public void Install(string identity, Configure config)
        {
            if (config.Settings.Get<bool>("Endpoint.SendOnly"))
            {
                return;
            }

            if (!config.CreateQueues())
            {
                return;
            }

            var wantQueueCreatedInstances = config.Builder.BuildAll<IWantQueueCreated>().ToList();

            foreach (var wantQueueCreatedInstance in wantQueueCreatedInstances.Where(wantQueueCreatedInstance => wantQueueCreatedInstance.ShouldCreateQueue()))
            {
                if (wantQueueCreatedInstance.Address == null)
                {
                    throw new InvalidOperationException(string.Format("IWantQueueCreated implementation {0} returned a null address", wantQueueCreatedInstance.GetType().FullName));
                }

                QueueCreator.CreateQueueIfNecessary(wantQueueCreatedInstance.Address, identity);
                Logger.DebugFormat("Verified that the queue: [{0}] existed", wantQueueCreatedInstance.Address);
            }
        }
        public void Install(string identity, Configure config)
        {
            Console.Title = "Complaint.Frontend";

            Console.WriteLine(
                "Hy there from CustomWindowsEverytimeInstaller! I will run every time! Identity {0}", identity);
        }
 public void SetUp()
 {
     config = Configure.With(new[] { typeof(MySaga).Assembly})
         .DefaultBuilder()
         .Sagas()
         .NHibernateSagaPersister();
 }
        public SqsDequeueStrategy(Configure config)
        {
			if (config != null)
				_purgeOnStartup = config.PurgeOnStartup();
			else
				_purgeOnStartup = false;
        }
 public void Install(string identity, Configure config)
 {
     if (RunInstaller)
     {
         new OptimizedSchemaUpdate(Configuration).Execute(false, true);
     }
 }
Example #22
0
        Usage(Configure configure)
        {
            #region SLRConfigurationSourceUsage

            configure.CustomConfigurationSource(new ConfigurationSource());

            #endregion
        }
Example #23
0
        Usage(Configure configure)
        {
            #region UseCustomConfigurationSourceForErrorQueueConfig

            configure.CustomConfigurationSource(new ConfigurationSource());

            #endregion
        }
        DefineExpress(Configure configure)
        {
            #region ExpressMessageConvention

            configure.DefiningExpressMessagesAs(t => t.Name.EndsWith("Express"));

            #endregion
        }
Example #25
0
    Usage(Configure configure)
    {
        #region Unity

        configure.UnityBuilder();

        #endregion
    }
Example #26
0
        Usage(Configure configure)
        {
            #region ConfiguringMsmqPersistence

            configure.MsmqSubscriptionStorage();

            #endregion
        }
Example #27
0
        Usage(Configure configure)
        {
            #region EncryptionServiceSimple

            configure.RijndaelEncryptionService();

            #endregion
        }
Example #28
0
        Usage(Configure configure)
        {
            #region Spring

            configure.SpringFrameworkBuilder();

            #endregion
        }
Example #29
0
        void RunDistributor(Configure configure)
        {
            #region 3to4RunDistributor

            configure.RunDistributor();

            #endregion
        }
Example #30
0
        void EnlistWithDistributor(Configure configure)
        {
            #region 3to4EnlistWithDistributor

            configure.EnlistWithDistributor();

            #endregion
        }
Example #31
0
 public UserWallet GetUserWallet(Network network, IUser user)
 {
     // BIP32 path: m / service_index' / user_id1' / user_id2' / user_id3' / reserved'
     return(new UserWallet(this, network, user, Configure.GetExtKey(GetKeyPath(user.Id))));
 }
Example #32
0
 private void login()
 {
     SendMessage(String.Format("80:{0},{1}", Configure.GetStockTraderItem(USERNAME), Configure.GetStockTraderItem(PASSWORD)));
 }
Example #33
0
        public void InitWebSocket()
        {
            // form.Show();
            showForm = ShowNotifyForm;

            wsChat            = new WebSocket(String.Format("ws://{0}/websock/stockmarket", Configure.GetStockTraderItem(SERVER)));
            openHandler       = new EventHandler(wsChat_OnOpen);
            wsChat.OnOpen    += openHandler;
            closeHandler      = new EventHandler <CloseEventArgs>(wsChat_OnClose);
            wsChat.OnClose   += closeHandler;
            errorHandler      = new EventHandler <ErrorEventArgs>(wsChat_OnError);
            wsChat.OnError   += errorHandler;
            messageHandler    = new EventHandler <MessageEventArgs>(wsChat_OnMessage);
            wsChat.OnMessage += messageHandler;
            connectServer();
        }
Example #34
0
 public override void ConfigureFake(IUndefined fakeObject)
 {
     Configure.Fake(fakeObject)
     .CallsTo(x => x.WasConfigured())
     .Returns(true);
 }
Example #35
0
        static TimeSpan RunTest(int numberOfMessages, PipelineStepProfilerStats profilerStats, PipelineInvokerMode pipelineInvokerMode)
        {
            using (var adapter = new BuiltinHandlerActivator())
            {
                var network = new InMemNetwork();

                Configure.With(adapter)
                .Logging(l => l.Console(LogLevel.Warn))
                .Transport(t => t.UseInMemoryTransport(network, "perftest"))
                .Options(o =>
                {
                    o.SetNumberOfWorkers(0);
                    o.SetMaxParallelism(1);

                    o.Decorate <IPipeline>(c => new PipelineStepProfiler(c.Get <IPipeline>(), profilerStats));

                    switch (pipelineInvokerMode)
                    {
                    case PipelineInvokerMode.Default:
                        o.Register <IPipelineInvoker>(c => new DefaultPipelineInvoker(c.Get <IPipeline>()));
                        break;

                    case PipelineInvokerMode.DefaultNew:
                        o.Register <IPipelineInvoker>(c => new DefaultPipelineInvokerNew(c.Get <IPipeline>()));
                        break;

                    case PipelineInvokerMode.Compiled:
                        o.Register <IPipelineInvoker>(c => new CompiledPipelineInvoker(c.Get <IPipeline>()));
                        break;

                    case PipelineInvokerMode.Action:
                        o.Register <IPipelineInvoker>(c => new ActionPipelineInvoker(c.Get <IPipeline>()));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException($"Unknown pipeline invoker: {pipelineInvokerMode}");
                    }
                })
                .Start();

                var serializer = new JsonSerializer(new SimpleAssemblyQualifiedMessageTypeNameConvention());
                var boy        = new SomeMessage("hello there!");

                for (var counter = 0; counter < numberOfMessages; counter++)
                {
                    var headers = new Dictionary <string, string> {
                        { Headers.MessageId, Guid.NewGuid().ToString() }
                    };
                    var message               = new Message(headers, boy);
                    var transportMessage      = serializer.Serialize(message).Result;
                    var inMemTransportMessage = transportMessage.ToInMemTransportMessage();

                    network.Deliver("perftest", inMemTransportMessage);
                }
                ;

                var numberOfReceivedMessages = 0;
                var gotAllMessages           = new ManualResetEvent(false);

                adapter.Handle <SomeMessage>(async m =>
                {
                    Interlocked.Increment(ref numberOfReceivedMessages);

                    if (Volatile.Read(ref numberOfReceivedMessages) == numberOfMessages)
                    {
                        gotAllMessages.Set();
                    }
                });

                var stopwatch = Stopwatch.StartNew();

                adapter.Bus.Advanced.Workers.SetNumberOfWorkers(1);
                gotAllMessages.WaitOrDie(TimeSpan.FromSeconds(30));

                return(stopwatch.Elapsed);
            }
        }
Example #36
0
 public BikeController(IOptions <Configure> configure, IBlobStorageService blobStorageService, IDataRepository <Bike> dataRepository)
 {
     _configure          = configure.Value;
     _dataRepository     = dataRepository;
     _blobStorageService = blobStorageService;
 }
 /// <summary>
 ///   <p>Manage resource provider features.</p>
 ///   <p>For more details, visit the <a href="https://docs.microsoft.com/en-us/cli/azure/feature?view=azure-cli-latest">official website</a>.</p>
 /// </summary>
 /// <remarks>
 ///   <p>This is a <a href="http://www.nuke.build/docs/authoring-builds/cli-tools.html#fluent-apis">CLI wrapper with fluent API</a> that allows to modify the following arguments:</p>
 ///   <ul>
 ///     <li><c>--debug</c> via <see cref="AzureFeatureListSettings.Debug"/></li>
 ///     <li><c>--help</c> via <see cref="AzureFeatureListSettings.Help"/></li>
 ///     <li><c>--namespace</c> via <see cref="AzureFeatureListSettings.Namespace"/></li>
 ///     <li><c>--output</c> via <see cref="AzureFeatureListSettings.Output"/></li>
 ///     <li><c>--query</c> via <see cref="AzureFeatureListSettings.Query"/></li>
 ///     <li><c>--subscription</c> via <see cref="AzureFeatureListSettings.Subscription"/></li>
 ///     <li><c>--verbose</c> via <see cref="AzureFeatureListSettings.Verbose"/></li>
 ///   </ul>
 /// </remarks>
 public static IReadOnlyCollection <Output> AzureFeatureList(Configure <AzureFeatureListSettings> configurator)
 {
     return(AzureFeatureList(configurator(new AzureFeatureListSettings())));
 }
 public OutboxLoopbackSendBehavior(Configure configure)
 {
     this.configure = configure;
 }
Example #39
0
        public static void GenerateCode(string saveTo, bool tsOnly = false)
        {
            filters = Configure.GetFilters();
            var configure = Configure.GetConfigureByTags(new List <string>()
            {
                "Puerts.BindingAttribute",
                "Puerts.BlittableCopyAttribute",
                "Puerts.TypingAttribute",
            });

            var genTypes = configure["Puerts.BindingAttribute"].Select(kv => kv.Key)
                           .Where(o => o is Type)
                           .Cast <Type>()
                           .Where(t => !t.IsGenericTypeDefinition);

            var blittableCopyTypes = new HashSet <Type>(configure["Puerts.BlittableCopyAttribute"].Select(kv => kv.Key)
                                                        .Where(o => o is Type)
                                                        .Cast <Type>()
                                                        .Where(t => !t.IsPrimitive && isBlittableType(t))
                                                        .Distinct());

            var tsTypes = configure["Puerts.TypingAttribute"].Select(kv => kv.Key)
                          .Where(o => o is Type)
                          .Cast <Type>()
                          .Where(t => !t.IsGenericTypeDefinition)
                          .Concat(genTypes)
                          .Distinct();

            using (var jsEnv = new JsEnv())
            {
                var templateGetter = jsEnv.Eval <Func <string, Func <object, string> > >("require('puerts/gencode/main.js')");
                var wrapRender     = templateGetter("type.tpl");

                if (!tsOnly)
                {
                    var typeGenInfos = new List <TypeGenInfo>();
                    foreach (var type in genTypes)
                    {
                        if (type.IsEnum || type.IsArray || (IsDelegate(type) && type != typeof(Delegate)))
                        {
                            continue;
                        }
                        TypeGenInfo typeGenInfo = ToTypeGenInfo(type);
                        typeGenInfo.BlittableCopy = blittableCopyTypes.Contains(type);
                        typeGenInfos.Add(typeGenInfo);
                        string filePath    = saveTo + typeGenInfo.WrapClassName + ".cs";
                        string fileContext = wrapRender(typeGenInfo);
                        using (StreamWriter textWriter = new StreamWriter(filePath, false, Encoding.UTF8))
                        {
                            textWriter.Write(fileContext);
                            textWriter.Flush();
                        }
                    }

                    var autoRegisterRender = templateGetter("autoreg.tpl");
                    using (StreamWriter textWriter = new StreamWriter(saveTo + "AutoStaticCodeRegister.cs", false, Encoding.UTF8))
                    {
                        string fileContext = autoRegisterRender(typeGenInfos.ToArray());
                        textWriter.Write(fileContext);
                        textWriter.Flush();
                    }
                }

                var typingRender = templateGetter("typing.tpl");
                using (StreamWriter textWriter = new StreamWriter(saveTo + "Typing/csharp/index.d.ts", false, Encoding.UTF8))
                {
                    string fileContext = typingRender(ToTypingGenInfo(tsTypes));
                    textWriter.Write(fileContext);
                    textWriter.Flush();
                }
            }
        }
Example #40
0
 public void ThrowsIfNoTransportIsSpecified()
 {
     Assert.Throws <ConfigurationErrorsException>(() => Configure.With(new BuiltinHandlerActivator()).Start());
 }
 public static IReadOnlyCollection <Output> Down(Configure <DockerComposeDownSettings> configure) =>
 Down(configure(new DockerComposeDownSettings()));
 public static IReadOnlyCollection <Output> Logs(Configure <DockerComposeLogsSettings> configure) =>
 Logs(configure(new DockerComposeLogsSettings()));
Example #43
0
 protected void StubResolve <T>(T returnedInstance)
 {
     Configure.Fake(ServiceLocator.Current)
     .CallsTo(x => x.Resolve(typeof(T)))
     .Returns(returnedInstance);
 }
Example #44
0
 public static void SendSlackMessage(Configure <SlackMessage> configurator, string webhook)
 {
     SendSlackMessageAsync(configurator, webhook).Wait();
 }
Example #45
0
 protected override void InternalConfigure(Configure config)
 {
     Enable <WebSphereMQTransport>();
 }
Example #46
0
 public void Init()
 {
     Configure.With().DefiningCommandsAs(t => t.Namespace != null && t.Namespace.EndsWith("Commands"))
     .DefiningMessagesAs(t => t.Namespace == "FullDuplex.Contracts.Messages")
     .DefineEndpointName("FullDuplex.EndPoint");;
 }
Example #47
0
 public void Customize(BusConfiguration configuration)
 {
     Configure.ForAllTypes <ISatellite>(configuration.Settings.GetAvailableTypes(), t => configuration.RegisterComponents(c => c.ConfigureComponent(t, DependencyLifecycle.SingleInstance)));
 }
Example #48
0
 private static void Assert <T>(Configure <T> configurator, string arguments)
     where T : ToolSettings, new()
 {
     configurator.Invoke(new T()).GetArguments().RenderForOutput().Should().Be(arguments);
 }
Example #49
0
        public void CanConfigureNumberOfRetriesForExceptionTypes()
        {
            const string errorQueueName            = "error";
            const string testCustomretrycountInput = "test.customRetryCount.input";

            using (var adapter = new BuiltinContainerAdapter())
                using (var errorQueue = GetMessageQueue(errorQueueName))
                {
                    errorQueue.Purge();

                    using (var inputQueue = GetMessageQueue(testCustomretrycountInput))
                    {
                        inputQueue.Purge();
                    }

                    var bimCount      = 0;
                    var bomCount      = 0;
                    var bommelomCount = 0;

                    adapter.Handle <string>(str =>
                    {
                        if (str == "bim")
                        {
                            bimCount++;
                            throw new InvalidOperationException("bim!");
                        }

                        if (str == "bom")
                        {
                            bomCount++;
                            throw new ArgumentException("bom!");
                        }

                        bommelomCount++;
                        throw new ExpectationViolationException("bommelom!");
                    });

                    var bus = (RebusBus)
                              Configure.With(adapter)
                              .Logging(l => l.None())
                              .Transport(t => t.UseMsmq(testCustomretrycountInput, errorQueueName))
                              .Behavior(b => b.SetMaxRetriesFor <InvalidOperationException>(9)
                                        .SetMaxRetriesFor <ArgumentException>(7))
                              .CreateBus();

                    bus.Start(1);

                    adapter.Bus.SendLocal("bim");
                    adapter.Bus.SendLocal("bom");
                    adapter.Bus.SendLocal("bommelom");

                    // dequeue three messages
                    var first  = errorQueue.Receive(TimeSpan.FromSeconds(10));
                    var second = errorQueue.Receive(TimeSpan.FromSeconds(1));
                    var third  = errorQueue.Receive(TimeSpan.FromSeconds(1));

                    bimCount.ShouldBe(9);
                    bomCount.ShouldBe(7);
                    bommelomCount.ShouldBe(5); //< default
                }
        }
Example #50
0
        /// <summary>
        /// 对指定的程序集注入
        /// </summary>
        /// <param name="assembly">程序集路径</param>
        public static void InjectAssembly(string assembly)
        {
            var configure = Configure.GetConfigureByTags(new List <string>()
            {
                "IFix.IFixAttribute",
                "IFix.InterpretAttribute",
                "IFix.ReverseWrapperAttribute",
            });

            var processCfgPath = "./process_cfg";

            //该程序集是否有配置了些类,如果没有就跳过注入操作
            bool hasSomethingToDo = false;

            using (BinaryWriter writer = new BinaryWriter(new FileStream(processCfgPath, FileMode.Create,
                                                                         FileAccess.Write)))
            {
                writer.Write(configure.Count);

                foreach (var kv in configure)
                {
                    writer.Write(kv.Key);

                    var typeList = kv.Value.Where(item => item.Key is Type)
                                   .Select(item => new KeyValuePair <Type, int>(item.Key as Type, item.Value))
                                   .Where(item => item.Key.Assembly.GetName().Name == assembly)
                                   .ToList();
                    writer.Write(typeList.Count);

                    if (typeList.Count > 0)
                    {
                        hasSomethingToDo = true;
                    }

                    foreach (var cfgItem in typeList)
                    {
                        writer.Write(GetCecilTypeName(cfgItem.Key));
                        writer.Write(cfgItem.Value);
                    }
                }
            }

            if (hasSomethingToDo)
            {
                var           core_path     = "./Assets/Plugins/IFix.Core.dll";
                var           assembly_path = string.Format("./Library/ScriptAssemblies/{0}.dll", assembly);
                var           patch_path    = string.Format("./{0}.ill.bytes", assembly);
                List <string> args          = new List <string>()
                {
                    "-inject", core_path, assembly_path,
                    processCfgPath, patch_path, assembly_path
                };

                foreach (var path in
                         (from asm in AppDomain.CurrentDomain.GetAssemblies()
                          select Path.GetDirectoryName(asm.ManifestModule.FullyQualifiedName)).Distinct())
                {
                    try
                    {
                        //UnityEngine.Debug.Log("searchPath:" + path);
                        args.Add(path);
                    }
                    catch { }
                }

                CallIFix(args);
            }

            File.Delete(processCfgPath);
        }
        public async Task CheckIdleBehavior()
        {
            var activator          = Using(new BuiltinHandlerActivator());
            var transportDecorator = new LoggingTransportDecorator();

            Configure.With(activator)
            .Transport(t =>
            {
                t.UseInMemoryTransport(new InMemNetwork(), "backoff-check");
                t.Decorate(c =>
                {
                    var transport = c.Get <ITransport>();
                    transportDecorator.Transport = transport;
                    return(transportDecorator);
                });
            })
            .Options(o =>
            {
                o.SetBackoffTimes(
                    // first five  seconds
                    TimeSpan.FromSeconds(0.01),
                    TimeSpan.FromSeconds(0.01),
                    TimeSpan.FromSeconds(0.01),
                    TimeSpan.FromSeconds(0.01),
                    TimeSpan.FromSeconds(0.01),

                    // next five seconds
                    TimeSpan.FromSeconds(0.1),
                    TimeSpan.FromSeconds(0.1),
                    TimeSpan.FromSeconds(0.1),
                    TimeSpan.FromSeconds(0.1),
                    TimeSpan.FromSeconds(0.1),

                    // the rest of the time
                    TimeSpan.FromSeconds(0.5)
                    );
            })
            .Start();

            await Task.Delay(TimeSpan.FromSeconds(15));

            var recordedReceiveTimes = transportDecorator.ReceiveTimes.ToList();

            var results = recordedReceiveTimes
                          .GroupBy(t => t.RoundTo(TimeSpan.FromSeconds(1)))
                          .OrderBy(g => g.Key)
                          .Select(g => new
            {
                Time  = g.Key,
                Count = g.Count()
            })
                          .ToList();

            Console.WriteLine(string.Join(Environment.NewLine, results.Select(r => $"{r.Time}: {new string('*', r.Count)}")));

            var firstPeriodMedian = results.Skip(0).Take(5).GetMedianBy(g => g.Time);

            var secondPeriodMedian = results.Skip(5).Take(5).GetMedianBy(g => g.Time);

            var thirdPeriodMedian = results.Skip(10).Take(5).GetMedianBy(g => g.Time);

            Console.WriteLine($" First period median: {firstPeriodMedian}");
            Console.WriteLine($"Second period median: {secondPeriodMedian}");
            Console.WriteLine($" Third period median: {thirdPeriodMedian}");

            Assert.That(firstPeriodMedian.Count, Is.GreaterThan(4 * secondPeriodMedian.Count),
                        "Expected receive calls during the first period to be more than four times as frequent as during the second period");

            Assert.That(secondPeriodMedian.Count, Is.GreaterThan(4 * thirdPeriodMedian.Count),
                        "Expected receive calls during the second period to be more than four times as frequent as during the third period");
        }
Example #52
0
 /// <summary><p>DocFX is an API documentation generator for .NET, and currently it supports C# and VB. It generates API reference documentation from triple-slash comments in your source code. It also allows you to use Markdown files to create additional topics such as tutorials and how-tos, and to customize the generated reference documentation. DocFX builds a static HTML website from your source code and Markdown files, which can be easily hosted on any web servers (for example, <em>github.io</em>). Also, DocFX provides you the flexibility to customize the layout and style of your website through templates. If you are interested in creating your own website with your own styles, you can follow <a href="http://dotnet.github.io/docfx/tutorial/howto_create_custom_template.html">how to create custom template</a> to create custom templates.</p><p>For more details, visit the <a href="https://dotnet.github.io/docfx/">official website</a>.</p></summary>
 public static IReadOnlyCollection <Output> DocFxBuild(string configPath, Configure <DocFxBuildSettings> configurator = null)
 {
     configurator = configurator ?? (x => x);
     return(DocFxBuild(x => configurator(x).SetConfigPath(configPath)));
 }
 public static void RegisterMessageEncryptor(this Configure busConfiguration)
 {
     busConfiguration.Configurer.ConfigureComponent <MessageEncryptor>(DependencyLifecycle.InstancePerCall);
 }
 public ToposConsumerConfigurer ConfigureConsumer(string groupName)
 {
     return(Configure
            .Consumer(groupName, c => c.UseKafka(KafkaTestConfig.Address))
            .Logging(l => l.UseSerilog()));
 }
 public ToposProducerConfigurer ConfigureProducer()
 {
     return(Configure
            .Producer(c => c.UseKafka(KafkaTestConfig.Address))
            .Logging(l => l.UseSerilog()));
 }
Example #56
0
 /// <summary><p>MSpec is called a 'context/specification' test framework because of the 'grammar' that is used in describing and coding the tests or 'specs'.</p><p>For more details, visit the <a href="https://github.com/machine/machine.specifications">official website</a>.</p></summary>
 public static IReadOnlyCollection <Output> MSpec(List <string> assemblies, Configure <MSpecSettings> configurator = null)
 {
     configurator = configurator ?? (x => x);
     return(MSpec(x => configurator(x).SetAssemblies(assemblies)));
 }
Example #57
0
 /// <summary>
 ///   <p>Test Cloud is a cloud based service consisting of thousands of physical mobile devices. Users upload their apps and tests to Test Cloud, which will install the apps on the devices and run the tests. When the tests are complete, Test Cloud, the results made available to users through an easy to use and informative web-based front end.</p>
 ///   <p>For more details, visit the <a href="https://developer.xamarin.com/guides/testcloud/">official website</a>.</p>
 /// </summary>
 /// <remarks>
 ///   <p>This is a <a href="http://www.nuke.build/docs/authoring-builds/cli-tools.html#fluent-apis">CLI wrapper with fluent API</a> that allows to modify the following arguments:</p>
 ///   <ul>
 ///     <li><c>--assembly-dir</c> via <see cref="TestCloudSettings.AssemblyDirectory"/></li>
 ///     <li><c>--data</c> via <see cref="TestCloudSettings.DataPaths"/></li>
 ///     <li><c>--devices</c> via <see cref="TestCloudSettings.Devices"/></li>
 ///     <li><c>--dsym</c> via <see cref="TestCloudSettings.DsymFile"/></li>
 ///     <li><c>--exclude</c> via <see cref="TestCloudSettings.ExcludeCategories"/></li>
 ///     <li><c>--fixture</c> via <see cref="TestCloudSettings.Fixtures"/></li>
 ///     <li><c>--fixture-chunk</c> via <see cref="TestCloudSettings.FixtureChunk"/></li>
 ///     <li><c>--include</c> via <see cref="TestCloudSettings.IncludeCategories"/></li>
 ///     <li><c>--nunit-xml</c> via <see cref="TestCloudSettings.NunitResultsFile"/></li>
 ///     <li><c>--sign-info</c> via <see cref="TestCloudSettings.SignInfoFile"/></li>
 ///     <li><c>--test-chunk</c> via <see cref="TestCloudSettings.TestChunk"/></li>
 ///     <li><c>--user</c> via <see cref="TestCloudSettings.UserEmail"/></li>
 ///   </ul>
 /// </remarks>
 public static IReadOnlyCollection <Output> TestCloud(Configure <TestCloudSettings> configurator)
 {
     return(TestCloud(configurator(new TestCloudSettings())));
 }
 public void ProfileActivated(Configure config)
 {
 }
Example #59
0
 public void Init()
 {
     Configure.Component <StatisticsUoW>(DependencyLifecycle.InstancePerUnitOfWork);
 }