Source/NFX/MiscUtils.cs
/// <summary>
/// Checks the value for null and throws exception if it is.
/// The method is useful for .ctor call chaining to preclude otherwise anonymous NullReferenceException
/// </summary>
Checks the value for null and throws exception if it is.
The method is useful for .ctor call chaining to preclude otherwise anonymous NullReferenceException
Checks the value for null and throws exception if it is . The method is useful for . ctor call chaining to preclude otherwise anonymous NullReferenceException
public static T NonNull<T>(this T obj,
                               Func<Exception> error = null,
                               string text = null) where T : class
    {
      if (obj==null)
      {
        if (error!=null)
         throw error();
        else
         throw new NFXException(StringConsts.PARAMETER_MAY_NOT_BE_NULL_ERROR
                                            .Args(text ?? CoreConsts.UNKNOWN,
                                                  new StackTrace(1, false).ToString()));
      }
      return obj;
    }
public static T NonNull < T > ( this T obj , Func < Exception > error = null , string text = null ) where T : class { if ( obj == null ) { if ( error != null ) throw error ( ) ; else throw new NFXException ( StringConsts . PARAMETER_MAY_NOT_BE_NULL_ERROR . Args ( text ?? CoreConsts . UNKNOWN , new StackTrace ( 1 , false ) . ToString ( ) ) ) ; } return obj ; }
Checks the value for null and throws exception if it is.
Checks the value for null and throws exception if it is .
T
this
error
Func<Exception>
text
string