Example #1
0
        public Type IsClass([ValidatedNotNull] Type param, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null)
        {
            if (!Ensure.IsActive)
            {
                return(param);
            }

            if (param == null)
            {
                throw ExceptionFactory.ArgumentNullException(
                          ExceptionMessages.Types_IsClass_Failed_Null,
                          paramName,
                          optsFn);
            }

            if (!param.GetTypeInfo().IsClass)
            {
                throw ExceptionFactory.ArgumentException(
                          ExceptionMessages.Types_IsClass_Failed.Inject(param.FullName),
                          paramName,
                          optsFn);
            }

            return(param);
        }
Example #2
0
        public T IsNotNull <T>([NoEnumeration, ValidatedNotNull] T value, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null)
        {
            if (!Ensure.IsActive)
            {
                return(value);
            }

            if (value == null)
            {
                throw ExceptionFactory.ArgumentNullException(ExceptionMessages.Common_IsNotNull_Failed, paramName, optsFn);
            }

            return(value);
        }
Example #3
0
        public T?IsNotNull <T>(T?value, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null) where T : struct
        {
            if (!Ensure.IsActive)
            {
                return(value);
            }

            if (value == null)
            {
                throw ExceptionFactory.ArgumentNullException(ExceptionMessages.Common_IsNotNull_Failed, paramName, optsFn);
            }

            return(value);
        }
Example #4
0
        public T IsClass <T>([ValidatedNotNull] T param, [InvokerParameterName] string paramName = Param.DefaultName, OptsFn optsFn = null)
        {
            if (!Ensure.IsActive)
            {
                return(param);
            }

            if (param == null)
            {
                throw ExceptionFactory.ArgumentNullException(
                          ExceptionMessages.Types_IsClass_Failed_Null,
                          paramName,
                          optsFn);
            }

            IsClass(param.GetType(), paramName, optsFn);

            return(param);
        }