/// <summary>
 /// Alternate constructor for dependency injection
 /// </summary>
 public GridIndexController(IViewAgent va, IConfigurationAgent ca, IPositioner p)
 {
     viewAgent   = va;
     configAgent = ca;
     positioner  = p;
     positioner.StatusChanged += OnPositionerStatusChanged;
 }
예제 #2
0
        static int Main(string[] args)
        {
            Console.WriteLine("Sighting Overseer");

            var app = new CommandLineApplication
            {
                Name        = "Overseer",
                FullName    = "Heimdall Sighting Overseer",
                Description = "A Reactive Endpoint user to monitor sightings and trigger investigations"
            };

            app.OnExecute(() =>
            {
                var mqAgent = new RabbitMqConfigurationAgent()
                              .WithConsumer <SightingInvestigationConsumer <ReportedSighting> >();

                var agents  = new IConfigurationAgent[] { mqAgent };
                var modules = new IModule[] { new MongoModule(), new OverSeerModule() };

                using (new ServiceInitiator(agents, modules))
                {
                    Console.WriteLine("Overseer Started");
                    return(Console.Read());
                }
            });

            return(app.Execute(args));
        }
예제 #3
0
        /// <summary>
        /// the method load the agent using reflection and return an instance of agent
        /// to the caller
        /// </summary>
        /// <param name="agentName">name of the agent referenced in the configuration file</param>
        /// <returns>an agent object</returns>
        private IConfigurationAgent GetAgent(string agentName)
        {
            XmlNode             agentNode = configurationData.SelectSingleNode("//Agent[@name ='" + agentName + "']");
            Type                type      = Type.GetType(agentNode.Attributes["type"].Value);
            IConfigurationAgent agent     = (IConfigurationAgent)Activator.CreateInstance(type);

            //Initialize method setup the agent object with the parameter information specified
            //in the file that is needed for the agent to do its job
            agent.Initialize(agentNode);
            return(agent);
        }
예제 #4
0
        /// <summary>
        /// 方法使用反射加载代理,并返回一个代理实例
        /// 给调用者
        /// </summary>
        /// <param name="agentName">代理的名称</param>
        /// <returns>返回的代理对象</returns>
        private IConfigurationAgent GetAgent(string agentName)
        {
            //获得该名称的节点
            XmlNode agentNode = configurationData.SelectSingleNode("//Agent[@name ='" + agentName + "']");
            //获得该节点的类型
            Type type = Type.GetType(agentNode.Attributes["type"].Value);
            //创建该类型的代理实例
            IConfigurationAgent agent = (IConfigurationAgent)Activator.CreateInstance(type, null);

            //初始化方法设置的代理对象与指定的参数信息
            //在文件中所需要的代理来完成其工作
            agent.Initialize(agentNode);
            //返回代理对象
            return(agent);
        }
예제 #5
0
        public ShellWindowViewModel(IConfigurationService configurationService, CreateItemViewModel creator, HistoryListViewModel historyList, SettingsWindowManager settingsManager)
        {
            _settingsManager    = settingsManager;
            _configurationAgent = configurationService.GetConfigurationAgent <ShellConfiguration>(ApplicationConfigurations.ShellConfiguration, this);

            _subscriptions = _configurationAgent.Updated.ObserveOnDispatcher().Do(x => { RefreshConfig(); }).Subscribe();

            Creator     = creator;
            HistoryList = historyList;

            ShowSettingsCommand = ReactiveCommand.Create(() => { _settingsManager.ShowSettingsWindow(); });

            RefreshConfig();

            PropertyChanged += (sender, e) => { PersistConfig(); };
        }
예제 #6
0
        public void GridIndexTestInitialize()
        {
            // stub out a view agent and view DS
            viewAgent = MockRepository.GenerateStub <IViewAgent>();
            viewDS    = new CCViewDS();

            // when the controller calls viewAgent.get return this DS
            viewAgent.Stub(x => x.Get()).Return(viewDS);

            // stub out a config agent
            configAgent = MockRepository.GenerateStub <IConfigurationAgent>();

            // stub out a positioner
            positioner = MockRepository.GenerateStub <IPositioner>();

            // create the controller
            gridIndexingController = new GridIndexController(viewAgent, configAgent, positioner);
        }
예제 #7
0
        public CreateItemViewModel(IConfigurationService configService, IGeneratorService generator, IClipboardService clipboardService)
        {
            _generator        = generator;
            _clipboardService = clipboardService;

            _factoryMonitorConfigurationAgent = configService.GetConfigurationAgent <FactoryMonitorConfiguration>(CommonConfigurations.FactoryMonitorConfiguration, this);
            _factoryMonitorConfigurationAgent.Updated.Do(x => _factoryMonitorConfig = _factoryMonitorConfigurationAgent.Get()).Subscribe();
            _factoryMonitorConfig = _factoryMonitorConfigurationAgent.Get();

            _generatorConfigurations = configService.GetConfigurationAgent <GeneratorConfiguration>(CommonConfigurations.GeneratorConfiguration, this);
            _generatorConfigurations.Updated.ObserveOnDispatcher().Do(x => ConvertGeneratorConfigurations()).Subscribe();
            ConvertGeneratorConfigurations();

            CreateSelectedItemCommand = ReactiveCommand.Create(() =>
            {
                var instance = SelectedGeneratorConfiguration?.CreateInstance();

                if (_factoryMonitorConfig.EnableAutoCopy)
                {
                    instance?.SetToClipboard(_clipboardService);
                }
            });
        }
 /// <summary>
 /// Base Constructor
 /// </summary>
 public GridIndexController(Navigator navigator) : base(navigator)
 {
     viewAgent   = new CCViewAgent();
     configAgent = new CCConfigurationAgent();
     positioner  = new CCPositioner();
 }
        public SettingsPageGenerationViewModel(IConfigurationService configService, IGeneratorCatalogueService generatorCatalogueService)
        {
            _generatorCatalogueService = generatorCatalogueService;
            _generatorConfigurations   = configService.GetConfigurationAgent <GeneratorConfiguration>(CommonConfigurations.GeneratorConfiguration, this);

            AddConfigurationFromSelectedGeneratorCommand = ReactiveCommand.Create(() =>
            {
                if (SelectedGenerator == null)
                {
                    return;
                }

                var newConfig = SelectedGenerator.CreateConfigurationInstance();
                var vm        = ViewModelFromLocalConfiguration(newConfig);

                Configurations.Add(vm);

                if (SelectedConfiguration == null)
                {
                    SelectedConfiguration = Configurations.FirstOrDefault();
                }
            });

            RemoveSelectedConfigurationCommand = ReactiveCommand.Create(() =>
            {
                if (SelectedConfiguration == null)
                {
                    return;
                }

                var index = Configurations.IndexOf(SelectedConfiguration);

                Configurations.Remove(SelectedConfiguration);

                if (Configurations.Count > index && index >= 0)
                {
                    SelectedConfiguration = Configurations[index];
                }
                else
                {
                    SelectedConfiguration = Configurations.LastOrDefault();
                }
            });

            MoveDownSelectedConfigurationCommand = ReactiveCommand.Create(() =>
            {
                var index       = Configurations.IndexOf(SelectedConfiguration);
                var targetIndex = index + 1;

                if (targetIndex >= Configurations.Count)
                {
                    return;
                }

                var s = SelectedConfiguration;
                Configurations.Remove(s);
                Configurations.Insert(targetIndex, s);
                SelectedConfiguration = s;
            });

            MoveUpSelectedConfigurationCommand = ReactiveCommand.Create(() =>
            {
                var index       = Configurations.IndexOf(SelectedConfiguration);
                var targetIndex = index - 1;

                if (targetIndex < 0)
                {
                    return;
                }

                var s = SelectedConfiguration;
                Configurations.Remove(s);
                Configurations.Insert(targetIndex, s);
                SelectedConfiguration = s;
            });
        }
예제 #10
0
 public SettingsPageGeneralViewModel(IConfigurationService configService)
 {
     _shellConfigurationAgent          = configService.GetConfigurationAgent <ShellConfiguration>(ApplicationConfigurations.ShellConfiguration, this);
     _factoryMonitorConfigurationAgent = configService.GetConfigurationAgent <FactoryMonitorConfiguration>(CommonConfigurations.FactoryMonitorConfiguration, this);
 }
예제 #11
0
 public TransportConfigurator WithAgent(IConfigurationAgent agent)
 {
     _agents.Add(agent);
     return(this);
 }