コード例 #1
0
ファイル: App.cs プロジェクト: semdelion/ReLearn
        public override void Initialize()
        {
            CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            Mvx.IoCProvider.RegisterSingleton(() => UserDialogs.Instance);
            RegisterAppStart <MainViewModel>();
            DataBase.SetupConnection();
            Task.Run(async() =>
            {
                await DatabaseImages.UpdateData();
                await DatabaseWords.UpdateData();
            });

            var assemblyConfig = new AssemblyContentConfig(GetType().GetTypeInfo().Assembly)
            {
                ResourceFolder = "Locales",
                ParserConfig   = new ParserConfig
                {
                    ThrowWhenKeyNotFound = true
                }
            };

            var textProvider = new MvxYamlTextProvider(assemblyConfig);

            Mvx.IoCProvider.RegisterSingleton <IMvxTextProvider>(textProvider);
            Mvx.IoCProvider.RegisterSingleton <IMvxLocalizationProvider>(textProvider);
        }
コード例 #2
0
ファイル: App.cs プロジェクト: squareinc/Xamarin.Yaml
        public override void Initialize()
        {
            this.CreatableTypes()
            .EndingWith("Service")
            .AsInterfaces()
            .RegisterAsLazySingleton();

            this.RegisterNavigationServiceAppStart <FirstViewModel>();

            Mvx.RegisterSingleton(UserDialogs.Instance);
            var assemblyConfig = new AssemblyContentConfig(this.GetType().GetTypeInfo().Assembly)
            {
                ResourceFolder = "Locales",
                ParserConfig   = new ParserConfig
                {
                    ThrowWhenKeyNotFound = true
                },
                Logger = trace => { LocaleLog.Debug(trace); }
            };

            var textProvider = new MvxYamlTextProvider(assemblyConfig);

            Mvx.RegisterSingleton <IMvxTextProvider>(textProvider);
            Mvx.RegisterSingleton <IMvxLocalizationProvider>(textProvider);
        }
コード例 #3
0
ファイル: App.cs プロジェクト: semdelion/Playground
        public override void Initialize()
        {
            base.Initialize();
            Environment = new EnvironmentBuilder().SetSettings(CreateSettings()).Build();

            var assemblyConfig = new AssemblyContentConfig(GetType().GetTypeInfo().Assembly)
            {
                ResourceFolder = "Locales",
                ParserConfig   = new ParserConfig
                {
                    ThrowWhenKeyNotFound = true
                }
            };

            I18N.Initialize(assemblyConfig);

            var textProvider = new MvxLocalizationProvider(assemblyConfig);

            Mvx.IoCProvider.RegisterSingleton <IMvxTextProvider>(textProvider);
            Mvx.IoCProvider.RegisterSingleton <IMvxLocalizationProvider>(textProvider);
            Mvx.IoCProvider.RegisterSingleton <IAppSettings>(new AppSettings(Environment));
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton(() => CrossConnectivity.Current);

            Mvx.IoCProvider.RegisterSingleton <IRepository>(() => new Repository());
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <ILogRepository, LogRepository>();
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <ILogWriter, LogWriter>();
            Mvx.IoCProvider.LazyConstructAndRegisterSingleton <ILogReader, LogReader>();

            var logger = Mvx.IoCProvider.Resolve <IMvxLogProvider>().GetLogFor(nameof(App));

            logger.Info("#################### Client Settings ####################");
            logger.Error("Error");
            logger.Fatal("Fatal");
            logger.Warn("Warn");
        }
コード例 #4
0
        protected override void ReloadLocale()
        {
            var assemblyConfig = new AssemblyContentConfig(this.GetType().GetTypeInfo().Assembly)
            {
                ResourceFolder = "Locales"
            };

            FriendlyLocale.I18N.Initialize(assemblyConfig);
            this.ReloadItems();
        }
        public void SetUp()
        {
            var hostAssembly   = this.GetType().Assembly;
            var assemblyConfig = new AssemblyContentConfig(hostAssembly)
            {
                ResourceFolder = "Locales"
            };

            this.assemblyTranslateContentClient = new AssemblyTranslateContentClient(assemblyConfig);
        }
コード例 #6
0
        public async Task Check_Multiple_Assemblies()
        {
            // Arrange
            var hostAssembly   = this.GetType().Assembly;
            var assemblyConfig = new AssemblyContentConfig(new List <Assembly> {
                hostAssembly, hostAssembly
            })
            {
                ResourceFolder = "Locales"
            };

            this.assemblyTranslateContentClient = new AssemblyTranslateContentClient(assemblyConfig);
            var locales = this.assemblyTranslateContentClient.GetLocales();

            // Act
            var contents = await this.assemblyTranslateContentClient.GetContent(locales.First(), null, new CancellationToken());

            // Assert
            Assert.AreEqual(2, contents.Length);
            foreach (var locale in locales)
            {
                Assert.AreEqual(2, (locale as AssemblyLocale)?.HostAssemblies.Count);
            }
        }
コード例 #7
0
 public AssemblyTranslateContentClient(AssemblyContentConfig contentConfig)
 {
     this.contentConfig = contentConfig;
 }
コード例 #8
0
 public static ITranslateContentClient Create(
     AssemblyContentConfig contentConfig)
 {
     return(new AssemblyTranslateContentClient(contentConfig));
 }
コード例 #9
0
 public MvxLocalizationProvider(AssemblyContentConfig config)
 {
     I18N.Initialize(config);
 }
コード例 #10
0
 public MvxYamlTextProvider(AssemblyContentConfig config)
 {
     I18N.Initialize(config);
 }
コード例 #11
0
 public static void Initialize(AssemblyContentConfig contentConfig)
 {
     InitializeInternal(TranslateContentClientFactory.Create(contentConfig));
 }