internal string GetReflectionInvocation(string methodInvClass) { String str = String.Empty; str += "object[] args_" + Name + " = {" + TestGenerator.RemoveChars(ComplexParameterType + Arrays) + "Var, " + TestGenerator.RemoveChars(PrimitiveParameterType + Arrays) + "Var};"; str += "methodInfo = " + methodInvClass + "Type.GetMethod(\"" + Name + "\"); "; if (GenericMethod.Equals("<T>")) { str += "Type[] genericArgumentsOf" + Name + " = new Type[] { typeof(int) };"; str += "methodInfo = methodInfo.MakeGenericMethod(genericArgumentsOf" + Name + ");"; } String firstParam = String.Empty; if (ClassInstanceModifier.Equals("static")) { firstParam = "null"; } else { firstParam = methodInvClass + "Var"; } str += "methodInfo.Invoke(" + firstParam + ", args_" + Name + ");"; return(str); }
public String GetDeclaration() { String safety = String.Empty; if (PrimitiveParameterType.Contains("*")) { safety = "unsafe"; } String heading = VisibilityModifier + " " + ClassInstanceModifier + " " + safety + " void " + Name + GenericMethod.Replace('T', 'B') + "(" + ParameterCallType + " " + ComplexParameterType + Arrays + " x, " + ParameterCallType + " " + PrimitiveParameterType + Arrays + " y)"; String str = heading + "{"; if (!Arrays.Contains("[]")) { str += "x = new " + ComplexParameterType + "();"; } else { str += "x = new " + ComplexParameterType + Arrays + "{};"; } str += "y = " + TestGenerator.GetPrimitiveInstance(PrimitiveParameterType, Arrays) + ";"; str += "Console.WriteLine(\"Called " + heading + "\");"; str += "}"; return(str); }
public String GetEventFireCode(String variable, bool async) { String str = String.Empty; String resultIdentifier = String.Empty; if (async) { resultIdentifier = "result" + Name + "Trigger"; str = "IAsyncResult " + resultIdentifier + " = "; } String eventName = variable + Name + "Trigger"; str += eventName; if (async) { str += ".BeginInvoke"; } String parameter = ParameterCallType + " " + TestGenerator.RemoveChars(ComplexParameterType + Arrays) + "Var, " + ParameterCallType + " " + TestGenerator.RemoveChars(PrimitiveParameterType + Arrays) + "Var"; str += "(" + parameter; if (async) { str += ", new AsyncCallback(Program.CallbackMethod), new object()"; } str += ");"; if (async) { str += eventName + ".EndInvoke("; if (!ParameterCallType.Equals(String.Empty)) { str += parameter + ","; } str += resultIdentifier + ");"; } return(str); }
private String GetInvocationArgumentString() { return(ParameterCallType + " " + TestGenerator.RemoveChars(ComplexParameterType + Arrays) + "Var, " + ParameterCallType + " " + TestGenerator.RemoveChars(PrimitiveParameterType + Arrays) + "Var"); }