Debugging Visualizer and Customized Object For Debugging/DebuggerTypeProxy
You can Create your own Visualizer while Debugging a type, say likethe example on the book,you can use an image debugging viewer , create Your own winform and Controls,
Right klik add new Debugger Visualizer on your classlibrary,
add the Form etc put your logic on Show method.
Compiled put the dll on your visualizer folder on mydocument->visualstudio2008->visualizer
You can also Customize how the look When Debugging a type.
Create an Internal Class , inside your class.
Ex:
internal class RbmProxy
{
private RBMInput RBM;
public RbmProxy(RBMInput rbm)
{
RBM = rbm;
}
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public string BirNumber { get { return RBM.SplitRawinput[1].ToString(); } }
public string CustomerName { get { return RBM.SplitRawinput[2].ToString(); }
}
public string RBMCode { get { return RBM.SplitRawinput[3].ToString(); }
}
public DateTime DateReceived { get { return Convert.ToDateTime(RBM.SplitRawinput[4].ToString()); }
}
public DateTime DateIn { get { return Convert.ToDateTime(RBM.SplitRawinput[5].ToString()); }
}
public DateTime ProcessDate { get { return Convert.ToDateTime(RBM.SplitRawinput
.ToString()); }
}
public DateTime DateOut{ get { return Convert.ToDateTime(RBM.SplitRawinput[7].ToString()); }
}
public string status{ get { return RBM.SplitRawinput
.ToString(); }
}
public DateTime CaDate { get { return Convert.ToDateTime(RBM.SplitRawinput[9].ToString()); }
}
[DebuggerDisplay("{ValidationRules()}")]
public string BusinessRulesViolation { get { return string.Empty; } }
private string ValidationRules()
{
StringBuilder sb = new StringBuilder();
if(BirNumber.Length<14) sb.Append("BirNumber can not less than 14;");
if (DateOut < DateIn) sb.Append("Date Out Must be Larger than Date In;");
if(!status.Equals("PASS") && !status.Equals("NO PASS"))
sb.Append("Status can only be filled with 'PASS' or 'NO PASS';");
return sb.ToString();
}
add the debugger type proxy to your class
[DebuggerTypeProxy(typeof(RbmProxy))]
public class RBMInput : BaseGenericInput
{
when you run it , and on the debug mode you should see the debugger has already change the behaviour