public void TearDown() { this.testVarCreate = null; this.testVarNoCreate = null; this.methodVarCreate = null; this.methodVarNoCreate = null; }
public void SetUp() { this.methodVarCreate = new CodeMemberMethod(); this.methodVarNoCreate = new CodeMemberMethod(); this.testVarCreate = this.methodVarCreate.Var("variableNameCreate", true); this.testVarNoCreate = this.methodVarNoCreate.Var("variableNameNoCreate", false); }
/// <summary> /// Completes the creation of the reference type. /// </summary> /// <returns> /// A fluent interface to build up methods. /// </returns> public CodeMemberMethod Commit() { // Todo: member checking. if (this.localVar != null) { var temp = this.localVar; this.localVar = null; return(temp.Commit(this)); } this.method.Statements.Add(this.invoker); return(this.method); }
/// <summary> /// Creates and initializes a local variable. var test = object.DoSomething("parameter"). /// </summary> /// <param name="method">The method to add the statements to.</param> /// <param name="variableName">Name of the local variable.</param> /// <param name="createVariable">if set to <c>true</c> a local variable is created; otherwise it is only referenced.</param> /// <returns>A fluent interface to build up reference types.</returns> public static CodeLocalVariableBinder Var( this CodeMemberMethod method, string variableName, bool createVariable) { // "Assert" if (createVariable) { var localDecl = new CodeVariableDeclarationStatement("var", variableName); var result = new CodeLocalVariableBinder(method, localDecl); return(result); } else { var staticexpr = new CodeVariableReferenceExpression(variableName); var result = new CodeLocalVariableBinder(method, staticexpr); return(result); } }