IServicesProvider ICoreApplication.Initialize(IServicesProvider servicesProvider) { var assembly = GetType().Assembly; var builder = new ScopeBuilder(servicesProvider); var elementTypeMapping = new ElementTypeMapping(assembly); var appValues = new AppValues(); var conversionService = new ConversionService(assembly); var bindingService = new BindingService(appValues, conversionService); LoadApplicationDefinition(appValues, bindingService, elementTypeMapping, servicesProvider.GetService <IObjectFactory>()); builder .WithInstance(this).As <Application>().As(GetType()) .WithInstance(elementTypeMapping).As <IElementTypeMapping>() .WithInstance(appValues).As <IAppValues>() .WithInstance(bindingService).As <IBindingService>() .WithType <TooltipService>().As <ITooltipService>().AsSingleton() .WithType <UIServices>().As <IUIServices>().AsSingleton() .WithType <XxFileParserImpl>().As <IXxFileParser>().AsSingleton(); BeforeInitServices?.Invoke(servicesProvider, builder); InitServices(servicesProvider, builder); if (!builder.TryResolveInstance <IViewLocator>(out var _)) { builder.WithType <DefaultViewLocator>().As <IViewLocator>().AsSingleton(); } AfterInitServices?.Invoke(servicesProvider, builder); Services = builder.Build(); LoadFonts(Services.GetService <IFontManager>()); WindowsService = Services.GetService <IWindowsService>(); ((WindowService)WindowsService).ObjectFactory = Services.GetService <IObjectFactory>(); return(Services); }
IServicesContainerBuilder IServicesContainerBuilder.RegisterSingleton <InterfaceType>(InterfaceType instance) { scopeBuilder.WithInstance(instance).As <InterfaceType>(); return(this); }