Build a local variable from fluent parameters.
Пример #1
0
 public void TearDown()
 {
     this.testVarCreate     = null;
     this.testVarNoCreate   = null;
     this.methodVarCreate   = null;
     this.methodVarNoCreate = null;
 }
Пример #2
0
 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);
 }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <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);
     }
 }
Пример #5
0
 public void TearDown()
 {
     this.testVarCreate = null;
     this.testVarNoCreate = null;
     this.methodVarCreate = null;
     this.methodVarNoCreate = null;
 }
Пример #6
0
 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);
 }