Esempio n. 1
0
        /// <summary>
        /// Indicates whether the current user as defined by
        /// <see cref="Csla.ApplicationContext.User" />
        /// is explicitly denied write access to the property.
        /// </summary>
        /// <param name="businessRules">Business rules</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <returns>
        ///   <c>true</c> if [is write denied] [the specified business rules]; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsWriteDenied(this BusinessRules businessRules, string propertyName)
        {
            var propertyInfo = PropertyHelper.GetRegisteredProperty(businessRules, propertyName);

            return(!businessRules.HasPermission(AuthorizationActions.ReadProperty, propertyInfo));
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a lambda property level rule to business rules.
        /// </summary>
        /// <param name="businessRules">Business rules</param>
        /// <param name="ruleHandler">Rule method</param>
        /// <param name="args">RuleArgs argument.</param>
        /// <param name="priority">Priority</param>
        //[Obsolete("For migration of older apps to Csla 4.x only")]
        public static void AddRule(this BusinessRules businessRules, RuleHandler ruleHandler, RuleArgs args, int priority)
        {
            var primaryProperty = PropertyHelper.GetRegisteredProperty(businessRules, args.PropertyName);

            AddRule(businessRules, ruleHandler, primaryProperty, args, priority);
        }
Esempio n. 3
0
        /// <summary>
        /// Specify the roles denied write access to
        /// a given property.
        /// </summary>
        /// <param name="businessRules">Business rules</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="roles">List of roles denied write access.</param>
        /// <remarks>
        /// This method may be called multiple times, with the roles in
        /// each call being added to the end of the list of denied roles.
        /// In other words, each call is cumulative, adding more roles
        /// to the list.
        /// </remarks>
        public static void DenyWrite(this BusinessRules businessRules, string propertyName, params string[] roles)
        {
            var propertyInfo = PropertyHelper.GetRegisteredProperty(businessRules, propertyName);

            businessRules.AddRule(new IsNotInRole(AuthorizationActions.WriteProperty, propertyInfo, roles));
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a lambda property level rule to business rules.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="businessRules">Business rules</param>
        /// <param name="ruleHandler">Rule method</param>
        /// <param name="args">RuleArgs argument.</param>
        //[Obsolete("For migration of older apps to Csla 4.x only")]
        public static void AddRule <T>(this BusinessRules businessRules, RuleHandler <T, RuleArgs> ruleHandler, RuleArgs args) where T : BusinessBase <T>
        {
            var primaryProperty = PropertyHelper.GetRegisteredProperty(businessRules, args.PropertyName);

            AddRule(businessRules, ruleHandler, primaryProperty, args, 0);
        }