Example #1
0
        protected virtual void ResolveDatasourceTemplate(GetRenderingDatasourceArgs args)
        {
            var contextItem        = args.ContentDatabase.GetItem(args.ContextItemPath);
            var datasourceLocation = args.RenderingItem[Templates.DatasourceConfiguration.Fields.DatasourceLocation];
            var name = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(datasourceLocation);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            Item datasourceTemplate = null;
            var  provider           = providerFactory.GetProvider(args.ContentDatabase);

            if (provider != null)
            {
                datasourceTemplate = provider.GetDatasourceTemplate(name, contextItem);
            }

            if (datasourceTemplate == null)
            {
                provider = providerFactory.GetFallbackProvider(args.ContentDatabase);
                if (provider != null)
                {
                    datasourceTemplate = provider.GetDatasourceTemplate(name, contextItem);
                }
            }

            args.Prototype = datasourceTemplate;
        }
Example #2
0
        protected virtual void ResolveDatasource(GetRenderingDatasourceArgs args)
        {
            var contextItem = args.ContentDatabase.GetItem(args.ContextItemPath);
            var source      = args.RenderingItem[Templates.DatasourceConfiguration.Fields.DatasourceLocation];
            var name        = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(source);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            var datasources = new Item[] {};
            var provider    = providerFactory.GetProvider(args.ContentDatabase);

            if (provider != null)
            {
                datasources = provider.GetDatasources(name, contextItem);
            }

            if (!datasources.Any())
            {
                provider = providerFactory.GetFallbackProvider(args.ContentDatabase);
                if (provider == null)
                {
                    return;
                }

                datasources = provider.GetDatasources(name, contextItem);
            }

            args.DatasourceRoots.AddRange(datasources);
        }
        public void GetSiteDatasourceConfigurationName_IncorrectSettings_NullOrEmpty()
        {
            var setting     = "med.ia";
            var name        = $"site:{setting}";
            var settingName = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(name);

            settingName.Should().BeNullOrEmpty();
        }
        public void GetSiteDatasourceConfigurationName_CorrectSettingsString_ReturnSettingName()
        {
            var setting     = "media";
            var name        = $"site:{setting}";
            var settingName = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(name);

            settingName.Should().BeEquivalentTo(setting);
        }
Example #5
0
        private static string GetDatasourceConfigurationName(Item renderingItem)
        {
            var datasourceLocationValue     = renderingItem[DatasourceLocationFieldName];
            var datasourceConfigurationName = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(datasourceLocationValue);

            if (string.IsNullOrEmpty(datasourceConfigurationName))
            {
                datasourceConfigurationName = renderingItem.Name;
            }
            return(datasourceConfigurationName);
        }
Example #6
0
        protected virtual void ResolveDatasourceTemplate(GetRenderingDatasourceArgs args)
        {
            var contextItem        = args.ContentDatabase.GetItem(args.ContextItemPath);
            var datasourceLocation = args.RenderingItem[Templates.DatasourceConfiguration.Fields.DatasourceLocation];
            var name = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(datasourceLocation);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            args.Prototype = this.provider.GetDatasourceTemplate(contextItem, name);
        }
Example #7
0
        protected virtual void ResolveDatasource(GetRenderingDatasourceArgs args)
        {
            var contextItem = args.ContentDatabase.GetItem(args.ContextItemPath);
            var source      = args.RenderingItem[Templates.RenderingOptions.Fields.DatasourceLocation];
            var name        = DatasourceConfigurationService.GetSiteDatasourceConfigurationName(source);

            if (string.IsNullOrEmpty(name))
            {
                return;
            }

            var datasourceLocations = this.provider.GetDatasourceLocations(contextItem, name);

            args.DatasourceRoots.AddRange(datasourceLocations);
        }