public override object Execute(ParameterList parameters, FunctionContextContainer context) { SitemapScope SitemapScope; if (parameters.TryGetParameter<SitemapScope>("SitemapScope", out SitemapScope) == false) { SitemapScope = SitemapScope.Current; } Guid pageId = Guid.Empty; switch (SitemapScope) { case SitemapScope.Current: pageId = PageRenderer.CurrentPageId; break; case SitemapScope.Parent: case SitemapScope.Level1: case SitemapScope.Level2: case SitemapScope.Level3: case SitemapScope.Level4: IEnumerable<Guid> pageIds = PageStructureInfo.GetAssociatedPageIds(PageRenderer.CurrentPageId, SitemapScope); pageId = pageIds.FirstOrDefault(); break; default: throw new NotImplementedException("Unhandled SitemapScope type: " + SitemapScope.ToString()); } return pageId; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { IEnumerable<string> strings = parameters.GetParameter<IEnumerable<string>>("Strings"); string separator = parameters.GetParameter<string>("Separator"); return string.Join(separator, strings.ToArray()); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { IComparable valueA = parameters.GetParameter<IComparable>("ValueA"); IComparable valueB = parameters.GetParameter<IComparable>("ValueB"); return valueA.CompareTo(valueB); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { return new TitleControl { PrefixToRemove = parameters.GetParameter<string>("PrefixToRemove"), PostfixToRemove = parameters.GetParameter<string>("PostfixToRemove") }; }
// IFunctionResultToXElementMapper public bool TryMakeXEmbedable(FunctionContextContainer contextContainer, object resultObject, out XNode resultElement) { var control = resultObject as Control; if (control == null) { resultElement = null; return false; } string controlMarkerKey; lock (_controls) { controlMarkerKey = string.Format("[Composite.Function.Render.Asp.Net.Control.{0}]", _controls.Count); _controls.Add(controlMarkerKey, control); } resultElement = XElement.Parse(@"<c1marker:{0} xmlns:c1marker=""{1}"" key=""{2}"" />" .FormatWith(_markerElementName.LocalName, _markerElementName.Namespace, controlMarkerKey)); return true; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { var result = new XhtmlDocument(); var functionCall = new XElement(Composite.Core.Xml.Namespaces.Function10 + "function", new XAttribute("name", "Composite.Forms.RendererControl")); BaseRuntimeTreeNode paramNode = null; foreach (var parameterName in parameters.AllParameterNames) { try { if (parameters.TryGetParameterRuntimeTreeNode(parameterName, out paramNode)) { functionCall.Add(paramNode.Serialize()); } } //Ignore catch { } } result.Body.Add( new XElement(Namespaces.AspNetControls + "form", functionCall)); return result; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { string commaSeparatedSearchTerms = parameters.GetParameter<string>("CommaSeparatedGuids"); if (!commaSeparatedSearchTerms.IsNullOrEmpty()) { ParameterExpression parameter = Expression.Parameter(typeof(Guid), "g"); IEnumerable<string> guidStrings = commaSeparatedSearchTerms.Split(','); Expression body = null; foreach (string guidString in guidStrings) { Guid temp = new Guid(guidString.Trim()); Expression part = Expression.Equal(parameter, Expression.Constant(temp)); body = body.NestedOr(part); } if(body != null) { return Expression.Lambda<Func<Guid, bool>>(body, parameter); } } return (Expression<Func<Guid, bool>>) (f => false); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { IEnumerable elements = parameters.GetParameter<IEnumerable>("Elements"); string keyPropertyName = parameters.GetParameter<string>("KeyPropertyName"); string valuePropertyName = parameters.GetParameter<string>("ValuePropertyName"); Dictionary<string, string> resultDictionary = new Dictionary<string, string>(); PropertyInfo keyPropertyInfo = null; PropertyInfo valuePropertyInfo = null; foreach (object element in elements) { if (keyPropertyInfo == null) { keyPropertyInfo = element.GetType().GetProperty(keyPropertyName); } if (valuePropertyInfo == null) { valuePropertyInfo = element.GetType().GetProperty(valuePropertyName); } string keyValue = keyPropertyInfo.GetValue(element, null).ToString(); string valueValue = valuePropertyInfo.GetValue(element, null).ToString(); resultDictionary.Add(keyValue, valueValue); } return resultDictionary; }
/// <exclude /> public static T Execute <T>(IFunction function) { Dictionary <string, object> parameters = new Dictionary <string, object>(); FunctionContextContainer container = new FunctionContextContainer(); return(Execute <T>(function, parameters, container)); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { object valueA = parameters.GetParameter<object>("ValueA"); object valueB = parameters.GetParameter<object>("ValueB"); return valueA.Equals(valueB); }
/// <exclude /> public override object GetValue(FunctionContextContainer contextContainer) { if (contextContainer == null) { throw new ArgumentNullException("contextContainer"); } ValidateNotSelfCalling(); ParameterList parameters = new ParameterList(contextContainer); foreach (ParameterProfile parameterProfile in _widgetFunction.ParameterProfiles) { BaseParameterRuntimeTreeNode parameterTreeNode = this.Parameters.Where(ptn => ptn.Name == parameterProfile.Name).SingleOrDefault(); if (parameterTreeNode == null) { BaseValueProvider valueProvider = parameterProfile.FallbackValueProvider; object value = valueProvider.GetValue(contextContainer); parameters.AddConstantParameter(parameterProfile.Name, value, parameterProfile.Type); } else { parameters.AddLazyParameter(parameterProfile.Name, parameterTreeNode, parameterProfile.Type); } } return(_widgetFunction.GetWidgetMarkup(parameters, this.Label, this.HelpDefinition, this.BindingSourceName)); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { var result = new List<FormEmail>(); result.AddRange(parameters.GetParameter<IEnumerable<FormEmail>>("EmailA")); result.AddRange(parameters.GetParameter<IEnumerable<FormEmail>>("EmailB")); return result; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { var metaTags = new List<XElement>(); string contentType = parameters.GetParameter<string>("ContentType"); string designer = parameters.GetParameter<string>("Designer"); bool showGenerator = parameters.GetParameter<bool>("ShowGenerator"); if (!string.IsNullOrWhiteSpace(contentType)) { metaTags.Add(new XElement(Namespaces.Xhtml + "meta", new XAttribute("http-equiv", "Content-Type"), new XAttribute("content", contentType))); } if (!string.IsNullOrWhiteSpace(designer)) { metaTags.Add(new XElement(Namespaces.Xhtml + "meta", new XAttribute("name", "Designer"), new XAttribute("content", designer))); } if (showGenerator) { metaTags.Add(new XElement(Namespaces.Xhtml + "meta", new XAttribute("name", "Generator"), new XAttribute("content", "Composite C1 CMS - Free Open Source from http://composite.net/"))); } return metaTags; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { return new XsltExtensionDefinition<GlobalizationXsltExtensions> { EntensionObject = new GlobalizationXsltExtensions(), ExtensionNamespace = "#globalizationExtensions" }; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { return new XsltExtensionDefinition<DateFormattingXsltExtensions> { EntensionObject = new DateFormattingXsltExtensions(), ExtensionNamespace = "#dateExtensions" }; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { string stringA = parameters.GetParameter<string>("StringA"); string stringB = parameters.GetParameter<string>("StringB"); string separator = parameters.GetParameter<string>("Separator"); return stringA + separator + stringB; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { return new XsltExtensionDefinition<MarkupParserXsltExtensions> { EntensionObject = new MarkupParserXsltExtensions(), ExtensionNamespace = "#MarkupParserExtensions" }; }
public override object GetValue(FunctionContextContainer contextContainer) { if (contextContainer == null) throw new ArgumentNullException("contextContainer"); Initialize(); return _functionFunctionRuntimeNode.GetValue(contextContainer); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { return HttpContext.Current.Request.Browser.Crawler; } return false; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { string stringToSplit = parameters.GetParameter<string>("String"); string[] separator = new string[] { parameters.GetParameter<string>("Separator") }; var resultArray = stringToSplit.Split(separator, StringSplitOptions.RemoveEmptyEntries); return new List<string>(resultArray); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { return HttpContext.Current.Request.Browser.EcmaScriptVersion; } return null; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { HttpContext.Current.Session[parameters.GetParameter<string>("VariableName")] = parameters.GetParameter<string>("Value"); } return null; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { string path = parameters.GetParameter<string>("Path"); Page currentPage = HttpContext.Current.Handler as Page; if (currentPage == null) throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page"); return currentPage.LoadControl(path); }
public override object GetValue(FunctionContextContainer contextContainer) { if (!_evaluated) { _result = _getValueFunction(); _evaluated = true; } return _result; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { var codeAttributeDeclaration = new CodeAttributeDeclaration(new CodeTypeReference(typeof(RegexValidatorAttribute))); string pattern = parameters.GetParameter<string>("pattern"); codeAttributeDeclaration.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(pattern))); return new ConstructorBasedPropertyValidatorBuilder<string>(codeAttributeDeclaration, new RegexValidatorAttribute(pattern)); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { var codeAttributeDeclaration = new CodeAttributeDeclaration(new CodeTypeReference(typeof(DecimalPrecisionValidatorAttribute))); int maxDigits = parameters.GetParameter<int>("MaxDigits"); codeAttributeDeclaration.Arguments.Add(new CodeAttributeArgument(new CodePrimitiveExpression(maxDigits))); return new ConstructorBasedPropertyValidatorBuilder<decimal>(codeAttributeDeclaration, new DecimalPrecisionValidatorAttribute(28, maxDigits)); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { Guid value = parameters.GetParameter<Guid>("Value"); // Expression<Func<Guid, bool>> predicate = f => f == value; // DDZ: in order to get a correct debug information, not using labmda syntax while building an expression ParameterExpression parameter = Expression.Parameter(typeof(Guid), "f"); return Expression.Lambda<Func<Guid, bool>>(Expression.Equal(parameter, Expression.Constant(value)), parameter); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { Guid? value = parameters.GetParameter<Guid?>("Value"); // Expression<Func<Guid?, bool>> predicate = f => f == value; var f = Expression.Parameter(typeof(Guid?), "f"); var body = Expression.Equal(f, Expression.Constant(value, typeof (Guid?))); return Expression.Lambda(body, f); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { string result = HttpContext.Current.Request.QueryString[parameters.GetParameter<string>("ParameterName")]; if (result != null) return new Guid(result); } return parameters.GetParameter<Guid>("FallbackValue"); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { Page currentPage = HttpContext.Current.Handler as Page; if (currentPage == null) throw new InvalidOperationException("The Current HttpContext Handler must be a System.Web.Ui.Page"); Control control = currentPage.LoadControl("~/Frontend/Composite/Forms/Renderer/Controls/FormsRender.ascx"); control.GetType().GetProperty("parameters").SetValue(control, parameters, null); return control; }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { object result = HttpContext.Current.Session[parameters.GetParameter<string>("VariableName")]; if (result != null) return result.ToString(); } return parameters.GetParameter<string>("FallbackValue"); }
public override object GetValue(FunctionContextContainer contextContainer) { if (contextContainer == null) { throw new ArgumentNullException("contextContainer"); } Initialize(); return(_functionFunctionRuntimeNode.GetValue(contextContainer)); }
public override object Execute(ParameterList parameters, FunctionContextContainer context) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { string result = HttpContext.Current.Request.Form[parameters.GetParameter<string>("ParameterName")]; if (result != null) return decimal.Parse(result); } return parameters.GetParameter<decimal>("FallbackValue"); }
public override object GetValue(FunctionContextContainer contextContainer, Type type) { Verify.ArgumentNotNull(contextContainer, "contextContainer"); Verify.ArgumentNotNull(type, "type"); if (_attribute != null) { return(XmlSerializationHelper.Deserialize(_attribute, type)); } return(ValueTypeConverter.Convert(_constantValue, type)); }
private XElement ExecuteInnerFunctions(FunctionContextContainer contextContainer) { XElement resultRoot = new XElement(_element); int loopCount = 0; while (true) { XName functionXName = Namespaces.Function10 + FunctionTreeConfigurationNames.FunctionTagName; IEnumerable <XElement> nestedFunctionCalls = resultRoot.Descendants(functionXName).Where(f => !f.Ancestors(functionXName).Any()); var evaluatedListOfInnerFunctions = nestedFunctionCalls.ToList(); if (!evaluatedListOfInnerFunctions.Any()) { break; } if (loopCount++ > 1000) { throw new InvalidOperationException("One or more function seems to be returning markup generating endless recursion. The following markup seems to generate the problem: " + evaluatedListOfInnerFunctions.First().ToString()); } var functionCallResults = new object[evaluatedListOfInnerFunctions.Count]; for (int i = 0; i < evaluatedListOfInnerFunctions.Count; i++) { XElement functionCallDefinition = evaluatedListOfInnerFunctions[i]; BaseRuntimeTreeNode runtimeTreeNode = FunctionTreeBuilder.Build(functionCallDefinition); functionCallResults[i] = runtimeTreeNode.GetValue(contextContainer); } ; for (int i = 0; i < evaluatedListOfInnerFunctions.Count; i++) { object embedableResult = contextContainer.MakeXEmbedable(functionCallResults[i]); if (embedableResult is XAttribute) { evaluatedListOfInnerFunctions[i].Parent.Add(embedableResult); evaluatedListOfInnerFunctions[i].Remove(); } else { evaluatedListOfInnerFunctions[i].ReplaceWith(embedableResult); } } } return(resultRoot); }
/// <exclude /> public virtual T GetValue <T>(FunctionContextContainer contextContainer) { object value = this.GetValue(contextContainer); if (value == null || value is T) { return((T)value); } else { return(ValueTypeConverter.Convert <T>(value)); } }
/// <exclude /> public virtual object GetValue(FunctionContextContainer contextContainer, Type type) { Verify.ArgumentNotNull(contextContainer, "contextContainer"); object value = this.GetValue(contextContainer); if (value == null || type.IsInstanceOfType(value)) { return(value); } return(ValueTypeConverter.Convert(value, type)); }
private static object EvaluateTreeNode(object node, Type type, FunctionContextContainer functionContextContainer) { if (node is BaseRuntimeTreeNode) { node = ((BaseRuntimeTreeNode)node).GetValue(functionContextContainer, type); } if (node != null && !type.IsInstanceOfType(node)) { node = ValueTypeConverter.Convert(node, type); } return(node); }
/// <exclude /> public static T Execute <T>(IFunction function, System.Collections.Specialized.NameValueCollection parameterValues) { Dictionary <string, object> parameters = new Dictionary <string, object>(); foreach (var parameterName in parameterValues.AllKeys) { if (parameterName != null && parameterValues[parameterName] != null) { parameters.Add(parameterName, parameterValues[parameterName]); } } FunctionContextContainer container = new FunctionContextContainer(); return(Execute <T>(function, parameters, container)); }
/// <exclude /> public ParameterList(FunctionContextContainer functionContextContainer) { _functionContextContainer = functionContextContainer; }
/// <exclude /> public override object GetValue(FunctionContextContainer contextContainer) { return(_constantValue); }
/// <exclude /> public FunctionContextContainer(FunctionContextContainer inheritFromContainer, Dictionary <string, object> parameterDictionary) { _parameterDictionary = parameterDictionary; this.XEmbedableMapper = inheritFromContainer.XEmbedableMapper; this.SuppressXhtmlExceptions = inheritFromContainer.SuppressXhtmlExceptions; }
/// <exclude /> public override object GetValue(FunctionContextContainer contextContainer) { throw new InvalidOperationException("No value exists"); }
/// <exclude /> public abstract object GetValue(FunctionContextContainer contextContainer);
/// <exclude /> public object GetValue() { FunctionContextContainer internalContextContainer = new FunctionContextContainer(); return(GetValue(internalContextContainer)); }
/// <exclude /> public override object GetValue(FunctionContextContainer contextContainer) { if (contextContainer == null) { throw new ArgumentNullException("contextContainer"); } string functionName = _function.CompositeName() ?? "<unknown function>"; using (TimerProfilerFacade.CreateTimerProfiler(functionName)) { ValidateNotSelfCalling(); try { var parameters = new ParameterList(contextContainer); foreach (ParameterProfile parameterProfile in _function.ParameterProfiles) { List <BaseParameterRuntimeTreeNode> parameterTreeNodes = this.Parameters.Where(ptn => ptn.Name == parameterProfile.Name).ToList(); if (parameterTreeNodes.Count > 0) { parameters.AddLazyParameter(parameterProfile.Name, parameterTreeNodes[0], parameterProfile.Type); continue; } if (parameterProfile.Type.IsGenericType && parameterProfile.Type.GetGenericTypeDefinition() == typeof(NullableDataReference <>)) { parameters.AddConstantParameter(parameterProfile.Name, null, parameterProfile.Type); continue; } if (parameterProfile.IsRequired) { var injectedValue = TryGetInjectedValue(parameterProfile.Type); if (injectedValue == null) { throw new ArgumentException("Missing parameter '{0}' (type of {1})".FormatWith(parameterProfile.Name, parameterProfile.Type.FullName)); } parameters.AddConstantParameter(parameterProfile.Name, injectedValue, parameterProfile.Type); continue; } BaseValueProvider valueProvider = parameterProfile.FallbackValueProvider; object value; try { value = valueProvider.GetValue(contextContainer); } catch (Exception ex) { throw new InvalidOperationException($"Failed to get value for parameter '{parameterProfile.Name}' in function '{functionName}'.", ex); } parameters.AddConstantParameter(parameterProfile.Name, value, parameterProfile.Type, true); } object result; IDisposable measurement = null; try { if (functionName != "Composite.Utils.GetInputParameter") { var nodeToLog = functionName; if (_function is IDynamicFunction df && df.PreventFunctionOutputCaching) { nodeToLog += " (PreventCaching)"; } measurement = Profiler.Measure(nodeToLog, () => _function.EntityToken); } result = _function.Execute(parameters, contextContainer); } finally { measurement?.Dispose(); } return(result); } catch (ThreadAbortException) { return(null); // Nothing will be returned as ThreadAbort will propagate } catch (Exception ex) { throw new InvalidOperationException($"Failed to get value for function '{functionName}'", ex); } } }
/// <exclude /> public static T Execute <T>(IFunction function, IDictionary <string, object> parameters) { var functionContextContainer = new FunctionContextContainer(); return(Execute <T>(function, parameters, functionContextContainer)); }
public override object GetValue(FunctionContextContainer contextContainer) { Verify.ArgumentNotNull(contextContainer, "contextContainer"); return(_attribute != null ? _attribute.Value : _constantValue); }
public override object GetValue(FunctionContextContainer contextContainer) { Verify.ArgumentNotNull(contextContainer, "contextContainer"); return(ExecuteInnerFunctions(contextContainer)); }
/// <exclude /> public static T Execute <T>(IFunction function, IDictionary <string, object> parameters, FunctionContextContainer functionContextContainer) { BaseRuntimeTreeNode node = BuildTree(function, parameters); return((T)node.GetValue(functionContextContainer)); }
//public static XElement GetWidgetMarkup(IWidgetFunction widgetFunction, Type targetType, IDictionary<string, object> parameters, string label, HelpDefinition helpDefinition, string bindingSourceName, FunctionContextContainer functionContextContainer) //{ // List<BaseParameterRuntimeTreeNode> parameterNodes = new List<BaseParameterRuntimeTreeNode>(); // if (parameters != null) // { // foreach (KeyValuePair<string, object> kvp in parameters) // { // parameterNodes.Add(new ConstantObjectParameterRuntimeTreeNode(kvp.Key, kvp.Value)); // } // } // BaseRuntimeTreeNode node = new WidgetFunctionRuntimeTreeNode(widgetFunction, label, helpDefinition, bindingSourceName, parameterNodes); // return (XElement)node.GetValue(functionContextContainer); //} /// <exclude /> public static XElement GetWidgetMarkup(IWidgetFunction widgetFunction, Type targetType, IEnumerable <BaseParameterRuntimeTreeNode> parameters, string label, HelpDefinition helpDefinition, string bindingSourceName, FunctionContextContainer functionContextContainer) { List <BaseParameterRuntimeTreeNode> parameterNodes = new List <BaseParameterRuntimeTreeNode>(); if (parameters != null) { foreach (BaseParameterRuntimeTreeNode parameterNode in parameters) { parameterNodes.Add(parameterNode); } } BaseRuntimeTreeNode node = new WidgetFunctionRuntimeTreeNode(widgetFunction, label, helpDefinition, bindingSourceName, parameterNodes); return((XElement)node.GetValue(functionContextContainer)); }
/// <exclude /> public T GetValue <T>() { FunctionContextContainer internalContextContainer = new FunctionContextContainer(); return(GetValue <T>(internalContextContainer)); }
/// <exclude /> public override object GetValue(FunctionContextContainer contextContainer) { Verify.ArgumentNotNull(contextContainer, "contextContainer"); return(_functionNode.GetValue(contextContainer)); }
/// <exclude /> public T GetValue <T>(FunctionContextContainer contextContainer) { return((T)GetValue(contextContainer, typeof(T))); }