Exemple #1
0
        /// <summary>
        /// Adds a dependency between two properties from first property to second proerty
        /// </summary>
        /// <param name="businessRules">Business rules</param>
        /// <param name="propertyName">Name of the property.</param>
        /// <param name="dependentPropertyName">Name of the dependent property.</param>
        /// <param name="isBidirectional">if set to <c>true</c> [is bidirectional].</param>
        //[Obsolete("For migration of older apps to Csla 4.x only")]
        public static void AddDependentProperty(this BusinessRules businessRules, string propertyName, string dependentPropertyName, bool isBidirectional)
        {
            var propertyInfo          = PropertyHelper.GetRegisteredProperty(businessRules, propertyName);
            var dependentPropertyInfo = PropertyHelper.GetRegisteredProperty(businessRules, dependentPropertyName);

            AddDependentProperty(businessRules, propertyInfo, dependentPropertyInfo, isBidirectional);
        }
Exemple #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="primaryPropertyName">Primary Property name</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, string primaryPropertyName, int priority)
        {
            if (string.IsNullOrEmpty(primaryPropertyName))
            {
                throw new ArgumentException("primaryPropertyName");
            }
            var primaryProperty = PropertyHelper.GetRegisteredProperty(businessRules, primaryPropertyName);

            AddRule(businessRules, ruleHandler, primaryProperty, new RuleArgs(primaryProperty), priority);
        }
Exemple #3
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="primaryPropertyName">Name of the primary property.</param>
        ///// <param name="primaryPropertyName">Primary Property name</param>
        //[Obsolete("For migration of older apps to Csla 4.x only")]
        public static void AddRule <T>(this BusinessRules businessRules, RuleHandler <T, RuleArgs> ruleHandler, string primaryPropertyName) where T : BusinessBase <T>
        {
            if (string.IsNullOrEmpty(primaryPropertyName))
            {
                throw new ArgumentException("primaryPropertyName");
            }

            var primaryProperty = PropertyHelper.GetRegisteredProperty(businessRules, primaryPropertyName);

            AddRule(businessRules, ruleHandler, primaryProperty, new RuleArgs(primaryProperty), 0);
        }
Exemple #4
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));
        }
Exemple #5
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));
        }
Exemple #6
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);
        }
Exemple #7
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);
        }