public static void AddMAUIService(this IServiceCollection services) { var store = FileStoreService.FromMd5Default(Path.Combine(Workstation, XComicConst.CacheFolderName)); services.AddSingleton <ProposalEngine>(); services.AddSingleton <IComicSaver>(store); services.AddSingleton <IStoreService>(store); services.AddSingleton <IPlatformService, PlatformService>(); services.AddScoped <IComicVisiting <ImageSource>, ComicVisiting <ImageSource> >(); services.AddSingleton <IStreamImageConverter <ImageSource>, StreamImageConverter>(); services.AddSingleton <IStreamImageConverter <ImageResource>, StreamResourceConverter>(); services.AddSingleton <IResourceFactoryCreator <ImageSource>, PlatformResourceCreatorFactory <ImageResource, ImageSource> >(); services.AddSingleton <ExceptionService>(); services.AddScoped <StoreComicVisiting <ImageSource> >(); var storeSer = new WithImageComicStoreService <ImageResource, ImageSource>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); services.AddSingleton(storeSer); services.AddSingleton <IObservableCollectionFactory>(new DefaultObservableCollectionFactory()); services.AddSingleton <ComicStoreService <WithImageComicStoreBox <ImageResource, ImageSource> > >(storeSer); var configRoot = BuildConfiguration(); services.AddSingleton(CreateSettings); services.AddSingleton(configRoot); services.AddSingleton <IConfiguration>(configRoot); services.AddSingleton <IConfigurationRoot>(configRoot); //LogManager.Configuration = new XmlLoggingConfiguration(XmlReader.Create(logXml)); //services.AddLogging(x => x.ClearProviders().AddNLog()); }
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()); }
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)); var hp = new Lazy <HomePage>(() => new HomePage()); var cv = new Lazy <ComicView>(() => new ComicView()); var bv = new Lazy <BookshelfView>(() => new BookshelfView()); var va = new ViewActiver <IControl> { [typeof(HomePage)] = () => hp.Value, [typeof(ComicView)] = () => cv.Value, [typeof(BookshelfView)] = () => bv.Value }; var nav = new MainNavigationService(new Border(), va); AppEngine.Services.AddSingleton(x => new BookManager(new DirectoryInfo(Path.Combine(Workstation, XComicConst.BookFolderName)), x.GetRequiredService <RecyclableMemoryStreamManager>())); AppEngine.Services.AddSingleton <IViewActiver <IControl> >(va); AppEngine.Services.AddSingleton <ThemeService>(); AppEngine.Services.AddSingleton <TitleService>(); AppEngine.Services.AddSingleton <IComicTurnPageService>(nav); AppEngine.Services.AddSingleton(nav); AppEngine.Services.AddScoped <RemoteEngine>(); AppEngine.Services.AddSingleton <IComicSaver>(store); AppEngine.Services.AddSingleton <IStoreService>(store); AppEngine.Services.AddSingleton <IPlatformService, PlatformService>(); AppEngine.Services.AddSingleton <IStreamImageConverter <Bitmap>, StreamImageConverter>(); AppEngine.Services.AddSingleton <IResourceFactoryCreator <Bitmap>, PlatformResourceCreatorFactory <Bitmap, Bitmap> >(); AppEngine.Services.AddSingleton <ExceptionService>(); var storeSer = new WithImageComicStoreService <Bitmap, Bitmap>(new DirectoryInfo(Path.Combine(Workstation, XComicConst.CacheFolderName, XComicConst.StoreFolderName))); AppEngine.Services.AddSingleton(storeSer); AppEngine.Services.AddSingleton <IObservableCollectionFactory>(new AvaloniaObservableCollectionFactory()); AppEngine.Services.AddSingleton <ComicStoreService <WithImageComicStoreBox <Bitmap, Bitmap> > >(storeSer); AppEngine.Services.AddSingleton(HistoryService.FromFile(Path.Combine(Workstation, HistoryService.HistoryFileName))); AppEngine.Services.AddSingleton <ProposalEngine>(); AppEngine.Services.AddScoped <IComicVisiting <Bitmap>, DesktopStoreComicVisiting>(); AppEngine.Services.AddScoped <StoreComicVisiting <Bitmap> >(); 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(); x.AddNLog("NLog.config"); }); }
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(); }); }