/// <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); }
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); }
/// <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); }
/// <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); }
/// <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; }
/// <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; }