Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace FailFast
- {
- public static class Assert
- {
- public static Action<String> LogCallback { set; get; }
- static Assert()
- {
- LogCallback = (msg) => Console.WriteLine(msg);
- }
- public static void NotNull(Object o, String message)
- {
- if (o == null)
- {
- if (!String.IsNullOrEmpty(message))
- LogCallback(message);
- throw new AssertNullReferenceException();
- }
- }
- public static void NotNull(Object o)
- {
- NotNull(o, "");
- }
- }
- [Serializable()]
- public class AssertNullReferenceException : System.Exception
- {
- public AssertNullReferenceException() : base() { }
- public AssertNullReferenceException(string message) : base(message) { }
- public AssertNullReferenceException(string message, System.Exception inner) : base(message, inner) { }
- // A constructor is needed for serialization when an
- // exception propagates from a remoting server to the client.
- protected AssertNullReferenceException(System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context) { }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement