protected async Task StartPump(Func <MessageContext, Task> onMessage, Func <ErrorContext, Task <ErrorHandleResult> > onError, TransportTransactionMode transactionMode, Action <string, Exception> onCriticalError = null) { InputQueueName = GetTestName() + transactionMode; ErrorQueueName = $"{InputQueueName}.error"; transportSettings.Set("NServiceBus.Routing.EndpointName", InputQueueName); var queueBindings = new QueueBindings(); queueBindings.BindReceiving(InputQueueName); queueBindings.BindSending(ErrorQueueName); transportSettings.Set(ErrorQueueSettings.SettingsKey, ErrorQueueName); transportSettings.Set <QueueBindings>(queueBindings); transportSettings.Set <EndpointInstances>(new EndpointInstances()); Configurer = CreateConfigurer(); var configuration = Configurer.Configure(transportSettings, transactionMode); TransportInfrastructure = configuration.TransportInfrastructure; IgnoreUnsupportedTransactionModes(transactionMode); IgnoreUnsupportedDeliveryConstraints(); ReceiveInfrastructure = TransportInfrastructure.ConfigureReceiveInfrastructure(); SendInfrastructure = TransportInfrastructure.ConfigureSendInfrastructure(); lazyDispatcher = new Lazy <IDispatchMessages>(() => SendInfrastructure.DispatcherFactory()); MessagePump = ReceiveInfrastructure.MessagePumpFactory(); var queueCreator = ReceiveInfrastructure.QueueCreatorFactory(); await queueCreator.CreateQueueIfNecessary(queueBindings, WindowsIdentity.GetCurrent().Name); var pushSettings = new PushSettings(InputQueueName, ErrorQueueName, configuration.PurgeInputQueueOnStartup, transactionMode); await MessagePump.Init( context => { if (context.Headers.ContainsKey(TestIdHeaderName) && context.Headers[TestIdHeaderName] == testId) { return(onMessage(context)); } return(Task.FromResult(0)); }, context => { if (context.Message.Headers.ContainsKey(TestIdHeaderName) && context.Message.Headers[TestIdHeaderName] == testId) { return(onError(context)); } return(Task.FromResult(ErrorHandleResult.Handled)); }, new FakeCriticalError(onCriticalError), pushSettings); MessagePump.Start(configuration.PushRuntimeSettings); }
public NoiseField(DisplayOpenGL parent, IVisualizerFormat visualizer, Dictionary <string, object> config) { if (visualizer is not IContinuous1D) { Log.Error("NoiseField cannot be used with this visualizer, as it does not output 1D continuous data."); throw new InvalidOperationException("Incompatible visualizer. Must implement IContinuous1D."); } if (ColorChord.NoteFinder is not BaseNoteFinder) { throw new Exception("NoiseField currently only supports BaseNoteFinder."); } this.HostWindow = parent; this.DataSource = (IContinuous1D)visualizer; Configurer.Configure(this, config); }
public Radar(DisplayOpenGL parent, IVisualizer visualizer, Dictionary <string, object> config) { if (visualizer is not IDiscrete1D) { Log.Error("Radar cannot use the provided visualizer, as it does not output 1D discrete data."); throw new InvalidOperationException("Incompatible visualizer. Must implement IDiscrete1D."); } if (ColorChord.NoteFinder is not BaseNoteFinder) { throw new Exception("Radar currently only supports BaseNoteFinder."); } Configurer.Configure(this, config); this.HostWindow = parent; this.DataSource = (IDiscrete1D)visualizer; this.RadiusResolution = this.DataSource.GetCountDiscrete(); }
protected async Task StartPump(Func <MessageContext, Task> onMessage, Func <ErrorContext, Task <ErrorHandleResult> > onError, TransportTransactionMode transactionMode, Action <string, Exception> onCriticalError = null) { InputQueueName = GetTestName() + transactionMode; ErrorQueueName = $"{InputQueueName}.error"; var endpointConfiguration = new EndpointConfiguration(InputQueueName); endpointConfiguration.SendFailedMessagesTo(ErrorQueueName); transportSettings = endpointConfiguration.GetSettings(); var queueBindings = transportSettings.Get <QueueBindings>(); queueBindings.BindReceiving(InputQueueName); queueBindings.BindSending(ErrorQueueName); Configurer = CreateConfigurer(); var configuration = Configurer.Configure(transportSettings, transactionMode); TransportInfrastructure = configuration.TransportInfrastructure; IgnoreUnsupportedTransactionModes(transactionMode); IgnoreUnsupportedDeliveryConstraints(); ReceiveInfrastructure = TransportInfrastructure.ConfigureReceiveInfrastructure(); var queueCreator = ReceiveInfrastructure.QueueCreatorFactory(); var userName = GetUserName(); await queueCreator.CreateQueueIfNecessary(queueBindings, userName); var result = await ReceiveInfrastructure.PreStartupCheck(); if (result.Succeeded == false) { throw new Exception($"Pre start-up check failed: {result.ErrorMessage}"); } await TransportInfrastructure.Start(); SendInfrastructure = TransportInfrastructure.ConfigureSendInfrastructure(); lazyDispatcher = new Lazy <IDispatchMessages>(() => SendInfrastructure.DispatcherFactory()); MessagePump = ReceiveInfrastructure.MessagePumpFactory(); await MessagePump.Init( context => { if (context.Headers.ContainsKey(TestIdHeaderName) && context.Headers[TestIdHeaderName] == testId) { return(onMessage(context)); } return(Task.FromResult(0)); }, context => { if (context.Message.Headers.ContainsKey(TestIdHeaderName) && context.Message.Headers[TestIdHeaderName] == testId) { return(onError(context)); } return(Task.FromResult(ErrorHandleResult.Handled)); }, new FakeCriticalError(onCriticalError), new PushSettings(InputQueueName, ErrorQueueName, configuration.PurgeInputQueueOnStartup, transactionMode)); result = await SendInfrastructure.PreStartupCheck(); if (result.Succeeded == false) { throw new Exception($"Pre start-up check failed: {result.ErrorMessage}"); } MessagePump.Start(configuration.PushRuntimeSettings); }
public WindowsMIDI(string name, Dictionary <string, object> config) { this.Callback = MIDICallback; this.CallbackHandle = GCHandle.Alloc(Callback); Configurer.Configure(this, config); }
private static ISessionFactory BuildSessionFactory() { var configuration = Configurer.Configure("IMDBDB", ConfigurationManager.ConnectionStrings["IMDBDB"], ClassMappingTypes); return(configuration.BuildSessionFactory()); }
public CNFABinding(string name, Dictionary <string, object> config) { Configurer.Configure(this, config); this.Callback = SoundCallback; this.CallbackHandle = GCHandle.Alloc(this.Callback); }
public ConfigTargetValid(Dictionary <string, object> config) { Configurer.Configure(this, config); }