Beispiel #1
0
        /// <summary>
        /// Add and assign a reference to a member field to the method body. Like 'this.myField = "Hello world;"'.
        /// </summary>
        /// <param name="method">The method to add the assignment to.</param>
        /// <param name="fieldName">Name of the field to create or reference.</param>
        /// <returns>A fluent interface to build up field reference types.</returns>
        public static CodeFieldReferenceBinder Assign(this CodeMemberMethod method, string fieldName)
        {
            var fieldRef1 = new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), fieldName);
            var result    = new CodeFieldReferenceBinder(method, fieldRef1);

            return(result);
        }
        public void SetUp()
        {
            // ToDo: Implement SetUp logic here
            var method = new CodeMemberMethod();

            this.binder     = method.Assign("myField");
            this.message    = "Value of message";
            this.inner      = new System.Exception();
            this.testObject = new CodeFieldReferenceException(this.binder, this.message, this.inner);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeFieldReferenceException"/> 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 <c>null</c> reference, the current exception is raised in a catch block that handles the inner exception.</param>
 public CodeFieldReferenceException(CodeFieldReferenceBinder binder, string message, Exception inner)
     : base(message, inner)
 {
     Guard.NotNull(() => binder, binder);
     this.binder = binder;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CodeFieldReferenceException"/> class
 /// </summary>
 /// <param name="binder">The binder associated with this exception.</param>
 public CodeFieldReferenceException(CodeFieldReferenceBinder binder)
 {
     Guard.NotNull(() => binder, binder);
     this.binder = binder;
 }
 public void SetUp()
 {
     // ToDo: Implement SetUp logic here
     var method = new CodeMemberMethod();
     this.binder = method.Assign("myField");
     this.message = "Value of message";
     this.inner = new System.Exception();
     this.testObject = new CodeFieldReferenceException(this.binder, this.message, this.inner);
 }