CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
ShortCircuitClasses.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ShortCircuitClasses.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>no summary</summary>
7//-----------------------------------------------------------------------
8using System;
9using System.Collections.Generic;
10using System.Text;
11using Csla;
13
15{
17 public class ShortCircuit : BusinessBase<ShortCircuit>
18 {
19 public static PropertyInfo<string> TestProperty = RegisterProperty<string>(c => c.Test);
20 public string Test
21 {
22 get { return GetProperty(TestProperty); }
23 set { SetProperty(TestProperty, value); }
24 }
25
26 protected override void AddBusinessRules()
27 {
28 BusinessRules.AddRule(new Csla.Rules.CommonRules.Required(TestProperty));
29 BusinessRules.AddRule(new AlwaysWarns { PrimaryProperty = TestProperty });
30 BusinessRules.AddRule(new AlwaysFails { PrimaryProperty = TestProperty, Priority = 10 });
31 }
32
33 public int Threshold
34 {
35 get { return BusinessRules.ProcessThroughPriority; }
36 set { BusinessRules.ProcessThroughPriority = value; }
37 }
38
39 public void CheckRules()
40 {
41 BusinessRules.CheckRules();
42 }
43
44 public class AlwaysWarns : Rules.BusinessRule
45 {
46 protected override void Execute(Rules.IRuleContext context)
47 {
48 context.AddWarningResult("Always warns");
49 }
50 }
51
52 public class AlwaysFails : Rules.BusinessRule
53 {
54 protected override void Execute(Rules.IRuleContext context)
55 {
56 context.AddErrorResult("Always error");
57 }
58 }
59
60 [Create]
61 private void Create()
62 {
63 }
64 }
65}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
Business rule for a required string.
Definition: CommonRules.cs:106
override void Execute(Rules.IRuleContext context)
override void Execute(Rules.IRuleContext context)
static PropertyInfo< string > TestProperty
@ Serializable
Prevents updating or inserting until the transaction is complete.