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.
SeverityClasses.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="SeverityClasses.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;
11
13{
14 public class SeverityRoot : Csla.BusinessBase<SeverityRoot>
15 {
16 public static PropertyInfo<string> TestProperty = RegisterProperty<string>(c => c.Test);
17 public string Test
18 {
19 get { return GetProperty(TestProperty); }
20 set { SetProperty(TestProperty, value); }
21 }
22
23 protected override void AddBusinessRules()
24 {
25 BusinessRules.AddRule(new AlwaysError { PrimaryProperty = TestProperty });
26 BusinessRules.AddRule(new AlwaysWarns { PrimaryProperty = TestProperty });
27 BusinessRules.AddRule(new AlwaysInfo { PrimaryProperty = TestProperty });
28 }
29
30 public void Validate()
31 {
32 BusinessRules.CheckRules();
33 }
34
35 public class AlwaysInfo : Rules.BusinessRule
36 {
37 protected override void Execute(Rules.IRuleContext context)
38 {
39 context.AddInformationResult("Always info");
40 }
41 }
42
43 public class AlwaysWarns : Rules.BusinessRule
44 {
45 protected override void Execute(Rules.IRuleContext context)
46 {
47 context.AddWarningResult("Always warns");
48 }
49 }
50
51 public class AlwaysError : Rules.BusinessRule
52 {
53 protected override void Execute(Rules.IRuleContext context)
54 {
55 context.AddErrorResult("Always error");
56 }
57 }
58
59 [Create]
60 private void Create()
61 {
62 BusinessRules.CheckRules();
63 }
64 }
65
66 public class NoErrorRoot : Csla.BusinessBase<NoErrorRoot>
67 {
68 public static PropertyInfo<string> TestProperty = RegisterProperty<string>(c => c.Test);
69 public string Test
70 {
71 get { return GetProperty(TestProperty); }
72 set { SetProperty(TestProperty, value); }
73 }
74
75 public void Validate()
76 {
77 BusinessRules.CheckRules();
78 }
79
80 protected override void AddBusinessRules()
81 {
82 BusinessRules.AddRule(new AlwaysInfo { PrimaryProperty = TestProperty });
83 BusinessRules.AddRule(new AlwaysWarns { PrimaryProperty = TestProperty });
84 }
85
86 public class AlwaysInfo : Rules.BusinessRule
87 {
88 protected override void Execute(Rules.IRuleContext context)
89 {
90 context.AddInformationResult("Always info");
91 }
92 }
93
94 public class AlwaysWarns : Rules.BusinessRule
95 {
96 protected override void Execute(Rules.IRuleContext context)
97 {
98 context.AddWarningResult("Always warns");
99 }
100 }
101
102 [Create]
103 private void Create()
104 {
105 BusinessRules.CheckRules();
106 }
107 }
108}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
override void Execute(Rules.IRuleContext context)
override void Execute(Rules.IRuleContext context)
static PropertyInfo< string > TestProperty
override void Execute(Rules.IRuleContext context)
override void Execute(Rules.IRuleContext context)
override void Execute(Rules.IRuleContext context)
static PropertyInfo< string > TestProperty