// usage:public class FullConditionUITypeEditor : UITypeEditor{// The immediate caller is required to have been granted the FullTrust permission.[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]public FullConditionUITypeEditor() { }}
static class Program{/// <summary>/// The main entry point for the application./// </summary>[STAThread]static void Main(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new Form1());}}
public static class CustomDebug{[DebuggerHidden]public static void Assert(Boolean condition, Func<Exception> exceptionCreator) { ... }}
...
// The following assert fails, and because of the attribute the exception is shown at this line// Isn't affecting the stack traceCustomDebug.Assert(false, () => new Exception());
它还可以防止在堆栈跟踪中显示方法,当一个方法只包装另一个方法时很有用:
[DebuggerHidden]public Element GetElementAt(Vector2 position){return GetElementAt(position.X, position.Y);}
public Element GetElementAt(Single x, Single y) { ... }