private bool CanConvert(IStepArgumentTransformationBinding stepTransformationBinding, object value, IBindingType typeToConvertTo, CultureInfo cultureInfo) { if (!stepTransformationBinding.Method.ReturnType.TypeEquals(typeToConvertTo)) { return(false); } if (stepTransformationBinding.Regex != null && !(value is string)) { return(false); } var arguments = GetStepTransformationArguments(stepTransformationBinding, value, cultureInfo); var parameters = stepTransformationBinding.Method.Parameters.ToArray(); if (arguments == null || arguments.Length != parameters.Length) { return(false); } for (var i = 0; i < parameters.Length; i++) { if (!stepArgumentTypeConverter.CanConvert(arguments[i], parameters[i].Type, cultureInfo)) { return(false); } } return(true); }
private object[] GetStepTransformationArguments(IStepArgumentTransformationBinding stepTransformation, object value, CultureInfo cultureInfo) { if (stepTransformation.Regex != null && value is string) { return(GetStepTransformationArgumentsFromRegex(stepTransformation, (string)value, cultureInfo)); } return(new[] { value }); }
private object[] GetStepTransformationArgumentsFromRegex(IStepArgumentTransformationBinding stepTransformation, string stepSnippet, CultureInfo cultureInfo) { var match = stepTransformation.Regex.Match(stepSnippet); var argumentStrings = match.Groups.Cast<Group>().Skip(1).Select(g => g.Value); var bindingParameters = stepTransformation.Method.Parameters.ToArray(); return argumentStrings .Select((arg, argIndex) => stepArgumentTypeConverter.Convert(arg, bindingParameters[argIndex].Type, cultureInfo)) .ToArray(); }
private object[] GetStepTransformationArgumentsFromRegex(IStepArgumentTransformationBinding stepTransformation, string stepSnippet, CultureInfo cultureInfo) { var match = stepTransformation.Regex.Match(stepSnippet); var argumentStrings = match.Groups.Cast <Group>().Skip(1).Select(g => g.Value); var bindingParameters = stepTransformation.Method.Parameters.ToArray(); return(argumentStrings .Select((arg, argIndex) => stepArgumentTypeConverter.Convert(arg, bindingParameters[argIndex].Type, cultureInfo)) .ToArray()); }
private object DoTransform(IStepArgumentTransformationBinding stepTransformationBinding, object value, CultureInfo cultureInfo) { var parameters = stepTransformationBinding.Method.Parameters.ToArray(); var arguments = GetStepTransformationArguments(stepTransformationBinding, value, cultureInfo) .Select((arg, i) => stepArgumentTypeConverter.Convert(arg, parameters[i].Type, cultureInfo)).ToArray(); TimeSpan duration; return(bindingInvoker.InvokeBinding(stepTransformationBinding, contextManager, arguments, testTracer, out duration)); }
private object[] GetStepTransformationArgumentsFromRegex(IStepArgumentTransformationBinding stepTransformation, string stepSnippet, CultureInfo cultureInfo) { var match = stepTransformation.Regex.Match(stepSnippet); if (!match.Success) { return(null); } return(match.Groups.Cast <Group>().Skip(1).Select(g => g.Value).Cast <object>().ToArray()); }
private object DoTransform(IStepArgumentTransformationBinding stepTransformation, object value, CultureInfo cultureInfo) { object[] arguments; if (stepTransformation.Regex != null && value is string) arguments = GetStepTransformationArgumentsFromRegex(stepTransformation, (string)value, cultureInfo); else arguments = new object[] { value }; TimeSpan duration; return bindingInvoker.InvokeBinding(stepTransformation, contextManager, arguments, testTracer, out duration); }
private bool CanConvert(IStepArgumentTransformationBinding stepTransformationBinding, object value, IBindingType typeToConvertTo) { if (!stepTransformationBinding.Method.ReturnType.TypeEquals(typeToConvertTo)) return false; if (stepTransformationBinding.Regex != null) { return value is string && stepTransformationBinding.Regex.IsMatch((string)value); } return stepTransformationBinding.Method.Parameters.Count() == 1; }
private bool CanConvert(IStepArgumentTransformationBinding stepTransformationBinding, object value, IBindingType typeToConvertTo) { if (!stepTransformationBinding.Method.ReturnType.TypeEquals(typeToConvertTo)) { return(false); } if (stepTransformationBinding.Regex != null && value is string) { return(stepTransformationBinding.Regex.IsMatch((string)value)); } return(true); }
private async Task <object[]> GetStepTransformationArgumentsFromRegexAsync(IStepArgumentTransformationBinding stepTransformation, string stepSnippet, CultureInfo cultureInfo) { var match = stepTransformation.Regex.Match(stepSnippet); var argumentStrings = match.Groups.Cast <Group>().Skip(1).Select(g => g.Value).ToArray(); var bindingParameters = stepTransformation.Method.Parameters.ToArray(); var result = new object[argumentStrings.Length]; for (int i = 0; i < argumentStrings.Length; i++) { result[i] = await ConvertAsync(argumentStrings[i], bindingParameters[i].Type, cultureInfo); } return(result); }
private async Task <object> DoTransformAsync(IStepArgumentTransformationBinding stepTransformation, object value, CultureInfo cultureInfo) { object[] arguments; if (stepTransformation.Regex != null && value is string) { arguments = await GetStepTransformationArgumentsFromRegexAsync(stepTransformation, (string)value, cultureInfo); } else { arguments = new[] { value } }; var(result, _) = await bindingInvoker.InvokeBindingAsync(stepTransformation, contextManager, arguments, testTracer); return(result); }
private object DoTransform(IStepArgumentTransformationBinding stepTransformation, object value, CultureInfo cultureInfo) { object[] arguments; if (stepTransformation.Regex != null && value is string) { arguments = GetStepTransformationArgumentsFromRegex(stepTransformation, (string)value, cultureInfo); } else { arguments = new object[] { value } }; TimeSpan duration; return(bindingInvoker.InvokeBinding(stepTransformation, contextManager, arguments, testTracer, out duration)); }
private bool CanConvert(IStepArgumentTransformationBinding stepTransformationBinding, object valueToConvert, IBindingType typeToConvertTo) { if (!stepTransformationBinding.Method.ReturnType.TypeEquals(typeToConvertTo)) { return(false); } if (stepTransformationBinding.Regex != null && valueToConvert is string) { return(stepTransformationBinding.Regex.IsMatch((string)valueToConvert)); } var transformationFirstArgumentTypeName = stepTransformationBinding.Method.Parameters.FirstOrDefault()?.Type.FullName; var isTableStepTransformation = transformationFirstArgumentTypeName == typeof(Table).FullName; var valueIsTable = valueToConvert is Table; return(isTableStepTransformation == valueIsTable); }
protected abstract void ProcessStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding);
private bool CanConvert(IStepArgumentTransformationBinding stepTransformationBinding, object value, IBindingType typeToConvertTo) { if (!stepTransformationBinding.Method.ReturnType.TypeEquals(typeToConvertTo)) return false; if (stepTransformationBinding.Regex != null && value is string) return stepTransformationBinding.Regex.IsMatch((string) value); return true; }
protected override void ProcessStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding) { StepArgumentTransformationBindings.Add(stepArgumentTransformationBinding); }
protected override void ProcessStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding) { bindingRegistry.RegisterStepArgumentTransformationBinding(stepArgumentTransformationBinding); }
protected override void ProcessStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding) { //nop - not needed for IDE integration }
public void RegisterStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding) { throw new NotSupportedException(); }
public void RegisterStepArgumentTransformationBinding(IStepArgumentTransformationBinding stepArgumentTransformationBinding) { stepArgumentTransformations.Add(stepArgumentTransformationBinding); }