Esempio n. 1
0
        public void TestActivityConfiguration()
        {
            Type  activityInterfaceType = typeof(ITask);
            ITang tang = TangFactory.GetTang();
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });

            cb.BindImplementation(GenericType <ITask> .Class, GenericType <HelloTask> .Class);
            cb.BindNamedParameter <TaskConfigurationOptions.Identifier, string>(
                GenericType <TaskConfigurationOptions.Identifier> .Class, "Hello Task");
            IConfiguration conf = cb.Build();

            ConfigurationFile.WriteConfigurationFile(conf, "TaskConf.txt");
            IDictionary <string, string> p = ConfigurationFile.FromFile("TaskConf.txt");

            ITang tang1 = TangFactory.GetTang();
            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Common, FileNames.Tasks });

            ConfigurationFile.AddConfigurationFromFile(cb1, "TaskConf.txt");
            IConfiguration conf1 = cb1.Build();

            IInjector injector    = tang1.NewInjector(conf1);
            var       activityRef = (ITask)injector.GetInstance(activityInterfaceType);

            Assert.NotNull(activityRef);
        }
Esempio n. 2
0
        public void TestTimerConfigurationWithClassHierarchy()
        {
            Type timerType = typeof(Timer);
            ClassHierarchyImpl classHierarchyImpl = new ClassHierarchyImpl(FileNames.Examples);

            ITang          tang = TangFactory.GetTang();
            IConfiguration conf = tang.NewConfigurationBuilder(classHierarchyImpl)
                                  .BindNamedParameter <Timer.Seconds, int>(GenericType <Timer.Seconds> .Class, "1")
                                  .Build();

            ConfigurationFile.WriteConfigurationFile(conf, "timerConfH.txt");
            IDictionary <string, string> p = ConfigurationFile.FromFile("timerConfH.txt");

            ITang tang1 = TangFactory.GetTang();
            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });

            ConfigurationFile.AddConfigurationFromFile(cb1, "timerConfH.txt");
            IConfiguration conf1 = cb1.Build();

            IInjector injector = tang1.NewInjector(conf1);
            var       timer    = (Timer)injector.GetInstance(timerType);

            Assert.NotNull(timer);
            timer.sleep();
        }
Esempio n. 3
0
        public void TestDocumentLoadNamedParameterConfiguration()
        {
            Type  documentedLocalNamedParameterType = typeof(DocumentedLocalNamedParameter);
            ITang tang = TangFactory.GetTang();
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });

            cb.BindNamedParameter <DocumentedLocalNamedParameter.Foo, string>(
                GenericType <DocumentedLocalNamedParameter.Foo> .Class, "Hello");
            IConfiguration conf = cb.Build();

            ConfigurationFile.WriteConfigurationFile(conf, "docLoadConf.txt");
            IDictionary <string, string> p = ConfigurationFile.FromFile("docLoadConf.txt");

            ITang tang1 = TangFactory.GetTang();
            ICsConfigurationBuilder cb1 = tang1.NewConfigurationBuilder(new string[] { FileNames.Examples });

            ConfigurationFile.AddConfigurationFromFile(cb1, "docLoadConf.txt");
            IConfiguration conf1 = cb1.Build();

            IInjector injector = tang1.NewInjector(conf1);
            var       doc      = (DocumentedLocalNamedParameter)injector.GetInstance(documentedLocalNamedParameterType);

            Assert.NotNull(doc);
            var s = doc.ToString();
        }
Esempio n. 4
0
        public void TestActivityConfig()
        {
            Type  activityInterfaceType = typeof(ITask);
            ITang tang = TangFactory.GetTang();
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples, FileNames.Common, FileNames.Tasks });

            cb.BindImplementation(GenericType <ITask> .Class, GenericType <HelloTask> .Class);
            IConfiguration conf = cb.Build();

            ConfigurationFile.WriteConfigurationFile(conf, "TaskConf.txt");
            IDictionary <string, string> p = ConfigurationFile.FromFile("TaskConf.txt");

            IInjector injector    = tang.NewInjector(new string[] { FileNames.Common, FileNames.Tasks }, "TaskConf.txt");
            var       activityRef = (ITask)injector.GetInstance(activityInterfaceType);

            Assert.IsNotNull(activityRef);
        }
Esempio n. 5
0
        public void TestTweetConfig()
        {
            Type  tweeterType          = typeof(Tweeter);
            ITang tang                 = TangFactory.GetTang();
            ICsConfigurationBuilder cb = tang.NewConfigurationBuilder(new string[] { FileNames.Examples });

            cb.BindImplementation(GenericType <ITweetFactory> .Class, GenericType <MockTweetFactory> .Class);
            cb.BindImplementation(GenericType <ISMS> .Class, GenericType <MockSMS> .Class);
            cb.BindNamedParameter <Tweeter.PhoneNumber, long>(GenericType <Tweeter.PhoneNumber> .Class, "8675309");
            IConfiguration conf = cb.Build();

            ConfigurationFile.WriteConfigurationFile(conf, "tweeterConf.txt");
            IDictionary <string, string> p = ConfigurationFile.FromFile("tweeterConf.txt");

            IInjector injector = tang.NewInjector(new string[] { FileNames.Examples }, "tweeterConf.txt");
            var       tweeter  = (Tweeter)injector.GetInstance(tweeterType);

            tweeter.sendMessage();
        }
Esempio n. 6
0
        public MainForm()
        {
            InitializeComponent();

            // get application settings
            if (!File.Exists(CONFIGURATION_FILE_PATH))
            {
                new ConfigurationFile().Save(CONFIGURATION_FILE_PATH);
            }
            _config = ConfigurationFile.FromFile(CONFIGURATION_FILE_PATH);

            lblStatus.Text = "Ready...";

            // register the hotkeys for buttons
            RegisterHotKey(this.Handle, (int)Keys.Q, (int)fsModifiers.Control, Keys.Q.GetHashCode());
            RegisterHotKey(this.Handle, (int)Keys.W, (int)fsModifiers.Control, Keys.W.GetHashCode());
            RegisterHotKey(this.Handle, (int)Keys.E, (int)fsModifiers.Control, Keys.E.GetHashCode());
            RegisterHotKey(this.Handle, (int)Keys.R, (int)fsModifiers.Control, Keys.R.GetHashCode());
        }