Exemple #1
2
        /// <summary>
        /// Returns an IObservable that continuously updates as the user's
        /// physical location changes. It is super important to make sure to
        /// dispose all subscriptions to this IObservable.
        /// </summary>
        /// <param name="minUpdateTime">Minimum update time.</param>
        /// <param name="minUpdateDist">Minimum update dist.</param>
        /// <param name="includeHeading">If set to <c>true</c> include heading.</param>
        public static IObservable<Position> Listen(int minUpdateTime, double minUpdateDist, bool includeHeading = false)
        {
            if (Implementation != null) {
                return Implementation.Listen(minUpdateTime, minUpdateDist, includeHeading);
            }

            var ret = Observable.Create<Position>(subj => {
#if ANDROID
                var geo = new Geolocator(AndroidApp.Context);
#else
                var geo = new Geolocator();
#endif

                var disp = new CompositeDisposable();
                bool isDead = false;

                if (!geo.IsGeolocationAvailable || !geo.IsGeolocationEnabled) {
                    return Observable.Throw<Position>(new Exception("Geolocation isn't available")).Subscribe(subj);
                }

                // NB: This isn't very Functional, but I'm lazy.
                disp.Add(Observable.FromEventPattern<PositionEventArgs>(x => geo.PositionChanged += x, x => geo.PositionChanged -= x).Subscribe(x => {
                    if (isDead) return;
                    subj.OnNext(x.EventArgs.Position);
                }));

                disp.Add(Observable.FromEventPattern<PositionErrorEventArgs>(x => geo.PositionError += x, x => geo.PositionError -= x).Subscribe(ex => {
                    isDead = true;
                    var toDisp = Interlocked.Exchange(ref disp, null);
                    if (toDisp != null) toDisp.Dispose();
                    subj.OnError(new GeolocationException(ex.EventArgs.Error));
                }));

                return disp;
            });

            return ret.Multicast(new Subject<Position>()).RefCount();
        }
        public void SetUp()
        {
            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            clockName = Any.CamelCaseName();
            targetId = Any.Word();
            target = new CommandTarget(targetId);
            store = new InMemoryStore<CommandTarget>(
                _ => _.Id,
                id => new CommandTarget(id))
            {
                target
            };

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseDependency<IStore<CommandTarget>>(_ => store)
                .UseDependency<GetClockName>(c => _ => clockName)
                .TraceScheduledCommands();

            scheduler = configuration.CommandScheduler<CommandTarget>();

            Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
    public static void Run()
    {
      var systems = new[] { "A", "B", "C" }.Select(CreateExternalSystem);
      var observables = systems.Select(s => s.ObserveHealth()).Select(obs => obs.DistinctUntilChanged(c => c.IsAvailable)).ToList();
      var disposable = new CompositeDisposable();

      // observe independently
      disposable.Add(new CompositeDisposable(observables.Select(c => c.Subscribe(PrintHealthCheck))));

      // merge
      var merged = observables.Aggregate((l, r) => l.Merge(r));
      disposable.Add(merged.Subscribe(PrintHealthCheck));

      // combine
      var combined = observables
        .Aggregate(Observable.Return(Enumerable.Empty<HealthCheck>()), (agg, obs) => agg.CombineLatest(obs, (checks, check) => checks.Concat(new[] { check })));

      var scan = merged.Scan(ImmutableDictionary<string, bool>.Empty, (d, check) => d.SetItem(check.ExternalSystemName, check.IsAvailable));
      
      disposable.Add(combined.Subscribe(e => Console.WriteLine("Combined: " + string.Join(", ", e.Select(c => $"{c.ExternalSystemName}={c.IsAvailable}")))));
      disposable.Add(scan.Subscribe(d => Console.WriteLine("Scanned: " + string.Join(", ", d.Select(p => $"{p.Key}={p.Value}")))));

      Console.ReadKey();
      disposable.Dispose();
    }
        public void SetUp()
        {
            clockName = Any.CamelCaseName();

            Clock.Reset();

            disposables = new CompositeDisposable
            {
                Disposable.Create(Clock.Reset)
            };

            var configuration = new Configuration()
                .UseSqlEventStore(c => c.UseConnectionString(TestDatabases.EventStore.ConnectionString))
                .UseSqlStorageForScheduledCommands(c => c.UseConnectionString(TestDatabases.CommandScheduler.ConnectionString));

            Configure(configuration);

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);

            orderRepository = configuration.Repository<Order>();
            accountRepository = configuration.Repository<CustomerAccount>();
            clockTrigger = configuration.SchedulerClockTrigger();
            clockRepository = configuration.SchedulerClockRepository();
            clockRepository.CreateClock(clockName, Clock.Now());
        }
        public void SetUp()
        {
            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            clockName = Any.CamelCaseName();
            targetId = Any.Word();
            target = new CommandTarget(targetId);
            store = new InMemoryStore<CommandTarget>(
                _ => _.Id,
                id => new CommandTarget(id))
            {
                target
            };

            CommandSchedulerDbContext.NameOrConnectionString =
                @"Data Source=(localdb)\MSSQLLocalDB; Integrated Security=True; MultipleActiveResultSets=False; Initial Catalog=ItsCqrsTestsCommandScheduler";

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseDependency<IStore<CommandTarget>>(_ => store)
                .UseDependency<GetClockName>(c => _ => clockName)
                .TraceScheduledCommands();

            scheduler = configuration.CommandScheduler<CommandTarget>();

            Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
        public void SetUp()
        {
            // disable authorization
            Command<Order>.AuthorizeDefault = (o, c) => true;
            Command<CustomerAccount>.AuthorizeDefault = (o, c) => true;

            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            customerAccountId = Any.Guid();

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseInMemoryEventStore();

            customerRepository = configuration.Repository<CustomerAccount>();
            orderRepository = configuration.Repository<Order>();

            customerRepository.Save(new CustomerAccount(customerAccountId).Apply(new ChangeEmailAddress(Any.Email())));

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
        public IObservable<Unit> SendMessage(string message, IScheduler scheduler)
        {
            return Observable.Create<Unit>(observer =>
            {
                var disposable = new CompositeDisposable();
                var buffer = Encoding.UTF8.GetBytes(message);
                connectionToken.SocketEvent.SetBuffer(buffer, 0, buffer.Length);

                var disposableCompletedSubscription = connectionToken.SocketEvent.Completed.Subscribe(_ =>
                {
                    SendNotificationToObserver(observer, connectionToken.SocketEvent);
                });

                var disposableActions = scheduler.Schedule(() =>
                {
                    if (!connectionToken.Socket.SendAsync(connectionToken.SocketEvent))
                    {
                        SendNotificationToObserver(observer, connectionToken.SocketEvent);
                    }
                });

                disposable.Add(disposableCompletedSubscription);
                disposable.Add(disposableActions);

                return disposable;
            });
        }
Exemple #8
0
        public void SetUp()
        {
            disposables = new CompositeDisposable();
            telemetryEvents = new List<Telemetry>();

            disposables.Add(Log.TelemetryEvents().Subscribe(e => { telemetryEvents.Add(e); }));
        }
        public void SetUp()
        {
            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseInMemoryEventStore(traceEvents: true);

            itRepo = configuration.Repository<MarcoPoloPlayerWhoIsIt>();

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
        public IDisposable Subscribe(ReactiveSpace spaceListener)
        {
            CompositeDisposable subscriptions = new CompositeDisposable();
            subscriptions.Add(spaceListener
                                .LockedHands()
                                .ObserveOn(UI)
                                .Subscribe(o =>
                                {
                                    HandsCount++;
                                }));

            subscriptions.Add(spaceListener
                                .LockedHands()
                                .Select(o =>
                                        o
                                        .ObserveOn(UI)
                                        .Subscribe(oo =>
                                        {
                                        }, () =>
                                        {
                                            HandsCount--;
                                        }))
                                .Subscribe());
            subscriptions.Add(SubscribeCore(spaceListener));
            subscriptions.Add(Disposable.Create(()=>HandsCount = 0));
            return subscriptions;
        }
 public void Order()
 {
     // It is time-dependent test (i.e. lengthy and inconsistent), which is not very good but we cannot use HistoricalScheduler to test it...
     var s = Scheduler.ThreadPool;
     var l = new List<int> ();
     var dis = new CompositeDisposable ();
     try {
         dis.Add (s.Schedule (() => { Thread.Sleep (1200); l.Add (1); }));
         dis.Add (s.Schedule (() => { Thread.Sleep (800); l.Add (2); }));
         dis.Add (s.Schedule (() => { Thread.Sleep (50); l.Add (3); }));
         Thread.Sleep (1500);
         Assert.AreEqual (new int [] {3, 2, 1}, l.ToArray (), "#1");
     } finally {
         dis.Dispose ();
     }
 }
        public GherkinFileClassifier(ITextBuffer buffer)
        {
            var snapshot = buffer.CurrentSnapshot;
            _spans = new List<ClassificationSpan>();
            _listeners = new CompositeDisposable();

            _parser = buffer.Properties.GetProperty<GherkinFileEditorParser>(typeof(GherkinFileEditorParser));

            _listeners.Add(_parser.IsParsing.Where(isParsing => isParsing).Subscribe(b => _spans.Clear()));
            _listeners.Add(_parser.IsParsing.Where(isParsing => !isParsing).Subscribe(b => PublishClassificationEvents()));

            _listeners.Add(_parser
                            .ParserEvents
                            .Select(f => SelectClassifiable(f, snapshot))
                            .Subscribe((spans => _spans.AddRange(spans))));
        }
        public void SetUp()
        {
            eventStoreDbTest = new EventStoreDbTest();
            clockName = Any.CamelCaseName();

            Clock.Reset();

            disposables = new CompositeDisposable
            {
                Disposable.Create(() => eventStoreDbTest.TearDown()),
                Disposable.Create(Clock.Reset)
            };

            var bus = new FakeEventBus();
            orderRepository = new SqlEventSourcedRepository<Order>(bus);
            accountRepository = new SqlEventSourcedRepository<CustomerAccount>(bus);

            var configuration = new Configuration();
            configuration.UseEventBus(bus)
                         .UseDependency<IEventSourcedRepository<Order>>(t => orderRepository)
                         .UseDependency<IEventSourcedRepository<CustomerAccount>>(t => accountRepository);

            ConfigureScheduler(configuration);

            disposables.Add(ConfigurationContext.Establish(configuration));

            Console.WriteLine(new { clockName });

            clockTrigger = configuration.Container.Resolve<ISchedulerClockTrigger>();
            clockRepository = configuration.Container.Resolve<ISchedulerClockRepository>();
            clockRepository.CreateClock(clockName, Clock.Now());
        }
        protected override IDisposable SubscribeCore(ReactiveSpace spaceListener)
        {
            CompositeDisposable subscriptions = new CompositeDisposable();

            subscriptions.Add(spaceListener
                .LockedHands()
                .ObserveOn(UI)
                .SelectMany(h => h
                                .Select(hh => new
                                {
                                    Group = h,
                                    Hand = hh
                                }))
                .Subscribe(h =>
                {
                    var diff = 1000 + (h.Hand.PalmPosition.y - h.Group.Key.PalmPosition.y);
                    var bin = (int)(diff / MinInterval);
                    if(bin < PreviousBin)
                    {
                        if(OnMoveDown != null)
                            OnMoveDown();
                    }
                    if(bin > PreviousBin)
                    {
                        if(OnMoveUp != null)
                            OnMoveUp();
                    }
                    PreviousBin = bin;
                }));

            return subscriptions;
        }
Exemple #15
0
        private static void CompositeDisposable()
        {
            Demo.DisplayHeader("The CompositeDisposable - groups multiple disposables and dispose them together");

            var compositeDisposable = new CompositeDisposable(
                Disposable.Create(() => Console.WriteLine("1st disposed")),
                Disposable.Create(() => Console.WriteLine("2nd disposed")));

            compositeDisposable.Dispose();

            //The same can also be written using the Add() method
            compositeDisposable = new CompositeDisposable();
            compositeDisposable.Add(Disposable.Create(() => Console.WriteLine("1st disposed")));
            compositeDisposable.Add(Disposable.Create(() => Console.WriteLine("2nd disposed")));

            compositeDisposable.Dispose();
        }
Exemple #16
0
        public TimelineModel(Func<TwitterStatus, bool> evaluator,
                             Func<long?, int, bool, IObservable<TwitterStatus>> fetcher)
        {
            _fetcher = fetcher;
            _statusIdCache = new AVLTree<long>();
            _disposable = new CompositeDisposable();

            // add handler
            _disposable.Add(StatusStore.StatusPublisher
                                       .Where(sn => sn.IsAdded && evaluator(sn.Status))
                                       .Select(s => s.Status)
                                       .Subscribe(AddStatus));
            // remove handler
            _disposable.Add(StatusStore.StatusPublisher
                                       .Where(sn => !sn.IsAdded || !evaluator(sn.Status))
                                       .Select(s => s.StatusId)
                                       .Subscribe(RemoveStatus));
        }
 public void Order()
 {
     // It is time-dependent test (i.e. lengthy and inconsistent), which is not very good but we cannot use HistoricalScheduler to test it...
     var s = Scheduler.TaskPool;
     var l = new List<int> ();
     var dis = new CompositeDisposable ();
     try {
         // If the tasks do not run long enough, the (Task) scheduler will not use separate Threads,
         // therefore Thread.Sleep(x) will block not only current task, but also tasks scheduled to run
         // in the same Thread
         dis.Add (s.Schedule (() => { Thread.Sleep (2400); l.Add (1); }));
         dis.Add (s.Schedule (() => { Thread.Sleep (1600); l.Add (2); }));
         dis.Add (s.Schedule (() => { Thread.Sleep (50); l.Add (3); }));
         Thread.Sleep (2500);
         Assert.AreEqual (new int [] {3, 2, 1}, l.ToArray (), "#1");
     } finally {
         dis.Dispose ();
     }
 }
        public override void SetUp()
        {
            base.SetUp();

            schedulerActivity = new List<IScheduledCommand>();

            using (VirtualClock.Start(DateTimeOffset.Now.AddMonths(1)))
            {
                disposables = new CompositeDisposable();
                Settings.Sources = new ISettingsSource[] { new ConfigDirectorySettings(@"c:\dev\.config") }.Concat(Settings.Sources);

                serviceBusSettings = Settings.Get<ServiceBusSettings>();
                serviceBusSettings.NamePrefix = "itscqrstests";
                serviceBusSettings.ConfigureQueue = q => { q.AutoDeleteOnIdle = TimeSpan.FromMinutes(15); };

                var clockName = Any.Paragraph(4);

                var configuration = new Configuration()
                    .UseSqlEventStore()
                    .UseDependency<GetClockName>(_ => @event => clockName)
                    .UseSqlStorageForScheduledCommands()
                    .AddToCommandSchedulerPipeline<Order>(
                        schedule: async (cmd, next) =>
                        {
                            await next(cmd);
                            schedulerActivity.Add(cmd);
                        },
                        deliver: async (cmd, next) =>
                        {
                            await next(cmd);
                            schedulerActivity.Add(cmd);
                        });

                queueSender = new ServiceBusCommandQueueSender(serviceBusSettings)
                {
                    MessageDeliveryOffsetFromCommandDueTime = TimeSpan.FromSeconds(30)
                };

                disposables.Add(queueSender.Messages.Subscribe(s => Console.WriteLine("[ServiceBusCommandQueueSender] " + s.ToJson())));
                disposables.Add(configuration);
                disposables.Add(ConfigurationContext.Establish(configuration));
            }
        }
        public void SetUp()
        {
            eventStoreDbTest = new EventStoreDbTest();
            clockName = Any.CamelCaseName();

            VirtualClock.Start();

            disposables = new CompositeDisposable
            {
                Disposable.Create(() => eventStoreDbTest.TearDown())
            };

            var configuration = new Configuration();

            Configure(configuration);

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
        public IObservable<Stream> SafeOpenFileAsync(string path, FileMode mode, FileAccess access, FileShare share, IScheduler scheduler)
        {
            return Observable.Create<Stream>(subj =>
            {
                var disp = new CompositeDisposable();
                IsolatedStorageFile fs = null;
                try
                {
                    fs = IsolatedStorageFile.GetUserStoreForApplication();
                    disp.Add(fs);
                    disp.Add(Observable.Start(() => fs.OpenFile(path, mode, access, share), RxApp.TaskpoolScheduler).Select(x => (Stream)x).Subscribe(subj));
                }
                catch(Exception ex)
                {
                    subj.OnError(ex);
                }

                return disp;
            });
        }
        public IObservable<Stream> OpenFileForWriteAsync(string path, IScheduler scheduler)
        {
            return Observable.Create<Stream>(subj =>
            {
                var disp = new CompositeDisposable();
                IsolatedStorageFile fs = null;
                try
                {
                    fs = IsolatedStorageFile.GetUserStoreForApplication();
                    disp.Add(fs);
                    disp.Add(Observable.Start(() => fs.OpenFile(path, FileMode.Create, FileAccess.Write, FileShare.None), BlobCache.TaskpoolScheduler).Subscribe(subj));
                }
                catch (Exception ex)
                {
                    subj.OnError(ex);
                }

                return disp;
            });
        }
        /// <summary>
        ///      Subscribes an event handler to events published on the bus.
        /// </summary>
        /// <param name="bus">The bus to whose events the handler will be subscribed.</param>
        /// <param name="handlers">The handlers to be subscribed to the bus.</param>
        /// <returns>
        ///     A disposable that can be disposed in order to cancel the subscriptions.
        /// </returns>
        public static IDisposable Subscribe(this IEventBus bus, params object[] handlers)
        {
            if (handlers == null || !handlers.Any())
            {
                return Disposable.Empty;
            }

            var disposable = new CompositeDisposable();
            handlers.ForEach(handler => disposable.Add(bus.Subscribe(handler)));
            return disposable;
        }
        public void SetUp()
        {
            Command<Order>.AuthorizeDefault = (order, command) => true;

            disposables = new CompositeDisposable();

            var configuration = new Configuration()
                .UseInMemoryEventStore()
                .UseInMemoryCommandScheduling();
            disposables.Add(ConfigurationContext.Establish(configuration));
        }
    public static void Run()
    {
      var systems = new[] { "A", "B", "C" }.Select(CreateExternalSystem);
      var observables = systems.Select(s => s.ObserveHealth()).Select(obs => obs.DistinctUntilChanged(c => c.IsAvailable)).ToList();
      var disposable = new CompositeDisposable();

      // observe independently
      disposable.Add(new CompositeDisposable(observables.Select(c => c.Subscribe(PrintHealthCheck))));

      // merge
      var merged = Observable.Empty<HealthCheck>();
      disposable.Add(merged.Subscribe(PrintHealthCheck));

      // combine
      var combined = Observable.Empty<IEnumerable<HealthCheck>>();

      disposable.Add(combined.Subscribe(e => Console.WriteLine("Combined: " + string.Join(", ", e.Select(c => $"{c.ExternalSystemName}={c.IsAvailable}")))));

      Console.ReadKey();
      disposable.Dispose();
    }
        public override void SetUp()
        {
            base.SetUp();

            using (VirtualClock.Start(DateTimeOffset.Now.AddMonths(1)))
            {
                disposables = new CompositeDisposable();
                Settings.Sources = new ISettingsSource[] { new ConfigDirectorySettings(@"c:\dev\.config") }.Concat(Settings.Sources);

                serviceBusSettings = Settings.Get<ServiceBusSettings>();
                serviceBusSettings.NamePrefix = "itscqrstests";
                serviceBusSettings.ConfigureQueue = q =>
                {
                    q.AutoDeleteOnIdle = TimeSpan.FromMinutes(15);
                };

                bus = new FakeEventBus();
                orderRepository = new SqlEventSourcedRepository<Order>(bus);

                var configuration = new Configuration()
                    .UseSqlEventStore(() => new EventStoreDbContext())
                    .UseEventBus(bus)
                    .UseSqlCommandScheduling()
                    .UseDependency<IEventSourcedRepository<Order>>(t => orderRepository);

                var clockName = Any.Paragraph(4);
                scheduler = new SqlCommandScheduler(configuration) { GetClockName = @event => clockName };

                queueSender = new ServiceBusCommandQueueSender(serviceBusSettings)
                {
                    MessageDeliveryOffsetFromCommandDueTime = TimeSpan.FromSeconds(30)
                };

                disposables.Add(scheduler.Activity.Subscribe(s => Console.WriteLine("SqlCommandScheduler: " + s.ToJson())));
                disposables.Add(queueSender.Messages.Subscribe(s => Console.WriteLine("ServiceBusCommandQueueSender: " + s.ToJson())));
                disposables.Add(bus.Subscribe(scheduler));
                disposables.Add(configuration);
                disposables.Add(ConfigurationContext.Establish(configuration));
            }
        }
Exemple #26
0
        public static IObservable<Position> GetPosition(bool includeHeading = false)
        {
            if (Implementation != null) {
                return Implementation.GetPosition(includeHeading);
            }

            #if !WP7 && !WP8
            var ret = Observable.Create<Position>(subj => {
                var geo = new Geolocator();
                var cts = new CancellationTokenSource();
                var disp = new CompositeDisposable();

                if (!geo.IsGeolocationAvailable || !geo.IsGeolocationEnabled) {
                    return Observable.Throw<Position>(new Exception("Geolocation isn't available")).Subscribe(subj);
                }

                disp.Add(new CancellationDisposable(cts));
                disp.Add(geo.GetPositionAsync(cts.Token, includeHeading).ToObservable().Subscribe(subj));
                return disp;
            }).Multicast(new AsyncSubject<Position>());
            #else
            // NB: Xamarin.Mobile.dll references CancellationTokenSource, but
            // the one we have comes from the BCL Async library - if we try to
            // pass in our type into the Xamarin library, it gets confused.
            var ret = Observable.Create<Position>(subj => {
                var geo = new Geolocator();
                var disp = new CompositeDisposable();

                if (!geo.IsGeolocationAvailable || !geo.IsGeolocationEnabled) {
                    return Observable.Throw<Position>(new Exception("Geolocation isn't available")).Subscribe(subj);
                }

                disp.Add(geo.GetPositionAsync(Int32.MaxValue, includeHeading).ToObservable().Subscribe(subj));
                return disp;
            }).Multicast(new AsyncSubject<Position>());
            #endif

            return ret.RefCount();
        }
Exemple #27
0
        static InputModel()
        {
            _disposables = new CompositeDisposable();
            _core = new InputCoreModel();
            _accounts = new AccountSelectorModel(_core);

            // link property changing
            var icmpc = new PropertyChangedEventListener(_core);
            icmpc.RegisterHandler(() => _core.CurrentInputData,
                                (o, e) => _accounts.CurrentInputDataChanged());
            _disposables.Add(icmpc);
            SetEventPropagation();
        }
 public async Task<IObservable<ArmaServerInfo>> GetServers(CancellationToken ct, ServerFilterWrap filter) {
     var dsp = new CompositeDisposable();
     // Apparently we get null ServerInfo (not even endpoints :S)
     var obs = ServerResponses
         .TakeUntil(RefreshComplete)
         .Select(x => x.ServerInfo == null ? null : ArmaServerInfo.FromWrap(x.ServerIndex, x.ServerInfo))
         .Where(x => x != null)
         .Replay();
     dsp.Add(obs.Connect());
     obs.Subscribe(_ => { }, x => dsp.Dispose(), dsp.Dispose, ct);
     ct.Register(dsp.Dispose);
     await GetServerInfo(filter).ConfigureAwait(false);
     return obs;
 }
        public void SetUp()
        {
            // disable authorization
            Command<Order>.AuthorizeDefault = (o, c) => true;
            Command<CustomerAccount>.AuthorizeDefault = (o, c) => true;

            disposables = new CompositeDisposable();

            var configurationContext = ConfigurationContext
                .Establish(new Configuration()
                    .UseInMemoryEventStore()
                    .IgnoreScheduledCommands());
            disposables.Add(configurationContext);
        }
 private IConnectableObservable<ArmaServerInfo> PrepareListener(CancellationToken ct, bool inclRules = false) {
     var dsp = new CompositeDisposable();
     var obs = BuildListener(dsp);
     if (inclRules)
         obs = obs
             .SelectMany(async si => {
                 await UpdateRules(si, ct).ConfigureAwait(false);
                 return si;
             });
     var theObs = obs.Select(x => x.Info)
         .Replay();
     dsp.Add(theObs.Connect());
     theObs.Subscribe(_ => { }, x => dsp.Dispose(), dsp.Dispose, ct);
     ct.Register(dsp.Dispose);
     return theObs;
 }