// 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 LookUpEngine GetConfigProviderForModule(int moduleId, IApp app, IBlockBuilder blockBuilder) { var log = new Log("Stc.GetCnf", blockBuilder?.Log); // Find the standard DNN property sources if PortalSettings object is available (changed 2018-03-05) var dnnLookUps = Factory.Resolve <IGetEngine>().GetEngine(moduleId, blockBuilder?.Log); log.Add($"Environment provided {dnnLookUps.Sources.Count} sources"); var provider = new LookUpEngine(dnnLookUps, blockBuilder?.Log); // only add these in running inside an http-context. Otherwise leave them away! if (HttpContext.Current != null) { log.Add("Found HttpContext, will ty to add params for querystring, server etc."); var request = HttpContext.Current.Request; // new var paramList = new NameValueCollection(); if (blockBuilder?.Parameters != null) { foreach (var pair in blockBuilder.Parameters) { paramList.Add(pair.Key, pair.Value); } } else { paramList = request.QueryString; } provider.Add(new LookUpInNameValueCollection("querystring", paramList)); // old provider.Add(new LookUpInNameValueCollection("server", request.ServerVariables)); provider.Add(new LookUpInNameValueCollection("form", request.Form)); } else { log.Add("No HttpContext found, won't add http params to look-up"); } provider.Add(new LookUpInAppProperty("app", app)); // add module if it was not already added previously if (!provider.HasSource("module")) { var modulePropertyAccess = new LookUpInDictionary("module"); modulePropertyAccess.Properties.Add("ModuleID", moduleId.ToString(CultureInfo.InvariantCulture)); provider.Add(modulePropertyAccess); } // provide the current SxcInstance to the children where necessary if (!provider.HasSource(LookUpConstants.InstanceContext) && blockBuilder != null) { var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, blockBuilder); provider.Add(blockBuilderLookUp); } return(provider); }
// 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 LookUpEngine GetConfigProviderForModule(IContextOfSite context, IApp appForLookup, IBlock blockForLookup) { var modId = (context as ContextOfBlock)?.Module.Id ?? 0; var wrapLog = Log.Call <LookUpEngine>($"{modId}, ..., ..."); // Find the standard DNN property sources if PortalSettings object is available var envLookups = _getEngineLazy.Value.Init(Log).GetLookUpEngine(modId); Log.Add($"Environment provided {envLookups.Sources.Count} sources"); var provider = new LookUpEngine(envLookups, Log); // Add QueryString etc. when running inside an http-context. Otherwise leave them away! var http = _httpLazy.Value; if (http.Current != null) { Log.Add("Found Http-Context, will ty to add params for querystring, server etc."); // new var paramList = new NameValueCollection(); var ctxWithPage = context as IContextOfBlock; if (ctxWithPage?.Page.Parameters != null) { foreach (var pair in ctxWithPage.Page.Parameters) { paramList.Add(pair.Key, pair.Value); } } else { paramList = http.QueryStringParams; } provider.Add(new LookUpInNameValueCollection("querystring", paramList)); // old #if NET451 provider.Add(new LookUpInNameValueCollection("server", http.Request.ServerVariables)); provider.Add(new LookUpInNameValueCollection("form", http.Request.Form)); #else // "Not Yet Implemented in .net standard #TodoNetStandard" - might not actually support this #endif } else { Log.Add("No Http-Context found, won't add http params to look-up"); } provider.Add(new LookUpInAppProperty("app", appForLookup)); // add module if it was not already added previously if (!provider.HasSource(CmsBlock.InstanceLookupName)) { var modulePropertyAccess = new LookUpInDictionary(CmsBlock.InstanceLookupName); modulePropertyAccess.Properties.Add(CmsBlock.InstanceIdKey, modId.ToString(CultureInfo.InvariantCulture)); provider.Add(modulePropertyAccess); } // provide the current SxcInstance to the children where necessary if (!provider.HasSource(LookUpConstants.InstanceContext) && blockForLookup != null) { var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, blockForLookup); provider.Add(blockBuilderLookUp); } return(wrapLog("ok", provider)); }
// 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 LookUpEngine GetConfigProviderForModule(int moduleId, IApp app, IBlock block) { var log = new Log("Stc.GetCnf", block?.Log); // Find the standard DNN property sources if PortalSettings object is available var envLookups = Factory.Resolve <IGetEngine>().GetEngine(moduleId, block?.Log); log.Add($"Environment provided {envLookups.Sources.Count} sources"); var provider = new LookUpEngine(envLookups, block?.Log); // Add QueryString etc. when running inside an http-context. Otherwise leave them away! var http = Factory.Resolve <IHttp>(); if (http.Current != null) { log.Add("Found Http-Context, will ty to add params for querystring, server etc."); // new var paramList = new NameValueCollection(); if (block?.Context.Page.Parameters != null) { foreach (var pair in block.Context.Page.Parameters) { paramList.Add(pair.Key, pair.Value); } } else { paramList = http.QueryString; } provider.Add(new LookUpInNameValueCollection("querystring", paramList)); // old #if NET451 provider.Add(new LookUpInNameValueCollection("server", http.Request.ServerVariables)); provider.Add(new LookUpInNameValueCollection("form", http.Request.Form)); #else // "Not Yet Implemented in .net standard #TodoNetStandard" - might not actually support this #endif } else { log.Add("No Http-Context found, won't add http params to look-up"); } provider.Add(new LookUpInAppProperty("app", app)); // add module if it was not already added previously if (!provider.HasSource(CmsBlock.InstanceLookupName /* "module"*/)) { var modulePropertyAccess = new LookUpInDictionary(CmsBlock.InstanceLookupName /*"module"*/); modulePropertyAccess.Properties.Add(CmsBlock.InstanceIdKey /*"ModuleID"*/, moduleId.ToString(CultureInfo.InvariantCulture)); provider.Add(modulePropertyAccess); } // provide the current SxcInstance to the children where necessary if (!provider.HasSource(LookUpConstants.InstanceContext) && block != null) { var blockBuilderLookUp = new LookUpCmsBlock(LookUpConstants.InstanceContext, block); provider.Add(blockBuilderLookUp); } return(provider); }