public void Broadcasts_RegistersABroadcasterWithTheGivenInterface()
        {
            ISystemDefinition subsystem = new SystemDefinition();
            subsystem.Broadcasts<IListener>();

            Reciever reciever = new Reciever();
            subsystem.HasInstance(reciever).ListensTo<IListener>();
            subsystem.HasSingleton<Sender>().Provides<ISender>();

            ISender sender = subsystem.Get<ISender>();

            sender.SendMessage(2);
            sender.SendMessage(4);

            Assert.AreEqual(2, reciever.recieved[0]);
            Assert.AreEqual(4, reciever.recieved[1]);
        }
        public void ApplicationScopeObjects_MembersAreNotSerialized()
        {
            ISystemDefinition writeTimeSystem = new SystemDefinition();
            var writeTimeAdapter = new NDependencyInjectAdapter(writeTimeSystem);
            writeTimeSystem.HasInstance(new ClassB(1234))
                .Provides<IClassB>();
            var writeObject = new ClassA(writeTimeSystem.Get<IClassB>());
            var xmlText = SerializeAsXml(writeObject, writeTimeAdapter);

            Assert.IsFalse(xmlText.Contains("1234"));

            ISystemDefinition readTimeSystem = new SystemDefinition();
            var readTimeAdapter = new NDependencyInjectAdapter(readTimeSystem);
            var readTimeAppObject = new ClassB(3);
            readTimeSystem.HasInstance(readTimeAppObject)
                .Provides<IClassB>();
            var readObject = ReadXmlText<ClassA>(xmlText, readTimeAdapter, null, null);

            Assert.AreSame(readTimeAppObject, readObject.Value);
            Assert.AreEqual(3, readObject.Value.ValueA);
        }
Esempio n. 3
0
        public void ApplicationScopeObjects_MembersAreNotSerialized()
        {
            ISystemDefinition writeTimeSystem = new SystemDefinition();
            var writeTimeAdapter = new NDependencyInjectAdapter(writeTimeSystem);

            writeTimeSystem.HasInstance(new ClassB(1234))
            .Provides <IClassB>();
            var writeObject = new ClassA(writeTimeSystem.Get <IClassB>());
            var xmlText     = SerializeAsXml(writeObject, writeTimeAdapter);

            Assert.IsFalse(xmlText.Contains("1234"));

            ISystemDefinition readTimeSystem = new SystemDefinition();
            var readTimeAdapter   = new NDependencyInjectAdapter(readTimeSystem);
            var readTimeAppObject = new ClassB(3);

            readTimeSystem.HasInstance(readTimeAppObject)
            .Provides <IClassB>();
            var readObject = ReadXmlText <ClassA>(xmlText, readTimeAdapter, null, null);

            Assert.AreSame(readTimeAppObject, readObject.Value);
            Assert.AreEqual(3, readObject.Value.ValueA);
        }
Esempio n. 4
0
        public void Run()
        {
            ISystemDefinition system = new SystemDefinition();

            system.Broadcasts <IIncidentsListener>();
            system.Broadcasts <IIncidentChangeListener>();

            system.HasInstance(new NoeticTools.DotNetWrappers.Timer(new Timer())).Provides <ITimer>();

            system.HasSingleton <Scheduler>()
            .Provides <IScheduler>();

            system.HasSingleton <ScheduledEventFactory>()
            .Provides <IScheduledEventFactory>();

            system.HasSingleton <ImageResources>()
            .Provides <IImageResources>();

            system.HasInstance(new List <IPluginBuilder>())
            .Provides <List <IPluginBuilder> >();

            system.HasSubsystem(new IncidentsBuilder())
            .Provides <IIncidents>();

            string title;

            if (!applicationOptions.Simulate)
            {
                system.HasSingleton <Clock>()
                .Provides <IClock>();
                system.HasSingleton <HttpWebRequestFactory>()
                .Provides <IHttpWebRequestFactory>();
                title = "VicFireReader";
            }
            else
            {
                system.HasSubsystem(new SimulatorBuilder())
                .Provides <ISimulatedClock>()
                .Provides <IClock>()
                .Provides <IHttpWebRequestFactory>();

                title = "VicFireReader == SIMULATED ==";
            }

            system.HasSingleton <VicFireReaderSettings>()
            .Provides <VicFireReaderSettings>();

            system.HasSingleton <CFADataSet>()
            .Provides <ICFADataSet>();

            system.HasInstance(GetType().Assembly)
            .Provides <Assembly>();

            system.HasSingleton <PersistenceService>()
            .Provides <IPersistenceService>();

            system.HasSubsystem(new MainFormBuilder(title))
            .Provides <Form>()
            .Provides <IPluginHost>()
            .Provides <OptionsViewPlugin>()
            .Provides <IMenuStrip>()
            .Provides <IToolStrip>()
            .Provides <IStatusStrip>();

            system.Get <IPluginHost>().Register(new ToolStripMenuServicePlugIn(system.Get <IMenuStrip>()));
            system.Get <IPluginHost>().Register(new ToolBarServicePlugin(system.Get <IToolStrip>(), toolBarOdering));
            system.Get <IPluginHost>().Register(new StatusStripPlugin(system.Get <IStatusStrip>()));
            system.Get <IPluginHost>().Register(system.Get <OptionsViewPlugin>());

            system.HasSubsystem(new PluginsBuilder())
            .Provides <IPlugin[]>();

            system.Get <IPluginHost>().Register(system.Get <IPlugin[]>());

            system.Get <IScheduler>().Start();
            Application.Run(system.Get <Form>());
        }
Esempio n. 5
0
        public void Run()
        {
            ISystemDefinition system = new SystemDefinition();

            system.Broadcasts<IIncidentsListener>();
            system.Broadcasts<IIncidentChangeListener>();

            system.HasInstance(new NoeticTools.DotNetWrappers.Timer(new Timer())).Provides<ITimer>();

            system.HasSingleton<Scheduler>()
                .Provides<IScheduler>();

            system.HasSingleton<ScheduledEventFactory>()
                .Provides<IScheduledEventFactory>();

            system.HasSingleton<ImageResources>()
                .Provides<IImageResources>();

            system.HasInstance(new List<IPluginBuilder>())
                .Provides<List<IPluginBuilder>>();

            system.HasSubsystem(new IncidentsBuilder())
                .Provides<IIncidents>();

            string title;
            if (!applicationOptions.Simulate)
            {
                system.HasSingleton<Clock>()
                    .Provides<IClock>();
                system.HasSingleton<HttpWebRequestFactory>()
                    .Provides<IHttpWebRequestFactory>();
                title = "VicFireReader";
            }
            else
            {
                system.HasSubsystem(new SimulatorBuilder())
                    .Provides<ISimulatedClock>()
                    .Provides<IClock>()
                    .Provides<IHttpWebRequestFactory>();

                title = "VicFireReader == SIMULATED ==";
            }

            system.HasSingleton<VicFireReaderSettings>()
                .Provides<VicFireReaderSettings>();

            system.HasSingleton<CFADataSet>()
                .Provides<ICFADataSet>();

            system.HasInstance(GetType().Assembly)
                .Provides<Assembly>();

            system.HasSingleton<PersistenceService>()
                .Provides<IPersistenceService>();

            system.HasSubsystem(new MainFormBuilder(title))
                .Provides<Form>()
                .Provides<IPluginHost>()
                .Provides<OptionsViewPlugin>()
                .Provides<IMenuStrip>()
                .Provides<IToolStrip>()
                .Provides<IStatusStrip>();

            system.Get<IPluginHost>().Register(new ToolStripMenuServicePlugIn(system.Get<IMenuStrip>()));
            system.Get<IPluginHost>().Register(new ToolBarServicePlugin(system.Get<IToolStrip>(), toolBarOdering));
            system.Get<IPluginHost>().Register(new StatusStripPlugin(system.Get<IStatusStrip>()));
            system.Get<IPluginHost>().Register(system.Get<OptionsViewPlugin>());

            system.HasSubsystem(new PluginsBuilder())
                .Provides<IPlugin[]>();

            system.Get<IPluginHost>().Register(system.Get<IPlugin[]>());

            system.Get<IScheduler>().Start();
            Application.Run(system.Get<Form>());
        }