Beispiel #1
0
        public Provider <TProvider> GetProvider <TProvider>(string systemName, int storeId = 0) where TProvider : IProvider
        {
            if (systemName.IsEmpty())
            {
                return(null);
            }

            var provider = _ctx.ResolveOptionalNamed <Lazy <TProvider, ProviderMetadata> >(systemName);

            if (provider != null)
            {
                if (storeId > 0)
                {
                    var d = provider.Metadata.PluginDescriptor;
                    if (d != null && !IsActiveForStore(d, storeId))
                    {
                        return(null);
                    }
                }
                SetUserData(provider.Metadata);
                return(new Provider <TProvider>(provider));
            }

            return(null);
        }
Beispiel #2
0
        public void ActivateDependentWidgets(ProviderMetadata parent, bool activate)
        {
            Guard.ArgumentNotNull(() => parent);

            if (parent.DependentWidgets == null || parent.DependentWidgets.Length == 0)
            {
                return;
            }

            foreach (var systemName in parent.DependentWidgets)
            {
                var widget = _ctx.ResolveOptionalNamed <Lazy <IWidget, ProviderMetadata> >(systemName);
                if (widget != null)
                {
                    var widgetSettings = _ctx.Resolve <WidgetSettings>();

                    if (widget.IsWidgetActive(widgetSettings))
                    {
                        if (!activate)
                        {
                            widgetSettings.ActiveWidgetSystemNames.Remove(systemName);
                            _services.Settings.SaveSetting(widgetSettings);
                        }
                    }
                    else
                    {
                        if (activate)
                        {
                            widgetSettings.ActiveWidgetSystemNames.Add(systemName);
                            _services.Settings.SaveSetting(widgetSettings);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public static Page ResolvePage(this IComponentContext container, string code, object parameter)
        {
            var result = container.ResolveOptionalNamed <Page>(GetPageFullName(code), new NamedParameter("parameter", parameter));

            if (result == null)
            {
                throw new ApplicationError("message.unimplemented-page-resolved", code);
            }
            return(result);
        }
        public Provider <TProvider> GetProvider <TProvider>(string systemName, int storeId = 0) where TProvider : IProvider
        {
            if (systemName.IsEmpty())
            {
                return(null);
            }

            var provider = _ctx.ResolveOptionalNamed <Lazy <TProvider, ProviderMetadata> >(systemName);

            if (provider != null)
            {
                if (storeId > 0)
                {
                    var d = provider.Metadata.PluginDescriptor;
                    if (d != null && _services.Settings.GetSettingByKey <string>(d.GetSettingKey("LimitedToStores")).ToIntArrayContains(storeId, false))
                    {
                        return(null);
                    }
                }
                SetUserData(provider.Metadata);
                return(new Provider <TProvider>(provider));
            }
            return(null);
        }
 protected virtual bool ResolveDbContextLoggerFactory(IComponentContext context, out ILoggerFactory loggerFactory)
 {
     loggerFactory = context.ResolveOptionalNamed <ILoggerFactory>(DbContextLoggerFactoryRegistrationName);
     return(loggerFactory != null);
 }
Beispiel #6
0
 public T GetService <T>(string name, params Parameter[] parameters)
     where T : class
 {
     return(_componentContext.ResolveOptionalNamed <T>(name, GetResolvedParameters(parameters)));
 }
 protected override Page CreatePage(string name)
 {
     return(_context.ResolveOptionalNamed <object>(name) as Page);
 }