Пример #1
0
        /// <summary>
        /// Add a reference to a static class to the method body. Like '<c>Assert</c>' or '<c>DateTime</c>'.
        /// </summary>
        /// <param name="method">The method to add the statements to.</param>
        /// <param name="className">Name of the class.</param>
        /// <returns>
        /// A fluent interface to build up reference types.
        /// </returns>
        public static CodeTypeReferenceBinder StaticClass(this CodeMemberMethod method, string className)
        {
            // "Assert"
            var staticexpr = new CodeTypeReferenceExpression(className);
            var result     = new CodeTypeReferenceBinder(method, staticexpr);

            return(result);
        }
Пример #2
0
        public void SetUp()
        {
            // ToDo: Implement SetUp logic here
            var method = new CodeMemberMethod();

            this.binder     = method.StaticClass("ReferencedClass");
            this.message    = "Value of message";
            this.inner      = new System.Exception();
            this.testObject = new CodeTypeReferenceException(this.binder, this.message, this.inner);
        }
Пример #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
        /// <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);
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeTypeReferenceException"/> class
 /// </summary>
 /// <param name="binder">The binder associated with this exception.</param>
 /// <param name="message">A <see cref="T:System.String"/> that describes the error. The content of message is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.</param>
 /// <param name="inner">The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception.</param>
 public CodeTypeReferenceException(CodeTypeReferenceBinder binder, string message, Exception inner)
     : base(message, inner)
 {
     Guard.NotNull(() => binder, binder);
     this.binder = binder;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeTypeReferenceException"/> class
 /// </summary>
 /// <param name="binder">The binder associated with this exception.</param>
 public CodeTypeReferenceException(CodeTypeReferenceBinder binder)
 {
     Guard.NotNull(() => binder, binder);
     this.binder = binder;
 }
 public void SetUp()
 {
     // ToDo: Implement SetUp logic here
     var method = new CodeMemberMethod();
     this.binder = method.StaticClass("ReferencedClass");
     this.message = "Value of message";
     this.inner = new System.Exception();
     this.testObject = new CodeTypeReferenceException(this.binder, this.message, this.inner);
 }