CSLA.NET 5.4.2
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ObjectRule.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ObjectRule.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>Base class used to create object level rule</summary>
7//-----------------------------------------------------------------------
8using System;
9using Csla.Core;
10using Csla.Properties;
11
12namespace Csla.Rules
13{
17 public abstract class ObjectRule : BusinessRule
18 {
22 protected ObjectRule()
23 { }
24
31 {
32 get
33 {
34 return null;
35 }
36 set
37 {
38 if (value != null)
39 {
40 throw new ArgumentException(Resources.ObjectRulesCannotSetPrimaryProperty, "PrimaryProperty");
41 }
42 }
43 }
44
52 {
53 get { return (RunMode & RunModes.DenyCheckRules) == 0; }
54 set
55 {
56 if (value && !CanRunInCheckRules)
57 {
58 RunMode = RunMode ^ RunModes.DenyCheckRules;
59 }
60 else if (!value && CanRunInCheckRules)
61 {
62 RunMode = RunMode | RunModes.DenyCheckRules;
63 }
64 }
65 }
66 }
67}
A strongly-typed resource class, for looking up localized strings, etc.
static string ObjectRulesCannotSetPrimaryProperty
Looks up a localized string similar to Object rule can not have PrimaryPropery.
RunModes RunMode
Gets or sets the run in context.
Base class used to create business and validation rules.
Definition: BusinessRule.cs:15
Base class for object level rules.
Definition: ObjectRule.cs:18
override IPropertyInfo PrimaryProperty
Gets or sets the primary property affected by this rule.
Definition: ObjectRule.cs:31
ObjectRule()
Initializes a new instance of the ObjectRule class.
Definition: ObjectRule.cs:22
bool CanRunInCheckRules
Gets or sets a value indicating whether this instance can run when CheckRules is called on BO.
Definition: ObjectRule.cs:52
Maintains metadata about a property.
RunModes
Flags enum to define when rule is allowed or denied to run