Inheritance: IStartConfiguration
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Startup"/> class.
 /// </summary>
 /// <param name="env">The injected Environment provider.</param>
 /// <param name="configuration">The injected configuration provider.</param>
 public Startup(IWebHostEnvironment env, IConfiguration configuration)
 {
     this.environment   = env;
     this.startupConfig = new StartupConfiguration(configuration, env);
     this.configuration = configuration;
     this.logger        = this.startupConfig.Logger;
 }
        private void InitMediaPlayer()
        {
            App.DebugLog("");
            var startupConfiguration = new StartupConfiguration()
            {
                AutoPlay   = !isPausedByUser,
                ResumeTime = lastPosition,
                FilePath   = filePath
            };

            foreach (var sub in videoItem.SubtitleFiles)
            {
                startupConfiguration.ExternalSubtitles.Add(new SubitlesConfig()
                {
                    FileUrl    = sub.FileUrl,
                    Delay      = sub.Delay,
                    Encoding   = sub.Encoding,
                    IsSelected = sub.IsSelected
                });
            }
            if (videoItem.IsFileSubtitleSelected)
            {
            }
            else
            {
                startupConfiguration.SelectedSubtitlesSpu = videoItem.SelectedSubtitlesId;
            }
            startupConfiguration.EmbeddedSubtitlesDelay = videoItem.EmbeddedSubtitlesDelay;

            VlcPlayerHelper.LoadFile(startupConfiguration);

            VlcPlayerHelper.MediaPlayer.TimeChanged   += MediaPlayer_TimeChanged;
            VlcPlayerHelper.MediaPlayer.SnapshotTaken += MediaPlayer_SnapshotTaken;
            VlcPlayerHelper.AspectRatioChanged        += VlcPlayerHelper_AspectRatioChanged;
        }
Esempio n. 3
0
        public void ShouldSetPassedArgumentsToArgumentsProperty()
        {
            var arguments = new[] { "arg1", "arg2" };
            StartupConfiguration startupConfiguration = new StartupConfiguration(arguments);

            Assert.Equal(arguments, startupConfiguration.Arguments);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            BsonSerializer.RegisterSerializer(typeof(DateTime), new DateTimeSerializer(DateTimeKind.Local, BsonType.DateTime));

            var serviceCollection = new ServiceCollection();

            StartupConfiguration.ConfigureServices(serviceCollection);
            StartupHandle.ConfigureServices(serviceCollection);

            try
            {
                var command = args[0];
                if (string.IsNullOrEmpty(command))
                {
                    return;
                }

                logger.Debug($"Program runing start args[0]:{command}");

                var handle = serviceCollection.BuildServiceProvider().GetServices <IHandle>().Where(item => item.Command == command).FirstOrDefault();
                handle.Execution(args);

                logger.Debug("Program runing completed...");
            }
            catch (Exception exception)
            {
                logger.Error(exception);
                throw exception;
            }
        }
        //private readonly ITypeCatalog _typeCatalog;


        public UnityServiceLocatorTests()
        {
            _serviceLocator = new UnityServiceLocator(new UnityContainer());
            StartupConfiguration.RunBootstrapper(_serviceLocator);

            //_typeCatalog = StartupConfiguration.GetTypeCatalog(_serviceLocator);
        }
Esempio n. 6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              UserManager <ApplicationUser> userManager,
                              RoleManager <IdentityRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            StartupConfiguration.Setup(app);
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            IdentityDataInitializer.SeedData(userManager, roleManager);

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Esempio n. 7
0
        public void ShouldSetCategoryNamesToSeedIfArgumentPassed()
        {
            // TODO Add test for cases when name provided without ':', when no names provided or several names provided.
            StartupConfiguration startupConfiguration = new StartupConfiguration(new[] { "seed:category-name" });

            Assert.Contains("seed:category-name", startupConfiguration.CategoryTokensToSeed);
        }
        public void ServiceCollection_IConfiguration_should_be_registered()
        {
            var serviceCollection = new ServiceCollection();
            var startupOptions    = new StartupConfiguration
            {
                ConfigurationPath = "TestsConfiguration/Bootstrap",
                Profile           = "profile1",
                ServiceCollection = serviceCollection
            };

            new ApplicationBuilder().Build(startupOptions);

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var sampleOptions = serviceProvider.GetService <SampleOptions>();

            sampleOptions.Should().NotBeNull();

            var configuration = serviceProvider.GetService <IConfiguration>();

            configuration.Should().NotBeNull();

            var configurationRoot = serviceProvider.GetService <IConfigurationRoot>();

            configurationRoot.Should().NotBeNull();
        }
        public void Complex1()
        {
            /*
             * {
             *  "ComplexObjectConfiguration": {
             *      "Name": "Complex",
             *      "Inner": {
             *          "Name": "InnerName",
             *          "Value": "InnerValue"
             *      }
             *  }
             * }
             */
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath  = "TestsConfiguration/Complex/complex1",
                ConfigurationTypes = new[] { typeof(ComplexObject) }
            };
            var serviceProvider = new ApplicationBuilder().BuildAndStart(startupOptions);

            var complexObject = serviceProvider.GetRequiredService <ComplexObject>();

            complexObject.Should().NotBeNull();
            complexObject.Name.Should().Be("Complex");
            complexObject.Inner.Should().NotBeNull();

            complexObject.Inner.Name.Should().Be("InnerName");
            complexObject.Inner.Value.Should().Be("InnerValue");
        }
Esempio n. 10
0
        public void ShouldSetConfigPathToPropertyValueIfItPassed()
        {
            StartupConfiguration startupConfiguration =
                new StartupConfiguration(new[] { ValidConfigurationProperty + ValidConfigurationFileName });

            Assert.Equal(GetFullPath(ValidConfigurationFileName), startupConfiguration.ConfigRootDir);
        }
Esempio n. 11
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // needed to load IP Rate limit configuration from appsettings.json
            services.AddOptions();

            var configuration = StartupConfiguration.Configure(Container, services);

            // needed to store IP rate limit counters and ip rules, as well as in-memory API caching
            services.AddMemoryCache();

            services.AddControllersWithViews();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/build";
            });

            StartupConfiguration.ConfigureIoC(Container, services);
            StartupConfiguration.ConfigureLogging(Container, services);
            var provider = Container.CreateServiceProvider(services);

            Container.ScopeManagerProvider = new PerLogicalCallContextScopeManagerProvider();
            Container.BeginScope();

            return(provider);
        }
Esempio n. 12
0
        public void ShouldSetConfigPathToDefaultIfConfigurationPropertyPassedWithBlankValue()
        {
            StartupConfiguration startupConfiguration =
                new StartupConfiguration(new[] { ValidConfigurationProperty + " " });

            Assert.Equal(GetFullPath(DefaultConfigurationFileName), startupConfiguration.ConfigRootDir);
        }
        public void ReadTypedConfigurationWithProfileAndSubProfile()
        {
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath = "TestsConfiguration/Bootstrap",
                Profile           = "profile1/sub_profile1"
            };
            var serviceProvider = new ApplicationBuilder().BuildAndStart(startupOptions);
            var sampleOptions   = serviceProvider.GetService <SampleOptions>();

            sampleOptions.SharedValue.Should().BeEquivalentTo("SharedValue");
            sampleOptions.Value.Should().BeEquivalentTo("OverridenValueSubProfile1");
            sampleOptions.OptionalValue.Should().BeEquivalentTo("OptionalValueSubProfile1");

            var startupOptions2 = new StartupConfiguration
            {
                ConfigurationPath = "TestsConfiguration/Bootstrap",
                Profile           = "profile1/sub_profile2"
            };
            var serviceProvider2 = new ApplicationBuilder().BuildAndStart(startupOptions2);
            var sampleOptions2   = serviceProvider2.GetService <SampleOptions>();

            sampleOptions2.SharedValue.Should().BeEquivalentTo("SharedValue");
            sampleOptions2.Value.Should().BeEquivalentTo("OverridenValueSubProfile2");
            // Значение должно быть из профиля profile1, а не из sub_profile2 где его нет
            sampleOptions2.OptionalValue.Should().BeEquivalentTo("OptionalValueProfile1");
        }
Esempio n. 14
0
        private void ClientTreatment_OnMessageParsed(NetworkElement arg1, ProtocolJsonContent arg2)
        {
            var hooker = HookManager <T> .Instance[LocalClient.localIp.Port];

            if (hooker is null)
            {
                logger.Error("no proxy found");
                return;
            }

            if (ClientTreatment.Informations is MessageBuffer informations)
            {
                hooker.Proxy.LAST_GLOBAL_INSTANCE_ID = informations.InstanceId;
            }

            uint instance_id = hooker.Proxy.LAST_GLOBAL_INSTANCE_ID + hooker.Proxy.FAKE_MESSAGE_SENT;
            StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup;

            if (configuration.show_message)
            {
                logger.Info($"[client {RemoteClient.remoteIp}] {arg1.BasicString()}");
                if (configuration.show_message_content)
                {
                    logger.Info($"{arg2}");
                }
            }

            HandlerManager.Instance.Handle(arg1.protocolID, LocalClient, RemoteClient, arg2);
            RemoteClient.Send(ClientTreatment.Informations.ReWriteInstanceId(instance_id));
        }
        public void RegisterModulesWithInjectedValues()
        {
            var serviceCollection = new ServiceCollection();

            // Регистрируем конфигурацию.
            serviceCollection.AddSingleton(new TestModule2Configuration {
                ConfigurationValue = "Test"
            });

            var startupOptions = new StartupConfiguration
            {
                ServiceCollection = serviceCollection,
                Modules           = new ModulesOptions
                {
                    ModuleTypes = new[] { typeof(TestModule1), typeof(TestModule2) }
                }
            };
            var buildContext = new ApplicationBuilder().Build(startupOptions);

            var testModule1Service = buildContext.GetService <TestModule1Service>();

            testModule1Service.Should().NotBeNull("testModule1Service had to be registered in TestModule1");

            var testModule2Service = buildContext.GetService <TestModule2Service>();

            testModule2Service.Should().NotBeNull("testModule2Service had to be registered in TestModule2");
            testModule2Service.ConfigurationValue.Should().Be("Test");
        }
Esempio n. 16
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            StartupConfiguration.ConfigureServices(services);

            services.AddControllersWithViews();
            services.AddRazorPages()
            .AddRazorRuntimeCompilation();
        }
Esempio n. 17
0
        public App()
        {
            var startupConfiguration = new StartupConfiguration();

            InitializeComponent();

            MainPage = new MainPage();
        }
Esempio n. 18
0
        public void ServerLifecycleManager_IsServerOnline_False()
        {
            //------------------------Arrange------------------------
            var mockEnvironmentPreparer    = new Mock <IServerEnvironmentPreparer>();
            var mockIpcClient              = new Mock <IIpcClient>();
            var mockAssemblyLoader         = new Mock <IAssemblyLoader>();
            var mockDirectory              = new Mock <IDirectory>();
            var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>();
            var mockWebServerConfiguration = new Mock <IWebServerConfiguration>();
            var mockWriter                           = new Mock <IWriter>();
            var mockSerLifeCycleWorker               = new Mock <IServerLifecycleWorker>();
            var mockResourceCatalog                  = new Mock <IResourceCatalog>();
            var mockStartWebServer                   = new Mock <IStartWebServer>();
            var mockSecurityIdentityFactory          = new Mock <ISecurityIdentityFactory>();
            var mockLoggingServiceMonitorWithRestart = new LoggingServiceMonitorWithRestart(new Mock <ChildProcessTrackerWrapper>().Object, new Mock <ProcessWrapperFactory>().Object);

            var items = new List <IServerLifecycleWorker> {
                mockSerLifeCycleWorker.Object
            };

            EnvironmentVariables.IsServerOnline = false;

            mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object);
            mockSerLifeCycleWorker.Setup(o => o.Execute()).Verifiable();
            mockAssemblyLoader.Setup(o => o.AssemblyNames(It.IsAny <Assembly>())).Returns(new AssemblyName[] { new AssemblyName {
                                                                                                                   Name = "testAssemblyName"
                                                                                                               } });
            mockWebServerConfiguration.Setup(o => o.EndPoints).Returns(new Dev2Endpoint[] { new Dev2Endpoint(new IPEndPoint(0x40E9BB63, 8080), "Url", "path") });

            //------------------------Act----------------------------
            var config = new StartupConfiguration
            {
                ServerEnvironmentPreparer = mockEnvironmentPreparer.Object,
                IpcClient              = mockIpcClient.Object,
                AssemblyLoader         = mockAssemblyLoader.Object,
                Directory              = mockDirectory.Object,
                ResourceCatalogFactory = mockResourceCatalogFactory.Object,
                WebServerConfiguration = mockWebServerConfiguration.Object,
                Writer                  = mockWriter.Object,
                StartWebServer          = mockStartWebServer.Object,
                SecurityIdentityFactory = mockSecurityIdentityFactory.Object,
                LoggingServiceMonitor   = mockLoggingServiceMonitorWithRestart
            };

            using (var serverLifeCycleManager = new ServerLifecycleManager(config))
            {
                serverLifeCycleManager.Run(items).Wait();
            }
            //------------------------Assert-------------------------
            mockWriter.Verify(o => o.Write("Loading security provider...  "), Times.Once);
            mockWriter.Verify(o => o.Write("Opening named pipe client stream for COM IPC... "), Times.Once);
            mockWriter.Verify(o => o.Write("Loading resource catalog...  "), Times.Once);
            mockWriter.Verify(o => o.Write("Loading server workspace...  "), Times.Once);
            mockWriter.Verify(o => o.Write("Loading resource activity cache...  "), Times.Once);
            mockWriter.Verify(o => o.Write("Loading test catalog...  "), Times.Once);
            mockWriter.Verify(o => o.Write("Loading triggers catalog...  "), Times.Once);
            mockSerLifeCycleWorker.Verify();
        }
 public void TypedConfigurationCodeFirstPrototype()
 {
     var startupOptions = new StartupConfiguration
     {
         ConfigurationPath = "TestsConfiguration/Bootstrap",
         Profile           = null
     };
     var serviceProvider = new ApplicationBuilder().BuildAndStart(startupOptions);
 }
Esempio n. 20
0
        public void SetForm(StartupConfiguration frm)
        {
            _frm = frm;

            _frm.ConnectionHost     = _settings.MainConnectionHost;
            _frm.ConnectionDatabase = _settings.MainConnectionDatabase;
            _frm.ConnectionUser     = _settings.MainConnectionUser;
            _frm.ConnectionPassword = _settings.MainConnectionPassword;
        }
Esempio n. 21
0
        private static void CheckStartupConfiguration()
        {
            if (Properties.Settings.Default.MainConnectionUser == string.Empty)
            {
                var config = new StartupConfiguration(new StartupConfigurationPresenter());

                config.ShowDialog();
            }
        }
        public void SetForm(StartupConfiguration frm)
        {
            _frm = frm;

            _frm.ConnectionHost = _settings.MainConnectionHost;
            _frm.ConnectionDatabase = _settings.MainConnectionDatabase;
            _frm.ConnectionUser = _settings.MainConnectionUser;
            _frm.ConnectionPassword = _settings.MainConnectionPassword;
        }
        public static List <Type> GetConfigurationTypes(Type[] allTypes, StartupConfiguration startupConfiguration)
        {
            var configurationTypes = allTypes
                                     .Where(t => GetConfigurationSuffixes().Any(suffix => t.Name.EndsWith(suffix)))
                                     .Where(type => !type.IsAbstract)
                                     .Concat(startupConfiguration.ConfigurationTypes ?? Array.Empty <Type>())
                                     .ToList();

            return(configurationTypes);
        }
Esempio n. 24
0
        public void Send(NetworkElement message, ProtocolJsonContent content, bool clientSide)
        {
            if (message is null)
            {
                return;
            }

            using (BigEndianWriter writer = new BigEndianWriter())
            {
                byte[] data = ProtocolTreatmentExtension.FromContent(content, message);

                int cmpLen = _cmpLen(data.Length);
                writer.WriteShort((short)((message.protocolID << 2) | cmpLen));

                if (clientSide)
                {
                    writer.WriteUnsignedInt(GetCustomInstanceId());
                }

                switch (cmpLen)
                {
                case 0:
                    break;

                case 1:
                    writer.WriteByte((byte)data.Length);
                    break;

                case 2:
                    writer.WriteShort((short)data.Length);
                    break;

                case 3:
                    writer.WriteByte((byte)((data.Length >> 16) & 255));
                    writer.WriteShort((short)(data.Length & 65535));
                    break;
                }

                writer.WriteBytes(data);
                Send(writer.Data);

                OnCustomMessageSent?.Invoke(message, content);

                StartupConfiguration configuration = Configurations.ConfigurationManager.Instance.Startup;
                if (configuration.show_fake_message)
                {
                    logger.Info($"fake message sent to {remoteIp} |{message.BasicString()}]");
                    if (configuration.show_fake_message_content)
                    {
                        logger.Info($"{content}");
                    }
                }
            }
        }
        public void RegisterModules1()
        {
            var startupConfiguration = new StartupConfiguration
            {
                ConfigureModules = options => options.AutoDiscoverModules = false
            };
            var buildContext       = new ApplicationBuilder().Build(startupConfiguration);
            var testModule1Service = buildContext.GetService <TestModule1Service>();

            testModule1Service.Should().BeNull();
        }
        public void Complex2()
        {
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath  = "TestsConfiguration/Complex/complex2",
                ConfigurationTypes = new[] { typeof(ComplexObject) }
            };
            var buildContext = new ApplicationBuilder().Build(startupOptions);

            buildContext.ConfigurationRoot["ComplexObject:UserName"].Should().Be("Second");
        }
Esempio n. 27
0
        public StartupDialogViewModel(StartupConfiguration configuration, IPlaceholderService placeholderService, ICasparCGService casparService, IEventAggregator ea)
        {
            this.startupConfiguration = configuration;
            this.placeholderService   = placeholderService;
            this.casparService        = casparService;

            Configurations        = configuration.Configurations;
            SelectedConfiguration = Configurations?.FirstOrDefault();

            ea.GetEvent <Core.Events.StartupDialogClosing>().Subscribe(Closing);
        }
        public void ConfigurationPathCanBeNull()
        {
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath = null,
                Profile           = null,
            };

            Action action = () => new ApplicationBuilder().Build(startupOptions);

            action.Should().NotThrow();
        }
Esempio n. 29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Startup"/> class.
        /// </summary>
        /// <param name="env">The injected Environment provider.</param>
        /// <param name="configuration">The injected configuration provider.</param>
        public Startup(IWebHostEnvironment env, IConfiguration configuration)
        {
            this.startupConfig = new StartupConfiguration(configuration, env);
            IConfigurationSection clientConfiguration = configuration.GetSection("ClientRegistries");

            this.clientRegistriesEndpoint = new EndpointAddress(new Uri(clientConfiguration.GetValue <string>("ServiceUrl")));

            // Load Certificate
            string clientCertificatePath = clientConfiguration.GetSection("ClientCertificate").GetValue <string>("Path");
            string certificatePassword   = clientConfiguration.GetSection("ClientCertificate").GetValue <string>("Password");

            this.clientRegistriesCertificate = new X509Certificate2(System.IO.File.ReadAllBytes(clientCertificatePath), certificatePassword);
        }
        public void ReadTypedConfigurationWithNoProfile()
        {
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath = "TestsConfiguration/Bootstrap",
                Profile           = null
            };
            var serviceProvider = new ApplicationBuilder().BuildAndStart(startupOptions);

            var sampleOptions = serviceProvider.GetService <SampleOptions>();

            sampleOptions.ShouldBeWithDefaultValues();
        }
        public void ReadTypedConfigurationWithProfile()
        {
            var startupOptions = new StartupConfiguration
            {
                ConfigurationPath = "TestsConfiguration/Bootstrap",
                Profile           = "profile1"
            };
            var serviceProvider = new ApplicationBuilder().BuildAndStart(startupOptions);
            var sampleOptions   = serviceProvider.GetService <SampleOptions>();

            sampleOptions.Value.Should().BeEquivalentTo("OverridenValueProfile1");
            sampleOptions.SharedValue.Should().BeEquivalentTo("SharedValue");
        }
Esempio n. 32
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            SetContentView(Resource.Layout.sample_cam);

            Title = TITLE;

            architectView = FindViewById<ArchitectView>(Resource.Id.architectView);
            var config = new StartupConfiguration (Constants.WIKITUDE_SDK_KEY, StartupConfiguration.Features.Tracking2D);
            /* use
               int requiredFeatures = StartupConfiguration.Features.Tracking2D | StartupConfiguration.Features.Geo;
               if you need both 2d Tracking and Geo
            */
            int requiredFeatures = StartupConfiguration.Features.Tracking2D | StartupConfiguration.Features.Geo;
            if ((ArchitectView.getSupportedFeaturesForDevice (Android.App.Application.Context) & requiredFeatures) == requiredFeatures) {
                architectView.OnCreate (config);
            } else {
                architectView = null;
                StartActivity (typeof(ErrorActivity));
            }
        }