private static Dictionary <string, object> BuildTestParameterInput(IEnumerable <ManagedParameterDefinition> parameters) { Dictionary <string, object> inputValues = new Dictionary <string, object>(); foreach (ManagedParameterDefinition parameterDefinition in parameters) { object value = null; if (string.IsNullOrEmpty(parameterDefinition.TestValueFunctionMarkup) == false) { FunctionRuntimeTreeNode functionNode = (FunctionRuntimeTreeNode)FunctionTreeBuilder.Build(XElement.Parse(parameterDefinition.TestValueFunctionMarkup)); value = functionNode.GetValue(); } else { if (string.IsNullOrEmpty(parameterDefinition.DefaultValueFunctionMarkup) == false) { FunctionRuntimeTreeNode functionNode = (FunctionRuntimeTreeNode)FunctionTreeBuilder.Build(XElement.Parse(parameterDefinition.DefaultValueFunctionMarkup)); value = functionNode.GetValue(); } } if (value != null) { if (parameterDefinition.Type.IsAssignableFrom(value.GetType()) == false) { value = ValueTypeConverter.Convert(value, parameterDefinition.Type); } inputValues.Add(parameterDefinition.Name, value); } } return(inputValues); }
/// <exclude /> public static ParameterList GetParametersListForTest(IEnumerable <ManagedParameterDefinition> parameterDefinitions) { ParameterList parameterList = new ParameterList(null); foreach (var parameterDefinition in parameterDefinitions) { if (!parameterDefinition.TestValueFunctionMarkup.IsNullOrEmpty()) { FunctionRuntimeTreeNode functionNode = (FunctionRuntimeTreeNode)FunctionTreeBuilder.Build(XElement.Parse(parameterDefinition.TestValueFunctionMarkup)); FunctionValueProvider valueProvider = new FunctionValueProvider(functionNode); object value = valueProvider.GetValue(); parameterList.AddConstantParameter(parameterDefinition.Name, value, parameterDefinition.Type); } else if (!parameterDefinition.DefaultValueFunctionMarkup.IsNullOrEmpty()) { FunctionRuntimeTreeNode functionNode = (FunctionRuntimeTreeNode)FunctionTreeBuilder.Build(XElement.Parse(parameterDefinition.DefaultValueFunctionMarkup)); FunctionValueProvider valueProvider = new FunctionValueProvider(functionNode); object value = valueProvider.GetValue(); parameterList.AddConstantParameter(parameterDefinition.Name, value, parameterDefinition.Type); } else { throw new InvalidOperationException("Parameter '{0}' have neigther 'test value' nor 'default value' specified.".FormatWith(parameterDefinition.Name)); } } return(parameterList); }
/// <summary> /// Executes the function. Note that all the XhtmlParameters will have all the nested >f:function /< lazily evaluated /// </summary> private static object ExecuteFunction(IFunction function, IDictionary <string, object> parameters, FunctionContextContainer functionContextContainer) { List <BaseParameterRuntimeTreeNode> parameterNodes = new List <BaseParameterRuntimeTreeNode>(); if (parameters != null) { foreach (KeyValuePair <string, object> kvp in parameters) { var value = kvp.Value; if (value is XhtmlDocument) { parameterNodes.Add(new LazyParameterRuntimeTreeNode(kvp.Key, () => ExecuteNestedFunctions(value as XhtmlDocument, functionContextContainer))); } else { parameterNodes.Add(new ConstantObjectParameterRuntimeTreeNode(kvp.Key, kvp.Value)); } } } var treeNode = new FunctionRuntimeTreeNode(function, parameterNodes); return(treeNode.GetValue(functionContextContainer)); }
public object GetResult() { IFunction function = FunctionFacade.GetFunction(this.name); FunctionRuntimeTreeNode functionNode = new FunctionRuntimeTreeNode(function, this.Producers); return(functionNode); }
public object GetResult() { IFunction function = FunctionFacade.GetFunction(this.name); FunctionRuntimeTreeNode functionNode = new FunctionRuntimeTreeNode(function, this.Producers); return functionNode; }
protected void Page_PreRender(object sender, EventArgs e) { if (CurrentlySelectedFieldId != Guid.Empty) { var defaultFunction = StandardFunctions.GetDefaultFunctionByType(this.CurrentlySelectedType); btnDefaultValueFunctionMarkup.Attributes["label"] = GetString(btnDefaultValueFunctionMarkup.Value.IsNullOrEmpty() ? "DefaultValueSpecify" : "DefaultValueEdit"); btnDefaultValueFunctionMarkup.Attributes["url"] = "${root}/content/dialogs/functions/editFunctionCall.aspx?type=" + this.CurrentlySelectedType.FullName + "&dialoglabel=" + HttpUtility.UrlEncodeUnicode(GetString("DefaultValueDialogLabel")) + "&multimode=false&functionmarkup="; btnTestValueFunctionMarkup.Attributes["label"] = GetString(btnTestValueFunctionMarkup.Value.IsNullOrEmpty() ? "TestValueSpecify" : "TestValueEdit"); btnTestValueFunctionMarkup.Attributes["url"] = "${root}/content/dialogs/functions/editFunctionCall.aspx?type=" + this.CurrentlySelectedType.FullName + "&dialoglabel=" + HttpUtility.UrlEncodeUnicode(GetString("TestValueDialogLabel")) + "&multimode=false&functionmarkup="; btnWidgetFunctionMarkup.Attributes["label"] = CurrentlySelectedWidgetText; btnWidgetFunctionMarkup.Attributes["url"] = "${root}/content/dialogs/functions/editFunctionCall.aspx?functiontype=widget&type=" + this.CurrentlySelectedWidgetReturnType.FullName + "&dialoglabel=" + HttpUtility.UrlEncodeUnicode(GetString("WidgetDialogLabel")) + "&multimode=false&functionmarkup="; if (defaultFunction != null) { string defaultValue = new FunctionRuntimeTreeNode(defaultFunction).Serialize().ToString(); btnDefaultValueFunctionMarkup.DefaultValue = defaultValue; btnTestValueFunctionMarkup.DefaultValue = defaultValue; } } btnDelete.Attributes["isdisabled"] = CurrentlySelectedFieldId == Guid.Empty ? "true" : "false"; if (nameChanged) { UpdateFieldsPanel(); } _state.Parameters = this.CurrentFields.ToList(); SessionStateManager.GetProvider(SessionStateProviderName).SetState(StateId, _state, DateTime.Now.AddDays(7.0)); }
/// <exclude /> public static IEnumerable <NamedFunctionCall> GetValidFunctionCalls(Guid xsltFunctionId, out List <string> errors) { errors = null; List <NamedFunctionCall> result = new List <NamedFunctionCall>(); foreach (INamedFunctionCall namedFunctionCallData in DataFacade.GetData <INamedFunctionCall>(f => f.XsltFunctionId == xsltFunctionId)) { XElement functionElement = XElement.Parse(namedFunctionCallData.SerializedFunction); FunctionRuntimeTreeNode function = null; try { function = (FunctionRuntimeTreeNode)FunctionTreeBuilder.Build(functionElement); } catch (Exception ex) { string errDescriptionForLog = string.Format("XSLT Function call markup for failed to parse ('{0}').\nThe markup was \n{1}", ex.Message, functionElement); string errDescriptionForUser = string.Format("XSLT Function call markup for failed to parse ('{0}').\nPlease see server log for more details.", ex.Message); LoggingService.LogError("Function parse error", errDescriptionForLog); if (errors == null) { errors = new List <string>(); } errors.Add(errDescriptionForUser); } if (function != null) { result.Add(new NamedFunctionCall(namedFunctionCallData.Name, function)); } } return(result); }