Пример #1
0
        protected override void Execute(RuleContext context)
#endif
        {
            int role = (int)context.InputPropertyValues[PrimaryProperty];

#if __ANDROID__
            var roles = await RoleList.GetListAsync();

            if (!(await RoleList.GetListAsync()).ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
            context.Complete();
#elif SILVERLIGHT
            RoleList.GetList((o, e) =>
            {
                if (!e.Object.ContainsKey(role))
                {
                    context.AddErrorResult("Role must be in RoleList");
                }
                context.Complete();
            });
#else
            if (!RoleList.GetList().ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
#endif
        }
Пример #2
0
        /// <summary>
        /// Ensure the Role property value exists
        /// in RoleList
        /// </summary>
        public static bool ValidRole(object target, RuleArgs e)
        {
            int role = ((IHoldRoles)target).Role;

            if (RoleList.GetList().ContainsKey(role))
            {
                return(true);
            }
            else
            {
                e.Description = "Role must be in RoleList";
                return(false);
            }
        }
Пример #3
0
        protected override void Execute(RuleContext context)
        {
#if SILVERLIGHT
            int role = (int)context.InputPropertyValues[PrimaryProperty];
            RoleList.GetList((o, e) =>
            {
                if (!e.Object.ContainsKey(role))
                {
                    context.AddErrorResult("Role must be in RoleList");
                }
                context.Complete();
            });
#else
            int role = (int)context.InputPropertyValues[PrimaryProperty];
            if (!RoleList.GetList().ContainsKey(role))
            {
                context.AddErrorResult("Role must be in RoleList");
            }
#endif
        }