/// <summary>
        /// Creates an observable for smart card events.
        /// </summary>
        /// <param name="factory">Factory to use for <see cref="ISCardMonitor"/> creation.</param>
        /// <param name="scope">Scope of the establishment. This can either be a local or remote connection.</param>
        /// <param name="readerNames">Name of the smart card reader that shall be monitored.</param>
        /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
        /// <returns></returns>
        public static IObservable <MonitorEvent> CreateObservable(this IMonitorFactory factory, SCardScope scope,
                                                                  IEnumerable <string> readerNames, IScheduler scheduler = null)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            if (readerNames == null)
            {
                throw new ArgumentNullException(nameof(readerNames));
            }

            return(Observable.Create <MonitorEvent>(obs => {
                var monitor = factory.Create(scope);
                var useScheduler = scheduler ?? Scheduler.ForCurrentContext();

                var readers = readerNames
                              .Where(name => !string.IsNullOrWhiteSpace(name))
                              .ToArray();

                var subscription = monitor
                                   .ObserveEvents(useScheduler)
                                   .Subscribe(obs);

                monitor.Start(readers);

                return new CompositeDisposable(subscription, monitor);
            }));
        }
Exemple #2
0
 public WordTransformerWithMonitorUnderTest(
     ITransformationTraversalWithMonitor traversal,
     ITransformationNodeFactory nodeFactory,
     IWordModulator wordModulator,
     IMonitorFactory monitorFactory)
     : base(traversal, nodeFactory, wordModulator, monitorFactory)
 {
 }
Exemple #3
0
 public ThreadWrangler(IDataActions dataActions, IApplicationSettings applicationSettings, IMonitorFactory monitorFactory, IMonitorJobActions monitorJobActions)
 {
     _dataActions              = dataActions;
     _applicationSettings      = applicationSettings;
     _monitorFactory           = monitorFactory;
     _monitorJobActions        = monitorJobActions;
     _manualResetEvent         = new ManualResetEvent(false);
     _theServiceShouldContinue = true;
 }
 public void SetUp()
 {
     _fakeMonitorFactory = Substitute.For <IMonitorFactory>();
     _fakeFileMonitor    = Substitute.For <IFileMonitor>();
     _fakeMonitorFactory.CreateFileMonitor().Returns(_fakeFileMonitor);
     _fakeProjectionFolderCreator   = Substitute.For <IProjectionFolderCreator>();
     _fakeProjectionPipelineFactory = Substitute.For <IProjectionPipelineFactory>();
     _uut = new SubfolderController(_fakeProjectionFolderCreator, _fakeMonitorFactory,
                                    _fakeProjectionPipelineFactory);
 }
 public ProductsMonitorService(IDateTimeNow dateTimeNow)
 {
     _dateTimeNow = dateTimeNow;
     _modelPortfolioRepository = new ModelPortfolioRepository();
     _behaviourFactory         = new BehaviourFactory();
     _productRepository        = new ProductRepository(_modelPortfolioRepository, _behaviourFactory, _dateTimeNow);
     _rebalancerHandler        = new RebalanceHandler(_behaviourFactory);
     _payoutHandler            = new PayoutHandler(_behaviourFactory);
     _monitorFactory           = new MonitorFactory(_dateTimeNow, _rebalancerHandler, _payoutHandler);
     _monitorHandler           = new MonitorHandler(_monitorFactory);
 }
Exemple #6
0
 public static IServiceEndpoint <TMessage, TCommand, TEvent, TRequest, TResponse> CreateMonitoringProxy <TMessage, TCommand, TEvent, TRequest, TResponse>(
     this IServiceEndpoint <TMessage, TCommand, TEvent, TRequest, TResponse> endpoint,
     IMonitorFactory <TMessage> monitorFactory)
     where TMessage : class
     where TCommand : TMessage
     where TEvent : TMessage
     where TRequest : TMessage
     where TResponse : TMessage
 {
     return(new ServiceEndpointMonitoringProxy <TMessage, TCommand, TEvent, TRequest, TResponse>(endpoint, monitorFactory));
 }
 /// <summary>
 /// Creates an observable for smart card events.
 /// </summary>
 /// <param name="factory">Factory to use for <see cref="ISCardMonitor"/> creation.</param>
 /// <param name="scope">Scope of the establishment. This can either be a local or remote connection.</param>
 /// <param name="readerName">Name of the smart card reader that shall be monitored.</param>
 /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
 /// <returns></returns>
 public static IObservable <MonitorEvent> CreateObservable(this IMonitorFactory factory, SCardScope scope, string readerName, IScheduler scheduler = null)
 {
     if (factory == null)
     {
         throw new ArgumentNullException(nameof(factory));
     }
     if (readerName == null)
     {
         throw new ArgumentNullException(nameof(readerName));
     }
     return(factory.CreateObservable(scope, new[] { readerName }, scheduler));
 }
        public void SetUp()
        {
            _fakeFolderMonitor       = Substitute.For <IMonitor>();
            _fakeMonitorFactory      = Substitute.For <IMonitorFactory>();
            _fakeSubfolderController = Substitute.For <ISubfolderController>();
            _fakeMonitorFactory.CreateFolderMonitor().Returns(_fakeFolderMonitor);

            var configuration = CreateDefaultConfiguration();

            _paths = configuration.Paths;
            Configuration.ConfigurationManager.OverrideConfiguration(configuration, false);

            _uut = new BaseFolderController(_fakeMonitorFactory, _fakeSubfolderController);
        }
Exemple #9
0
        public WordTransformerWithMonitor(
            ITransformationTraversalWithMonitor traversal,
            ITransformationNodeFactory nodeFactory,
            IWordModulator wordModulator,
            IMonitorFactory monitorFactory)
            : base(traversal, nodeFactory, wordModulator)
        {
            if (monitorFactory == null)
            {
                throw new ArgumentNullException(nameof(monitorFactory));
            }

            this.generatedWordsCounter = monitorFactory.OpenPerformanceCounter("New Words per Word");
            this.processedNodesCounter = monitorFactory.OpenPerformanceCounter("New Words per Word - Base");
        }
Exemple #10
0
        public WordDictionaryWithMonitor(IWordDictionary core, IMonitorFactory monitorFactory)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }
            if (monitorFactory == null)
            {
                throw new ArgumentNullException(nameof(monitorFactory));
            }

            this.core = core;

            this.wordTestCount = monitorFactory.OpenPerformanceCounter("Word Hit Ratio - Base");
            this.wordHitCount  = monitorFactory.OpenPerformanceCounter("Word Hit Ratio");
        }
        private void SubscribeToReaderEvents(IMonitorFactory monitorFactory, IReadOnlyCollection <string> readerNames)
        {
            _subscription?.Dispose();

            if (readerNames.Count <= 0)
            {
                return;
            }

            _subscription = monitorFactory
                            .CreateObservable(SCardScope.System, readerNames)
                            .Do(ev => EventHistory.AddOnScheduler(ev)) // Always add elements using the UI scheduler!
                            .Subscribe(
                onNext: _ => { },
                onError: OnError);
        }
        public TransformationTraversalWithMonitor(ITransformationTraversal core, IMonitorFactory monitorFactory)
        {
            if (core == null)
            {
                throw new ArgumentNullException(nameof(core));
            }
            if (monitorFactory == null)
            {
                throw new ArgumentNullException(nameof(monitorFactory));
            }

            this.core = core;

            this.backlogCount    = monitorFactory.OpenPerformanceCounter("Traversal Backlog");
            this.rateOfEmbark    = monitorFactory.OpenPerformanceCounter("Traversal Embark per Second");
            this.rateOfDisembark = monitorFactory.OpenPerformanceCounter("Traversal Disembark per Second");
        }
Exemple #13
0
 void LoadAppSettings()
 {
     try
     {
         _applicationSettings = new ApplicationSettings();
         _dataActions         = new DataActions(_applicationSettings);
         _timeActions         = new TimeActions();
         _emailActions        = new EmailActions(_applicationSettings);
         _monitorJobActions   = new MonitorJobActions(_timeActions, _applicationSettings);
         _monitorFactory      = new MonitorFactory(_emailActions, _timeActions);
     }
     catch (Exception ex)
     {
         Log.ErrorFormat("monitoryService was unable to create all the startup objects it needs to run. The exception was '{0}'", ex);
         throw;
     }
 }
        public MainWindowViewModel(IContextFactory contextFactory, IMonitorFactory monitorFactory)
        {
            Readers                  = new ReactiveCollection <string>().AddTo(_disposables);
            EventHistory             = new ReactiveCollection <MonitorEvent>().AddTo(_disposables);
            RefreshReaderListCommand = new ReactiveCommand().AddTo(_disposables);
            ClearEventListCommand    = new ReactiveCommand().AddTo(_disposables);

            RefreshReaderListCommand
            .Select(_ => GetReaderNames(contextFactory))
            .Do(UpdateReaderList)
            .Do(readerNames => SubscribeToReaderEvents(monitorFactory, readerNames))
            .Subscribe()
            .AddTo(_disposables);

            ClearEventListCommand
            .Do(_ => EventHistory.ClearOnScheduler())
            .Subscribe()
            .AddTo(_disposables);
        }
        public void Run()
        {
            Console.Write("what product information is required(LED, LCD, CRT) : ");
            string product = Console.ReadLine();

            IMonitorFactory factory = null;
            IMonitor        inputs  = null;

            if (product == "LED")
            {
                var fact = (IFactory <ILEDFactory>)_services.GetService(typeof(IFactory <ILEDFactory>));
                inputs  = new LEDMonitor(10000, "1968X1360");
                factory = fact.Create();
            }

            else if (product == "LCD")
            {
                var fact = (IFactory <ILCDFactory>)_services.GetService(typeof(IFactory <ILCDFactory>));
                inputs  = new LCDMonitor(9000, "1688X1180");
                factory = fact.Create();
            }
            else if (product == "CRT")
            {
                var fact = (IFactory <ICRTFactory>)_services.GetService(typeof(IFactory <ICRTFactory>));
                inputs  = new CRTMonitor(9000, "1688X1180");
                factory = fact.Create();
            }
            else
            {
                Console.Write("Invalid Input !!!");
                Console.ReadKey();
                return;
            }

            IMonitor typeofMonitor = factory.GetMonitor(inputs);

            Console.WriteLine(typeofMonitor.ToString());

            Console.ReadKey();
        }
        /// <summary>
        /// Creates an observable for smart card events.
        /// </summary>
        /// <param name="factory">Factory to use for <see cref="ISCardMonitor"/> creation.</param>
        /// <param name="scope">Scope of the establishment. This can either be a local or remote connection.</param>
        /// <param name="readerNames">Name of the smart card reader that shall be monitored.</param>
        /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
        /// <returns></returns>
        public static IObservable <MonitorEvent> CreateObservable(this IMonitorFactory factory, SCardScope scope, IEnumerable <string> readerNames, IScheduler scheduler = null)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            if (readerNames == null)
            {
                throw new ArgumentNullException(nameof(readerNames));
            }

            var useScheduler = scheduler ?? Scheduler.ForCurrentContext();

            IObservable <MonitorEvent> events = null;
            var monitor = factory.Start(
                scope,
                readerNames,
                preStartMonitor => events = preStartMonitor.ObserveEvents(useScheduler)
                );

            return(Observable.Using(() => monitor, _ => events));
        }
Exemple #17
0
        public static void Main()
        {
            Console.WriteLine("Listen device attached/detached events. Press any key to stop.");


            // var deviceMonitor = DeviceMonitor

            var factory = DeviceMonitorFactory.Instance;

            monitorFactory = MonitorFactory.Instance;

            var subscriptionDev = factory
                                  .CreateObservable(SCardScope.System)
                                  .Select(GetEventAsPrintableText)
                                  .Do(Console.WriteLine)
                                  .Subscribe(
                onNext: _ => { },
                onError: OnError);

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
            subscriptionDev.Dispose();
        }
 public MonitorHandler(IMonitorFactory monitorFactory)
 {
     _monitorFactory = monitorFactory;
 }
Exemple #19
0
        public ServiceEndpointClientMonitoringProxy(IServiceEndpointClient <TMessage, TCommand, TEvent, TRequest, TResponse> endpointClient, IMonitorFactory <TMessage> monitorFactory)
        {
            if (endpointClient == null)
            {
                throw new NullReferenceException("endpointClient cannot be null");
            }
            if (monitorFactory == null)
            {
                throw new NullReferenceException("monitorFactory cannot be null");
            }

            _endpointClient = endpointClient;
            _monitor        = monitorFactory.Create(endpointClient.Name);
        }
 public ICanSpecifyLoggingOrCreate <TMessage, TCommand, TEvent, TRequest, TResponse> UsingMonitor(IMonitorFactory <TMessage> monitorFactory)
 {
     _monitorFactory = monitorFactory;
     return(this);
 }
Exemple #21
0
 public Item(string description, Dictionary <string, string> settings, IMonitorFactory factory)
 {
     Description = description;
     Settings    = settings;
     Factory     = factory;
 }
 public void SetUp()
 {
     _timeActions    = MockRepository.GenerateStub <ITimeActions>();
     _emailActions   = MockRepository.GenerateStub <IEmailActions>();
     _monitorFactory = new MonitorFactory(_emailActions, _timeActions);
 }
Exemple #23
0
 public BaseFolderController(IMonitorFactory monitorFactory, ISubfolderController subfolderController)
 {
     _subfolderController    = subfolderController;
     _folderMonitor          = monitorFactory.CreateFolderMonitor();
     _folderMonitor.Created += HandleNewFolder;
 }
Exemple #24
0
 public SubfolderController(IProjectionFolderCreator projectionFolderCreator, IMonitorFactory monitorFactory, IProjectionPipelineFactory projectionPipelineFactory)
 {
     _projectionFolderCreator   = projectionFolderCreator;
     _monitorFactory            = monitorFactory;
     _projectionPipelineFactory = projectionPipelineFactory;
 }
 public MeasurableUnitOfWork(IEnumerable<IDbContextManager> contextList, IMonitorFactory monitorFactory)
     : base(contextList)
 {
     this.monitorFactory = monitorFactory;
 }
Exemple #26
0
 public MeasurableUnitOfWork(IEnumerable <IDbContextManager> contextList, IMonitorFactory monitorFactory)
     : base(contextList)
 {
     this.monitorFactory = monitorFactory;
 }
Exemple #27
0
 // some external code would call this for each plugin that is found and
 // either loaded dynamically at runtime or a static list at compile time
 public void Add(Guid id, string description, Dictionary <string, string> settings, IMonitorFactory factory)
 {
     _list.Add(id, new Item(description, settings, factory));
     factory.RegisterContainerAndTypes(_container);
 }
 public ICanSpecifyLoggingOrCreate <TMessage, TCommand, TEvent, TRequest, TResponse> UsingConsoleMonitor(TimeSpan period, IScheduler scheduler = null)
 {
     _monitorFactory = new ConsoleTimerMonitorFactory <TMessage>(period, scheduler ?? Scheduler.Default);
     return(this);
 }
Exemple #29
0
 public MonitorService(ILog log, IRepository repository, IMonitorFactory monitorFactory)
 {
     _log            = log.ThrowIfNull(nameof(log));
     _repository     = repository.ThrowIfNull(nameof(repository));
     _monitorFactory = monitorFactory.ThrowIfNull(nameof(monitorFactory));
 }