예제 #1
0
파일: IsSharp.cs 프로젝트: RhysC/IsSharp
 public static void Is <E>(Expression <Func <bool> > condition)
 {
     if (!(condition.Compile().Invoke()))
     {
         string conditionString = new ConditionToEnglish().Translate(condition.Body);
         throw (Exception)Activator.CreateInstance(typeof(E), conditionString);
     }
 }
예제 #2
0
파일: Guard.cs 프로젝트: JASGames/IsSharp
        public static void Is <TException>(Expression <Func <bool> > condition) where TException : Exception
        {
            if (condition.Compile().Invoke())
            {
                return;
            }
            var conditionString = ConditionToEnglish.Translate(condition.Body);

            throw (Exception)Activator.CreateInstance(typeof(TException), conditionString);
        }
예제 #3
0
        public IsCondition <T> Check <TException>(Expression <Func <T, bool> > expression) where TException : Exception
        {
            if (!(expression.Compile().Invoke(_value)))
            {
                var conditionString = ConditionToEnglish.Translate(expression.Body, _name, _value);
                throw (Exception)Activator.CreateInstance(typeof(TException), conditionString);
            }

            return(this);
        }
예제 #4
0
파일: IsSharp.cs 프로젝트: RhysC/IsSharp
        public IsCondition <T> Check <E>(Expression <Func <T, bool> > expression)
        {
            if (!(expression.Compile().Invoke(_value)))
            {
                string conditionString = new ConditionToEnglish().Translate(expression.Body, _name, _value);
                throw (Exception)Activator.CreateInstance(typeof(E), conditionString);
            }

            return(this);
        }