private static IApp ExtendAppWithDefaultProvider(bool versioningEnabled, bool showDrafts, App appStuff) { var provider = new ValueCollectionProvider(); // use blank provider for now appStuff.InitData(showDrafts, versioningEnabled, provider); return(appStuff); }
/// <summary> /// Create a test config provider - here you could supply tokens if you want to run tests which would resolve a token for you /// </summary> /// <returns></returns> public IValueCollectionProvider TestConfigProvider() { var vc = new ValueCollectionProvider(); // var entVc = new EntityValueProvider(AppSettings(), "AppSettings"); // vc.Sources.Add("AppSettings".ToLower(), entVc); // vc.Sources.Add("AppResources".ToLower(), new EntityValueProvider(AppResources(), "AppResources")); return(vc); }
public static IApp App(int appId, PortalSettings ownerPortalSettings, bool versioningEnabled) { var appStuff = new App(ownerPortalSettings, appId); var provider = new ValueCollectionProvider(); // use blank provider for now appStuff.InitData(false, versioningEnabled, provider); return(appStuff); }
// note: not sure yet where the best place for this method is, so it's here for now // will probably move again some day internal static ValueCollectionProvider GetConfigProviderForModule(int moduleId, App app, SxcInstance sxc) { var provider = new ValueCollectionProvider(); // only add these in running inside an http-context. Otherwise leave them away! if (HttpContext.Current != null) { var request = HttpContext.Current.Request; // new var paramList = new NameValueCollection(); if (sxc?.Parameters != null) { foreach (var pair in sxc.Parameters) { paramList.Add(pair.Key, pair.Value); } } else { paramList = request.QueryString; } provider.Sources.Add("querystring", new FilteredNameValueCollectionPropertyAccess("querystring", paramList)); // old provider.Sources.Add("server", new FilteredNameValueCollectionPropertyAccess("server", request.ServerVariables)); provider.Sources.Add("form", new FilteredNameValueCollectionPropertyAccess("form", request.Form)); } // Add the standard DNN property sources if PortalSettings object is available (changed 2018-03-05) var envProvs = Factory.Resolve <IEnvironmentValueProviders>().GetProviders(moduleId).Sources; foreach (var prov in envProvs) { provider.Sources.Add(prov.Key, prov.Value); } provider.Sources.Add("app", new AppPropertyAccess("app", app)); // add module if it was not already added previously if (!provider.Sources.ContainsKey("module")) { var modulePropertyAccess = new StaticValueProvider("module"); modulePropertyAccess.Properties.Add("ModuleID", moduleId.ToString(CultureInfo.InvariantCulture)); provider.Sources.Add(modulePropertyAccess.Name, modulePropertyAccess); } // provide the current SxcInstance to the children where necessary if (!provider.Sources.ContainsKey(SxcInstanceKey)) { var sxci = new SxcInstanceValueProvider(SxcInstanceKey, null, sxc); provider.Sources.Add(sxci.Name, sxci); } return(provider); }
public static IApp App(int appId, PortalSettings ownerPortalSettings) { //if(ownerPortalSettings == null) // throw new Exception("no portal settings received"); //var zoneId = ZoneHelpers.GetZoneID(ownerPortalSettings.PortalId); //if (!zoneId.HasValue) // throw new Exception("Cannot find zone-id for portal specified"); var appStuff = new App(ownerPortalSettings, appId); var provider = new ValueCollectionProvider(); // use blank provider for now appStuff.InitData(false, provider); return(appStuff); }
// note: not sure yet where the best place for this method is, so it's here for now // will probably move again some day internal static ValueCollectionProvider GetConfigProviderForModule(int moduleId, /*PortalSettings portalSettings,*/ SexyContent.App App) { var portalSettings = PortalSettings.Current; var provider = new ValueCollectionProvider(); // only add these in running inside an http-context. Otherwise leave them away! if (HttpContext.Current != null) { var request = HttpContext.Current.Request; provider.Sources.Add("querystring", new FilteredNameValueCollectionPropertyAccess("querystring", request.QueryString)); provider.Sources.Add("server", new FilteredNameValueCollectionPropertyAccess("server", request.ServerVariables)); provider.Sources.Add("form", new FilteredNameValueCollectionPropertyAccess("form", request.Form)); } // Add the standard DNN property sources if PortalSettings object is available if (portalSettings != null) { var dnnUsr = portalSettings.UserInfo; var dnnCult = Thread.CurrentThread.CurrentCulture; var dnn = new TokenReplaceDnn(App, moduleId, portalSettings, dnnUsr); var stdSources = dnn.PropertySources; foreach (var propertyAccess in stdSources) { provider.Sources.Add(propertyAccess.Key, new ValueProviderWrapperForPropertyAccess(propertyAccess.Key, propertyAccess.Value, dnnUsr, dnnCult)); } } provider.Sources.Add("app", new AppPropertyAccess("app", App)); // add module if it was not already added previously if (!provider.Sources.ContainsKey("module")) { var modulePropertyAccess = new StaticValueProvider("module"); modulePropertyAccess.Properties.Add("ModuleID", moduleId.ToString(CultureInfo.InvariantCulture)); provider.Sources.Add(modulePropertyAccess.Name, modulePropertyAccess); } var _valueCollectionProvider = provider; return(_valueCollectionProvider); }
public ValueCollectionProvider GetProviders(int instanceId) { var providers = new ValueCollectionProvider(); var portalSettings = PortalSettings.Current; if (portalSettings == null) { return(providers); } var dnnUsr = portalSettings.UserInfo; var dnnCult = Thread.CurrentThread.CurrentCulture; var dnn = new TokenReplaceDnn(instanceId, portalSettings, dnnUsr); var stdSources = dnn.PropertySources; foreach (var propertyAccess in stdSources) { providers.Sources.Add(propertyAccess.Key, new ValueProviderWrapperForPropertyAccess(propertyAccess.Key, propertyAccess.Value, dnnUsr, dnnCult)); } return(providers); }
// note: not sure yet where the best place for this method is, so it's here for now // will probably move again some day internal static ValueCollectionProvider GetConfigProviderForModule(int moduleId, SexyContent.App app, SxcInstance sxc) { var portalSettings = PortalSettings.Current; var provider = new ValueCollectionProvider();//sxc); // only add these in running inside an http-context. Otherwise leave them away! if (HttpContext.Current != null) { var request = HttpContext.Current.Request; // new NameValueCollection paramList = new NameValueCollection(); if (sxc?.Parameters != null) { foreach (var pair in sxc.Parameters) { paramList.Add(pair.Key, pair.Value); } } else { paramList = request.QueryString; } provider.Sources.Add("querystring", new FilteredNameValueCollectionPropertyAccess("querystring", paramList)); // old // provider.Sources.Add("querystring", new FilteredNameValueCollectionPropertyAccess("querystring", request.QueryString)); provider.Sources.Add("server", new FilteredNameValueCollectionPropertyAccess("server", request.ServerVariables)); provider.Sources.Add("form", new FilteredNameValueCollectionPropertyAccess("form", request.Form)); } // Add the standard DNN property sources if PortalSettings object is available if (portalSettings != null) { var dnnUsr = portalSettings.UserInfo; var dnnCult = Thread.CurrentThread.CurrentCulture; var dnn = new TokenReplaceDnn(moduleId, portalSettings, dnnUsr); var stdSources = dnn.PropertySources; foreach (var propertyAccess in stdSources) { provider.Sources.Add(propertyAccess.Key, new ValueProviderWrapperForPropertyAccess(propertyAccess.Key, propertyAccess.Value, dnnUsr, dnnCult)); } } provider.Sources.Add("app", new AppPropertyAccess("app", app)); // add module if it was not already added previously if (!provider.Sources.ContainsKey("module")) { var modulePropertyAccess = new StaticValueProvider("module"); modulePropertyAccess.Properties.Add("ModuleID", moduleId.ToString(CultureInfo.InvariantCulture)); provider.Sources.Add(modulePropertyAccess.Name, modulePropertyAccess); } // provide the current SxcInstance to the children where necessary if (!provider.Sources.ContainsKey("SxcInstance")) { var sxci = new SxcInstanceValueProvider("SxcInstance", null, sxc); provider.Sources.Add(sxci.Name, sxci); } return(provider); }
internal static ViewDataSource ForContentGroupInSxc(SxcInstance sxc, Template overrideTemplate, ValueCollectionProvider configurationProvider, Log parentLog, int moduleId = 0) { var log = new Log("DS.CreateV", parentLog, "will create view data source"); var showDrafts = sxc.Environment.Permissions.UserMayEditContent; log.Add($"mid#{moduleId}, draft:{showDrafts}, template:{overrideTemplate?.Name}"); // Get ModuleDataSource var initialSource = DataSource.GetInitialDataSource(sxc.ZoneId, sxc.AppId, showDrafts, configurationProvider, parentLog); var moduleDataSource = DataSource.GetDataSource <ModuleDataSource>(sxc.ZoneId, sxc.AppId, initialSource, configurationProvider, parentLog); moduleDataSource.InstanceId = moduleId; moduleDataSource.OverrideTemplate = overrideTemplate; // new moduleDataSource.UseSxcInstanceContentGroup = true; // new // If the Template has a Data-Pipeline, use an empty upstream, else use the ModuleDataSource created above var viewDataSourceUpstream = overrideTemplate?.Pipeline == null ? moduleDataSource : null; log.Add($"use pipeline upstream:{viewDataSourceUpstream != null}"); var viewDataSource = DataSource.GetDataSource <ViewDataSource>(sxc.ZoneId, sxc.AppId, viewDataSourceUpstream, configurationProvider, parentLog); // Take Publish-Properties from the View-Template if (overrideTemplate != null) { viewDataSource.Publish.Enabled = overrideTemplate.PublishData; viewDataSource.Publish.Streams = overrideTemplate.StreamsToPublish; log.Add($"override template, & pipe#{overrideTemplate.Pipeline?.EntityId}"); // Append Streams of the Data-Pipeline (this doesn't require a change of the viewDataSource itself) if (overrideTemplate.Pipeline != null) { new DataPipelineFactory(parentLog).GetDataSource(sxc.AppId ?? -999, overrideTemplate.Pipeline /*.EntityId*/, configurationProvider, viewDataSource, showDrafts: showDrafts); } } else { log.Add("no template override"); } return(viewDataSource); }