/// <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); }
private ParameterProfile BuildParameterProfile(IParameter parameter) { Type parameterType = TypeManager.GetType(parameter.TypeManagerName); bool isRequired = false; BaseValueProvider defaultValueProvider; if (string.IsNullOrEmpty(parameter.DefaultValueFunctionMarkup)) { defaultValueProvider = new NoValueValueProvider(); isRequired = true; } else { defaultValueProvider = new FunctionValueProvider(XElement.Parse(parameter.DefaultValueFunctionMarkup)); } WidgetFunctionProvider widgetFunctionProvider; if (string.IsNullOrEmpty(parameter.WidgetFunctionMarkup) == false) { widgetFunctionProvider = new WidgetFunctionProvider(XElement.Parse(parameter.WidgetFunctionMarkup)); } else { widgetFunctionProvider = WidgetFunctionProvider.BuildNoWidgetProvider(); } return(new ParameterProfile(parameter.Name, parameterType, isRequired, defaultValueProvider, widgetFunctionProvider, parameter.Label, new HelpDefinition(parameter.HelpText))); }