C# Class Editor.Utils.Check

Design By Contract Checks. Each method generates an exception or a trace assertion statement if the contract is broken.
This example shows how to call the Require method. public void Test(int x) { try { Check.Require(x > 1, "x must be > 1"); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } } You can direct output to a Trace listener. For example, you could insert Trace.Listeners.Clear(); Trace.Listeners.Add(new TextWriterTraceListener(Console.Out)); or direct output to a file or the Event Log. (Note: For ASP.NET clients use the Listeners collection of the Debug, not the Trace, object and, for a Release build, only exception-handling is possible.)
Datei anzeigen Open project: RIATEAM/MYSTIC

Private Properties

Property Type Description
Check System

Public Methods

Method Description
Assert ( bool assertion ) : void

Assertion check.

Assert ( bool assertion, string message ) : void

Assertion check.

Assert ( bool assertion, string message, Exception inner ) : void

Assertion check.

Ensure ( bool assertion ) : void

Postcondition check.

Ensure ( bool assertion, string message ) : void

Postcondition check.

Ensure ( bool assertion, string message, Exception inner ) : void

Postcondition check.

Invariant ( bool assertion ) : void

Invariant check.

Invariant ( bool assertion, string message ) : void

Invariant check.

Invariant ( bool assertion, string message, Exception inner ) : void

Invariant check.

Require ( bool assertion ) : void

Precondition check - should run regardless of preprocessor directives.

Require ( bool assertion, string message ) : void

Precondition check - should run regardless of preprocessor directives.

Require ( bool assertion, string message, Exception inner ) : void

Precondition check - should run regardless of preprocessor directives.

Private Methods

Method Description
Check ( ) : System

Method Details

Assert() public static method

Assertion check.
public static Assert ( bool assertion ) : void
assertion bool
return void

Assert() public static method

Assertion check.
public static Assert ( bool assertion, string message ) : void
assertion bool
message string
return void

Assert() public static method

Assertion check.
public static Assert ( bool assertion, string message, Exception inner ) : void
assertion bool
message string
inner System.Exception
return void

Ensure() public static method

Postcondition check.
public static Ensure ( bool assertion ) : void
assertion bool
return void

Ensure() public static method

Postcondition check.
public static Ensure ( bool assertion, string message ) : void
assertion bool
message string
return void

Ensure() public static method

Postcondition check.
public static Ensure ( bool assertion, string message, Exception inner ) : void
assertion bool
message string
inner System.Exception
return void

Invariant() public static method

Invariant check.
public static Invariant ( bool assertion ) : void
assertion bool
return void

Invariant() public static method

Invariant check.
public static Invariant ( bool assertion, string message ) : void
assertion bool
message string
return void

Invariant() public static method

Invariant check.
public static Invariant ( bool assertion, string message, Exception inner ) : void
assertion bool
message string
inner System.Exception
return void

Require() public static method

Precondition check - should run regardless of preprocessor directives.
public static Require ( bool assertion ) : void
assertion bool
return void

Require() public static method

Precondition check - should run regardless of preprocessor directives.
public static Require ( bool assertion, string message ) : void
assertion bool
message string
return void

Require() public static method

Precondition check - should run regardless of preprocessor directives.
public static Require ( bool assertion, string message, Exception inner ) : void
assertion bool
message string
inner System.Exception
return void