Exemplo n.º 1
0
        public NavigationImpl(IServicesProvider servicesProvider, IDispatcher dispatcher)
        {
            Services = new ScopeBuilder(servicesProvider)
                       .WithInstance(this).As <INavigation>()
                       .Build();

            objectFactory   = Services.GetService <IObjectFactory>();
            this.dispatcher = dispatcher;
        }
Exemplo n.º 2
0
        public ScopeBuilder(IServicesProvider parentServicesProvider = null)
        {
            servicesProvider.ObjectFactory = objectFactory;
            servicesProvider.TypeMapping   = abstractTypeMapping;
            objectFactory.ServicesProvider = servicesProvider;
            objectFactory.TypeMapping      = abstractTypeMapping;

            WithType <ScopeBuilder>().As <IScopeBuilder>();

            if (parentServicesProvider != null)
            {
                servicesProvider.Parent    = parentServicesProvider;
                abstractTypeMapping.Parent = parentServicesProvider.GetService <IAbstractTypeMapping>();
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public ScopeBuilder WithParent(IServicesProvider parent)
 {
     servicesProvider.Parent    = parent;
     abstractTypeMapping.Parent = parent.GetService <IAbstractTypeMapping>();
     return(this);
 }