Exemplo n.º 1
0
        private static bool EvaluateBitMaskRestriction(Restriction.BitMaskRestriction restriction, IRuleEvaluationContext context)
        {
            RestrictionEvaluator.ValidateBitMaskRestriction(restriction);
            object obj = context[restriction.Tag];

            if (obj is int)
            {
                int  num = (int)obj;
                bool flag;
                if ((num & restriction.Mask) != 0)
                {
                    flag = (restriction.Bmr == Restriction.RelBmr.NotEqualToZero);
                }
                else
                {
                    flag = (restriction.Bmr == Restriction.RelBmr.EqualToZero);
                }
                context.TraceFunction <object, Restriction.RelBmr, int, bool>("BitMaskRestriction [{0}] {1} [{2}] evaluates to {3}", obj, restriction.Bmr, restriction.Mask, flag);
                return(flag);
            }
            context.TraceError <object>("Invalid BitMaskRestriction value: {0}", obj);
            return(false);
        }