Esempio n. 1
0
 public SassyStudioPackage()
 {
     _ScssOptions = new Lazy<ScssOptions>(() => GetDialogPage(typeof(ScssOptions)) as ScssOptions, true);
     _Options = new OptionsProvider(this);
     _DTE = new Lazy<DTE2>(() => ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2);
     _ScssService = new ScssLanguageService();
 }
 public SassyStudioPackage()
 {
     _ScssOptions = new Lazy <ScssOptions>(() => GetDialogPage(typeof(ScssOptions)) as ScssOptions, true);
     _Options     = new OptionsProvider(this);
     _DTE         = new Lazy <DTE2>(() => ServiceProvider.GlobalProvider.GetService(typeof(DTE)) as DTE2);
     _ScssService = new ScssLanguageService();
 }
 static void LogInitialization(OptionsProvider options)
 {
     Logger.Log("Sassy studio initializing.", true);
     Logger.Log("CssGenerationOutputDirectory = " + options.Scss.CssGenerationOutputDirectory);
     Logger.Log("GenerateCssOnSave = " + options.Scss.GenerateCssOnSave);
     Logger.Log("GenerateMinifiedCssOnSave = " + options.Scss.GenerateMinifiedCssOnSave);
     Logger.Log("IncludeCssInProject = " + options.Scss.IncludeCssInProject);
     Logger.Log("IncludeCssInProjectOutput = " + options.Scss.IncludeCssInProjectOutput);
     Logger.Log("IncludeSourceComments = " + options.Scss.IncludeSourceComments);
     Logger.Log("ReplaceCssWithException = " + options.Scss.ReplaceCssWithException);
     Logger.Log("RubyInstallPath = " + options.Scss.RubyInstallPath);
 }
Esempio n. 4
0
 static void LogInitialization(OptionsProvider options)
 {
     Logger.Log("Sassy studio initializing.", true);
     Logger.Log("CssGenerationOutputDirectory = " + options.Scss.CssGenerationOutputDirectory);
     Logger.Log("GenerateCssOnSave = " + options.Scss.GenerateCssOnSave);
     Logger.Log("GenerateMinifiedCssOnSave = " + options.Scss.GenerateMinifiedCssOnSave);
     Logger.Log("IncludeCssInProject = " + options.Scss.IncludeCssInProject);
     Logger.Log("IncludeCssInProjectOutput = " + options.Scss.IncludeCssInProjectOutput);
     Logger.Log("IncludeSourceComments = " + options.Scss.IncludeSourceComments);
     Logger.Log("ReplaceCssWithException = " + options.Scss.ReplaceCssWithException);
     Logger.Log("RubyInstallPath = " + options.Scss.RubyInstallPath);
 }
Esempio n. 5
0
        public void ParseArguments_InvalidFormat_ReturnsFailureResult(string arguments)
        {
            // Arrange
            var argumentsArray  = arguments.Split(" ");
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.False);
            Assert.That(result.HelpText, Is.EqualTo(StandardHelpText));
        }
Esempio n. 6
0
        public void ParseArguments_ValidArguments_ReturnsSuccessResult(string arguments, int expectedNumberOfPosts)
        {
            // Arrange
            var argumentsArray  = arguments.Split(" ");
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.True);
            Assert.That(result.Options.NumberOfPosts, Is.EqualTo(expectedNumberOfPosts));
        }
        public void ShouldThrowValidationExceptionWhenOptionsAreInvalid()
        {
            // Arrange
            var testOptions = new TestOptions();

            var optionsMock = new Mock <IOptions <TestOptions> >();

            optionsMock.Setup(x => x.Value).Returns(testOptions);

            var optionsProvider = new OptionsProvider <TestOptions>(optionsMock.Object);

            // Act + Assert
            ((Action)(() => optionsProvider.Get())).ShouldThrow <ArgumentNullException>().Which.ParamName.Should().Be("Option");
        }
Esempio n. 8
0
        public void Execute_Invokes_Validate()
        {
            var validatorMock   = new Mock <IOptionsValidator>();
            var optionsProvider = new OptionsProvider(new Options());
            var subject         = new ValidateOptionsTask(validatorMock.Object
                                                          , optionsProvider
                                                          , TestObjects.Logger);

            validatorMock.Setup(m => m.Validate(It.IsAny <Options>())).Verifiable();

            subject.Execute();

            validatorMock.Verify(m => m.Validate(It.IsAny <Options>()));
        }
Esempio n. 9
0
        public void ParseArguments_ValidFormatPostCountOutOfRange_ReturnsFailureResult(int postCount)
        {
            // Arrange
            var argumentsArray  = new[] { "--posts", postCount.ToString() };
            var optionsProvider = new OptionsProvider();

            // Act
            var result = optionsProvider.ParseArguments(argumentsArray);

            // Assert
            var expectedHelpText = "Number of posts must be between 1 and 100." + Environment.NewLine + Environment.NewLine + StandardHelpText;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.ParsedSuccessfully, Is.False);
            Assert.That(result.HelpText, Is.EqualTo(expectedHelpText));
        }
        public void ShouldGetOptions()
        {
            // Arrange
            var testOptions = new TestOptions()
            {
                Option = "option"
            };

            var optionsMock = new Mock <IOptions <TestOptions> >();

            optionsMock.Setup(x => x.Value).Returns(testOptions);

            var optionsValue = new OptionsProvider <TestOptions>(optionsMock.Object);

            // Act + Assert
            optionsValue.Get().Should().BeSameAs(testOptions);
        }
Esempio n. 11
0
        private static (NtradaOptions, OptionsProvider) BuildConfiguration(IServiceCollection services)
        {
            IConfiguration config;

            using (var scope = services.BuildServiceProvider().CreateScope())
            {
                config = scope.ServiceProvider.GetService <IConfiguration>();
            }

            var optionsProvider = new OptionsProvider(config);

            services.AddSingleton <IOptionsProvider>(optionsProvider);
            var configuration = optionsProvider.Get <NtradaOptions>();

            services.AddSingleton(configuration);

            return(configuration, optionsProvider);
        }
Esempio n. 12
0
        private void ConfigureServices()
        {
            XBLMSAService msa;
            var           storage = new StorageSystem(LaunchSettings.WorkDir);

            ProfileManager = new ProfileManager(this, storage);


            Services.AddService <IStorageSystem>(storage);

            var optionsProvider = new OptionsProvider(storage);

            //optionsProvider.Load();

            optionsProvider.AlexOptions.VideoOptions.UseVsync.Bind((value, newValue) => { SetVSync(newValue); });
            if (optionsProvider.AlexOptions.VideoOptions.UseVsync.Value)
            {
                SetVSync(true);
            }

            optionsProvider.AlexOptions.VideoOptions.Fullscreen.Bind((value, newValue) => { SetFullscreen(newValue); });
            if (optionsProvider.AlexOptions.VideoOptions.Fullscreen.Value)
            {
                SetFullscreen(true);
            }

            Services.AddService <IOptionsProvider>(optionsProvider);

            Services.AddService <IListStorageProvider <SavedServerEntry> >(new SavedServerDataProvider(storage));

            Services.AddService(msa = new XBLMSAService());

            Services.AddService <IServerQueryProvider>(new ServerQueryProvider(this));
            Services.AddService <IPlayerProfileService>(ProfileService = new PlayerProfileService(msa, ProfileManager));

            var profilingService = new ProfilerService();

            Services.AddService <ProfilerService>(profilingService);

            Storage = storage;
        }
Esempio n. 13
0
        public void Run(string[] args)
        {
            if (args.Contains("/?", StringComparer.OrdinalIgnoreCase))
            {
                Console.WriteLine(OptionsProvider.HelpText());
                return;
            }

            var options = OptionsProvider.Parse(args);

            if (options == null)
            {
                Console.WriteLine(OptionsProvider.HelpText());
                return;
            }

            foreach (var each in Commands)
            {
                if (each.Execute(options))
                {
                    break;
                }
            }
        }
Esempio n. 14
0
 public LabEtlBuilder(OptionsProvider optionProvider) : base(optionProvider)
 {
 }
 public RemoteOptionsProvider(HostWorkspaceServices services, OptionsProvider <TOptions> optionsProvider)
 {
     _services        = services;
     _optionsProvider = optionsProvider;
 }
Esempio n. 16
0
        public Alex(LaunchSettings launchSettings)
        {
            EntityProperty.Factory = new AlexPropertyFactory();

            /*MiNET.Utils.DedicatedThreadPool fastThreadPool =
             *      ReflectionHelper.GetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>(
             *              typeof(MiNetServer), "FastThreadPool");
             *
             * fastThreadPool?.Dispose();
             * fastThreadPool?.WaitForThreadsExit();
             *
             * ReflectionHelper.SetPrivateStaticPropertyValue<MiNET.Utils.DedicatedThreadPool>(
             *      typeof(MiNetServer), "FastThreadPool",
             *      new MiNET.Utils.DedicatedThreadPool(
             *              new MiNET.Utils.DedicatedThreadPoolSettings(8, "MiNETServer Fast")));*/

            ThreadPool.GetMaxThreads(out _, out var completionPortThreads);
            //ThreadPool.SetMaxThreads(Environment.ProcessorCount, completionPortThreads);

            Instance       = this;
            LaunchSettings = launchSettings;

            OperatingSystem =
                $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription} ({System.Runtime.InteropServices.RuntimeInformation.OSArchitecture})";

            DeviceManager = new GraphicsDeviceManager(this)
            {
                PreferMultiSampling            = false,
                SynchronizeWithVerticalRetrace = false,
                GraphicsProfile = GraphicsProfile.Reach,
            };

            DeviceManager.PreparingDeviceSettings += (sender, args) =>
            {
                Gpu = args.GraphicsDeviceInformation.Adapter.Description;
                args.GraphicsDeviceInformation.PresentationParameters.DepthStencilFormat = DepthFormat.Depth24Stencil8;
                DeviceManager.PreferMultiSampling = true;
            };

            Content = new StreamingContentManager(base.Services, "assets");
            //	Content.RootDirectory = "assets";

            IsFixedTimeStep = false;
            // graphics.ToggleFullScreen();

            this.Window.AllowUserResizing = true;

            this.Window.ClientSizeChanged += (sender, args) =>
            {
                if (DeviceManager.PreferredBackBufferWidth != Window.ClientBounds.Width ||
                    DeviceManager.PreferredBackBufferHeight != Window.ClientBounds.Height)
                {
                    if (DeviceManager.IsFullScreen)
                    {
                        DeviceManager.PreferredBackBufferWidth =
                            GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;

                        DeviceManager.PreferredBackBufferHeight =
                            GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                    }
                    else
                    {
                        DeviceManager.PreferredBackBufferWidth  = Window.ClientBounds.Width;
                        DeviceManager.PreferredBackBufferHeight = Window.ClientBounds.Height;
                    }

                    DeviceManager.ApplyChanges();

                    //CefWindow.Size = new System.Drawing.Size(Window.ClientBounds.Width, Window.ClientBounds.Height);
                }
            };


            JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
            {
                Converters = new List <JsonConverter>()
                {
                    new Texture2DJsonConverter(GraphicsDevice)
                },
                Formatting = Formatting.Indented
            };

            ServerTypeManager = new ServerTypeManager();
            PluginManager     = new PluginManager();

            Storage = new StorageSystem(LaunchSettings.WorkDir);
            Options = new OptionsProvider(Storage);

            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton <Alex>(this);
            serviceCollection.AddSingleton <ContentManager>(Content);
            serviceCollection.AddSingleton <IStorageSystem>(Storage);
            serviceCollection.AddSingleton <IOptionsProvider>(Options);

            InitiatePluginSystem(serviceCollection);

            AudioEngine = new AudioEngine(Storage);

            ConfigureServices(serviceCollection);

            Services = serviceCollection.BuildServiceProvider();

            PluginManager.Setup(Services);

            PluginManager.LoadPlugins();

            ServerTypeManager.TryRegister("java", new JavaServerType(this));

            ServerTypeManager.TryRegister(
                "bedrock", new BedrockServerType(this, Services.GetService <XboxAuthService>()));

            UIThreadQueue = new ConcurrentQueue <Action>();

            FpsMonitor = new FpsMonitor();

            Resources = Services.GetRequiredService <ResourceManager>();

            // ThreadPool = new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount,
            //    ThreadType.Background, "Dedicated ThreadPool"));

            KeyboardInputListener.InstanceCreated += KeyboardInputCreated;

            TextureUtils.RenderThread        = Thread.CurrentThread;
            TextureUtils.QueueOnRenderThread = action => UIThreadQueue.Enqueue(action);
        }
Esempio n. 17
0
        public ICommandRegistry UseCommanding(ICommandingDependencyResolver dependencyResolver,
                                              IOptions options = null)
        {
            options = options ?? new Options();

            dependencyResolver.AssociatedCommandingRuntime = this;

            ICommandHandlerExecuter commandHandlerExecuter = new CommandHandlerExecuter();

            dependencyResolver.RegisterInstance(commandHandlerExecuter);
            IOptionsProvider optionsProvider = new OptionsProvider(options);

            dependencyResolver.RegisterInstance(optionsProvider);

            // the registry is always shared, but vagaries of different IoC containers mean its dangerous to rely
            // on dependecy resolver checks for an existing registration
            lock (_registryLockObject)
            {
                if (_registry == null || options.Reset)
                {
                    Action <Type> resolverContainerRegistration = type => dependencyResolver.TypeMapping(type, type);
                    _registry = new CommandRegistry(commandHandlerExecuter, options.CommandHandlerContainerRegistration ?? resolverContainerRegistration);
                }
                dependencyResolver.RegisterInstance(_registry);
            }

            // the enricher is always shared, but vagaries of different IoC containers mean its dangerous to rely
            // on dependecy resolver checks for an existing registration
            lock (_enrichmentLockObject)
            {
                if (_dispatchContextEnrichment == null || options.Reset)
                {
                    _dispatchContextEnrichment = new CommandDispatchContextEnrichment(options.Enrichers ?? new List <ICommandDispatchContextEnricher>());
                }
                else if (options.Enrichers != null)
                {
                    _dispatchContextEnrichment.AddEnrichers(options.Enrichers);
                }
                dependencyResolver.RegisterInstance(_dispatchContextEnrichment);
            }

            lock (_auditItemEnricherPipelineLockObject)
            {
                if (_auditItemEnricherPipeline == null || options.Reset)
                {
                    _auditItemEnricherPipeline = new AuditItemEnricherPipeline(
                        options.AuditItemEnricherFactoryFunc ?? (type => (IAuditItemEnricher)dependencyResolver.Resolve(type)));
                }
                dependencyResolver.RegisterInstance(_auditItemEnricherPipeline);
            }

            lock (_auditorPipelineLockObject)
            {
                if (_auditorPipeline == null || options.Reset)
                {
                    _auditorPipeline = new CommandAuditPipeline(t => (ICommandAuditor)dependencyResolver.Resolve(t),
                                                                dependencyResolver.Resolve <ICommandAuditSerializer>,
                                                                _auditItemEnricherPipeline);
                }
                dependencyResolver.RegisterInstance(_auditorPipeline);
            }

            ICommandHandlerFactory commandHandlerFactory = new CommandHandlerFactory(options.CommandHandlerFactoryFunc ?? dependencyResolver.Resolve);

            IPipelineAwareCommandHandlerExecuter pipelineAwareCommandHandlerExecuter = new PipelineAwareCommandHandlerExecuter();

            dependencyResolver.RegisterInstance(commandHandlerFactory);
            dependencyResolver.RegisterInstance(pipelineAwareCommandHandlerExecuter);

            dependencyResolver.TypeMapping <ICommandAuditorFactory, NullCommandAuditorFactory>();
            dependencyResolver.TypeMapping <ICommandScopeManager, AsyncLocalCommandScopeManager>();
            dependencyResolver.TypeMapping <IFrameworkCommandDispatcher, CommandDispatcher>();
            dependencyResolver.TypeMapping <ICommandDispatcher, CommandDispatcher>();
            dependencyResolver.TypeMapping <IFrameworkCommandExecuter, CommandExecuter>();
            dependencyResolver.TypeMapping <ICommandExecuter, CommandExecuter>();
            dependencyResolver.TypeMapping <IDirectCommandExecuter, DirectCommandExecuter>();
            if (options.DisableCorrelationIds)
            {
                dependencyResolver.TypeMapping <ICommandCorrelationIdProvider, DisabledCorrelationIdProvider>();
            }
            else
            {
                if (options.UseLocallyUniqueCorrelationIds)
                {
                    dependencyResolver
                    .TypeMapping <ICommandCorrelationIdProvider, LocallyUniqueCommandCorrelationIdProvider>();
                }
                else
                {
                    dependencyResolver.TypeMapping <ICommandCorrelationIdProvider, CommandCorrelationIdProvider>();
                }
            }

            dependencyResolver.TypeMapping <ICommandAuditSerializer, CommandAuditSerializer>();
            dependencyResolver.TypeMapping(typeof(ICommandExecutionExceptionHandler), options.CommandExecutionExceptionHandler ?? typeof(DefaultCommandExecutionExceptionHandler));

            return(_registry);
        }
Esempio n. 18
0
 public EtlBuilder(OptionsProvider provider)
 {
     _optionsProvider = provider;
 }