コード例 #1
0
        public void PropertyIsTypeReferenceNormalBehavior()
        {
            // Test read access of 'IsTypeReference' Property.
            var actual = testObject.IsTypeReference;

            Assert.IsTrue(actual);

            testObject = new CodeTypeReferenceBinder(this.method, new CodeFieldReferenceExpression());
            actual     = testObject.IsTypeReference;
            Assert.IsFalse(actual);
        }
コード例 #2
0
        /// <summary>
        /// Completes the creation of the reference type from a <see cref="CodeTypeReferenceBinder"/> build reference.
        /// </summary>
        /// <param name="binder">The calling binder.</param>
        /// <returns>
        /// A fluent interface to build up methods.
        /// </returns>
        internal CodeMemberMethod Commit(CodeTypeReferenceBinder binder)
        {
            if (this.variableDeclaration == null)
            {
                // add 'localVar = DateTime.Now;'
                var assign = new CodeAssignStatement(this.reference, binder.Invoker);
                this.method.Statements.Add(assign);
            }
            else
            {
                // add 'var localVar = DateTime.Now;'
                this.variableDeclaration.InitExpression = binder.Invoker;
                this.method.Statements.Add(this.variableDeclaration);
            }

            return this.method;
        }
コード例 #3
0
 /// <summary>
 /// Add a reference to a static class to the method body. Like '<c>Assert</c>' or '<c>DateTime</c>'.
 /// </summary>
 /// <param name="className">Name of the class.</param>
 /// <returns>A fluent interface to build up reference types.</returns>
 public CodeTypeReferenceBinder StaticClass(string className)
 {
     // var localRef = new CodeVariableReferenceExpression(this.reference.Name);
     // var as1 = new CodeAssignStatement(localRef, invoker);
     var staticexpr = new CodeTypeReferenceExpression(className);
     var result = new CodeTypeReferenceBinder(this.method, staticexpr) { LocalVar = this };
     return result;
 }
コード例 #4
0
 public void SetUp()
 {
     //var ctdecl = new CodeTypeDeclaration("MyClass");
     this.method = new CodeMemberMethod();
     this.testObject = this.method.StaticClass("ReferencedClass");
 }
コード例 #5
0
        public void PropertyIsTypeReferenceNormalBehavior()
        {
            // Test read access of 'IsTypeReference' Property.
            var actual = testObject.IsTypeReference;
            Assert.IsTrue(actual);

            testObject = new CodeTypeReferenceBinder(this.method, new CodeFieldReferenceExpression());
            actual = testObject.IsTypeReference;
            Assert.IsFalse(actual);
        }
コード例 #6
0
 public void SetUp()
 {
     //var ctdecl = new CodeTypeDeclaration("MyClass");
     this.method     = new CodeMemberMethod();
     this.testObject = this.method.StaticClass("ReferencedClass");
 }