public PositioningProcessor(AssetIconsCompiledStyle compiledStyleDefinition, AssetIconsStyle style) { widthProvider = new StaticValueProvider(new MathValue(1.0f, true)); heightProvider = new StaticValueProvider(new MathValue(1.0f, true)); var horizontalContext = new MathContextBuilder() .WithTerm("width", widthProvider) .WithTerm("height", heightProvider) .ImplicitlyReferences(widthProvider) .Build(); var verticalContext = new MathContextBuilder() .WithTerm("width", widthProvider) .WithTerm("height", heightProvider) .ImplicitlyReferences(heightProvider) .Build(); compiledWidth = CompiledExpression.Compile(style.Width, horizontalContext); compiledHeight = CompiledExpression.Compile(style.Height, verticalContext); compiledX = CompiledExpression.Compile(style.X, horizontalContext); compiledY = CompiledExpression.Compile(style.Y, verticalContext); compiledDisplay = CompiledExpression.Compile(style.Display, horizontalContext); styleAnchoring = compiledStyleDefinition.Anchor; }
// 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 SxcValueCollectionProvider(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(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); } return(provider); //return _valueCollectionProvider; }
// 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 void UseInvalidSetting_ExpectError() { var ds = TestSource1(); var settings = new Dictionary <string, string>(); settings.Add("DesiredDate", "Not today - should cause error"); var settingsValueProvider = new StaticValueProvider("Settings", settings); ds.ConfigurationProvider.Sources.Add(settingsValueProvider.Name, settingsValueProvider); Assert.AreEqual("Date Today", ds.List); }