public void AddTokens <TController>(TestServerAction action, TestServerTokenCollection tokens) where TController : class { var parameters = action.MethodInfo.GetParameters(); for (int i = 0; i < parameters.Length; i++) { var type = parameters[i].ParameterType; var instance = action.ArgumentValues.Any(x => x.Key == i) ? action.ArgumentValues[i].Instance : null; if (instance != null && !type.IsPrimitiveType()) { if (!IgnoreBind(parameters[i])) { foreach (var property in type.GetProperties()) { var tokenName = property.Name.ToLowerInvariant(); var value = property.GetValue(instance); if (value != null) { tokens.AddToken(tokenName, value.ToString(), isConventional: false); } } } } } }
public static TestServerTokenCollection FromDictionary(Dictionary <string, string> tokenKV) { var tokens = new TestServerTokenCollection(); foreach (var item in tokenKV) { tokens.AddToken(item.Key, item.Value, isConventional: false); } return(tokens); }
public void AddTokens <TController>(TestServerAction action, TestServerTokenCollection tokens) where TController : class { var parameters = action.MethodInfo.GetParameters(); for (var i = 0; i < parameters.Length; i++) { if (!IgnoreHeader(parameters[i])) { var tokenName = parameters[i].Name.ToLowerInvariant(); if (parameters[i].ParameterType.IsPrimitiveType()) { var tokenValue = action.ArgumentValues.Any(x => x.Key == i) ? action.ArgumentValues[i].Instance : null; if (tokenValue != null) { tokens.AddToken(tokenName, tokenValue.ToString(), isConventional: false); } } else if (parameters[i].ParameterType.IsArray && IsPrimitiveType(parameters[i].ParameterType.GetElementType())) { var arrayValues = (Array)action.ArgumentValues[i].Instance; if (arrayValues != null && arrayValues.Length != 0 ) { var tokenValue = GetTokenValue(arrayValues, tokenName); tokens.AddToken(tokenName, tokenValue, isConventional: false); } } } } }
public void AddTokens <TController>(TestServerAction action, TestServerTokenCollection tokens) where TController : class { const string ControllerTypeNameSuffix = "Controller"; const string controller_key = "controller"; if (!tokens.ContainsToken(controller_key)) { var controllerName = typeof(TController).Name .Replace(ControllerTypeNameSuffix, String.Empty); tokens.AddToken(controller_key, controllerName, isConventional: true); } }
public void AddTokens <TController>(TestServerAction action, TestServerTokenCollection tokens) where TController : class { var parameters = action.MethodInfo.GetParameters(); for (int i = 0; i < parameters.Length; i++) { if (parameters[i].ParameterType.IsPrimitive || parameters[i].ParameterType == typeof(String) || parameters[i].ParameterType == typeof(Decimal)) { var tokenName = parameters[i].Name.ToLowerInvariant(); var tokenValue = action.ArgumentValues[i].Instance; tokens.AddToken(tokenName, tokenValue.ToString(), isConventional: false); } } }
public void AddTokens <TController>(TestServerAction action, TestServerTokenCollection tokens) where TController : class { var parameters = action.MethodInfo.GetParameters(); for (int i = 0; i < parameters.Length; i++) { var type = parameters[i].ParameterType; if (!(type.IsPrimitive || type == typeof(String) || type == typeof(Decimal) || type == typeof(Guid))) { if (!IgnoreBind(parameters[i])) { foreach (var property in type.GetProperties()) { var tokenName = property.Name.ToLowerInvariant(); var value = property.GetValue(action.ArgumentValues[i].Instance); tokens.AddToken(tokenName, value.ToString(), isConventional: false); } } } } }