Ejemplo n.º 1
0
        private void InitServices()
        {
            AppEngine.Reset();
            AppEngine.AddServices(NetworkAdapterTypes.WebRequest);
            //var store = new GzipFileStoreService(new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XComicConst.CacheFolderName)), MD5AddressToFileNameProvider.Instance);
            var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName));

            AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>()));
            //AppEngine.Services.AddSingleton<IViewActiver<IControl>>(va);
            AppEngine.Services.AddScoped <RemoteEngine>();
            AppEngine.Services.AddSingleton(new UnoThemeService());
            AppEngine.Services.AddSingleton <IComicSaver>(store);
            AppEngine.Services.AddSingleton <IStoreService>(store);
            AppEngine.Services.AddSingleton <IPlatformService, PlatformService>();
            AppEngine.Services.AddSingleton <IStreamImageConverter <ImageBox>, StreamImageConverter>();
            AppEngine.Services.AddSingleton <IResourceFactoryCreator <ImageBox> >(new PlatformResourceCreatorFactory <ImageBox, ImageBox>
            {
                EnableCache        = true,
                StoreFetchSettings = StoreFetchSettings.DefaultNoDisposeStream.Clone()
            });
            AppEngine.Services.AddSingleton <ExceptionService>();
            var storeSer = new WithImageComicStoreService <ImageBox, ImageBox>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName)));

            AppEngine.Services.AddSingleton(storeSer);
            AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new UnoObservableCollectionFactory());
            AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageBox, ImageBox> > >(storeSer);
            AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName)));
            AppEngine.Services.AddSingleton <ProposalEngine>();
            AppEngine.Services.AddScoped <IComicVisiting <ImageBox>, UnoStoreComicVisiting>();
            AppEngine.Services.AddScoped <StoreComicVisiting <ImageBox> >();

            var configRoot = BuildConfiguration();

            AppEngine.Services.AddSingleton(CreateSettings);
            AppEngine.Services.AddSingleton(configRoot);
            AppEngine.Services.AddSingleton <IConfiguration>(configRoot);
            AppEngine.Services.AddSingleton <IConfigurationRoot>(configRoot);
            AppEngine.Services.AddSingleton(new UnoRuntime());
            AppEngine.Services.AddSingleton <UnoNavigationService>();
            AppEngine.Services.AddSingleton <IComicTurnPageService>(x => x.GetRequiredService <UnoNavigationService>());
            AppEngine.Services.AddLogging(x =>
            {
                x.ClearProviders();
#if HAS_UNO_SKIA_WPF
                x.AddConsole();
#endif
            });

            AppEngine.Services.AddSingleton <UnoHomeViewModel>();
            var appBarSer = new AppBarService();
            appBarSer.GetAsDefault()
            .Rights.Add(new DefaultControlView());
            AppEngine.Services.AddSingleton(appBarSer);
            AppEngine.Services.AddSingleton(new UnoTtileService());
        }
Ejemplo n.º 2
0
        private void InitServices()
        {
            AppEngine.Reset();
            AppEngine.AddServices(NetworkAdapterTypes.WebRequest);
            //var store = new GzipFileStoreService(new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, XComicConst.CacheFolderName)), MD5AddressToFileNameProvider.Instance);
            var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName));

            AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>()));
            //AppEngine.Services.AddSingleton<IViewActiver<IControl>>(va);
            AppEngine.Services.AddScoped <RemoteEngine>();
            AppEngine.Services.AddSingleton(new UnoThemeService());
            AppEngine.Services.AddSingleton <IComicSaver>(store);
            AppEngine.Services.AddSingleton <IStoreService>(store);
            AppEngine.Services.AddSingleton <IPlatformService, PlatformService>();
            AppEngine.Services.AddSingleton <IStreamImageConverter <ImageSource>, StreamImageConverter>();
            AppEngine.Services.AddSingleton <IResourceFactoryCreator <ImageSource>, PlatformResourceCreatorFactory <ImageSource, ImageSource> >();
            AppEngine.Services.AddSingleton <ExceptionService>();
            var storeSer = new WithImageComicStoreService <ImageSource, ImageSource>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName)));

            AppEngine.Services.AddSingleton(storeSer);
            AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new UnoObservableCollectionFactory());
            AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageSource, ImageSource> > >(storeSer);
            AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName)));
            AppEngine.Services.AddSingleton <ProposalEngine>();
            AppEngine.Services.AddScoped <IComicVisiting <ImageSource>, UnoStoreComicVisiting>();
            AppEngine.Services.AddScoped <StoreComicVisiting <ImageSource> >();

            var configRoot = BuildConfiguration();

            AppEngine.Services.AddSingleton(CreateSettings);
            AppEngine.Services.AddSingleton(configRoot);
            AppEngine.Services.AddSingleton <IConfiguration>(configRoot);
            AppEngine.Services.AddSingleton <IConfigurationRoot>(configRoot);
            AppEngine.Services.AddLogging(x =>
            {
                x.ClearProviders();
            });
        }