public void resolve_file_should_detect_config_file_from_other_locations()
        {
            // given
            string fileName          = Path.GetTempFileName();
            string expectedDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory), "Syringe");

            string[] paths =
            {
                AppDomain.CurrentDomain.BaseDirectory,
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System),        "Syringe"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),       "Syringe"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms),"Syringe"),
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms),"Syringe"),
                expectedDirectory
            };

            if (!Directory.Exists(expectedDirectory))
            {
                Directory.CreateDirectory(expectedDirectory);
            }

            File.Create(Path.Combine(expectedDirectory, fileName));

            // when
            var    store = new ConfigLocator(paths);
            string path  = store.ResolveConfigFile(fileName);

            // then
            Assert.That(path, Is.EqualTo(Path.Combine(expectedDirectory, fileName)));
        }
示例#2
0
 /// <summary>
 /// 加入自定义默认配置
 /// </summary>
 /// <param name="webHostBuilder"></param>
 /// <returns></returns>
 public static IWebHostBuilder CreateDefaultBuilder(this IWebHostBuilder webHostBuilder) =>
 webHostBuilder.ConfigureAppConfiguration(
     (ctx, config) => ConfigLocator.SetLocatorProvider(new ConfigGeter(config.Build())))
 .ConfigureServices((ctx, services) =>
 {
     services
     .AddRegisterContainer();
 });
        public void resolve_file_should_detect_config_file_current_directory()
        {
            // given
            string fileName          = "configuration.json";
            string expectedDirectory = AppDomain.CurrentDomain.BaseDirectory;

            // when
            var    store = new ConfigLocator();
            string path  = store.ResolveConfigFile(fileName);

            // then
            Assert.That(path, Is.EqualTo(Path.Combine(expectedDirectory, fileName)));
        }
示例#4
0
        public BunnyHopGame()
        {
            config   = new Config();
            database = new InMemoryDatabase();
            ConfigLocator.Provide(config);
            ContentLocator.Provide(Content);
            InMemoryDatabaseLocator.Provide(database);

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = ConfigLocator.Config.VirtualWidth * ConfigLocator.Config.Scale;
            graphics.PreferredBackBufferHeight = ConfigLocator.Config.VirtualHeight * ConfigLocator.Config.Scale;
            graphics.PreferMultiSampling       = false;
            graphics.ApplyChanges();
            GraphicsLocator.Provide(graphics);

            var viewportAdapter = new BoxingViewportAdapter(Window,
                                                            GraphicsDevice,
                                                            ConfigLocator.Config.VirtualWidth,
                                                            ConfigLocator.Config.VirtualHeight);

            camera = new Camera2D(viewportAdapter);
            CameraLocator.Provide(camera);

            soundEffects = new List <SoundEffect>();
            SoundLocator.Provide(soundEffects);

            Content.RootDirectory = "Content";
            stateStack            = new Stack <State>();
            stateStack.Push(new SplashState());

            //https://docs.microsoft.com/pt-br/dotnet/api/system.globalization.cultureinfo.currentculture?view=netcore-3.1
            //CultureInfo culture = new CultureInfo("ko-KR", false); // us-EN ko-KR ja-JP
            //Thread.CurrentThread.CurrentCulture = culture;
            //Thread.CurrentThread.CurrentUICulture = culture;
            //Resources.Culture = CultureInfo.CurrentCulture;
            //Debug.Print(CultureInfo.CurrentCulture.Name);
            //Debug.Print(CultureInfo.CurrentCulture.TwoLetterISOLanguageName);
            //Debug.Print(Resources.Culture.Name);
        }