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.
BypassBusinessBaseUsingFactory.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="BypassBusinessBaseUsingFactory.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;
12using Csla.TestHelpers;
13
15{
16 [Serializable()]
17 [Csla.Server.ObjectFactory("Csla.Test.BypassPropertyChecks.TestObjectFactory,Csla.Tests")]
18 public class BypassBusinessBaseUsingFactory : BusinessBase<BypassBusinessBaseUsingFactory>
19 {
21 {
22 MarkOld();
23 }
24
26 {
27 return dataPortal.Fetch();
28 }
29
30 protected static PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id, "Id");
31 public int Id
32 {
33 get { return GetProperty<int>(IdProperty); }
34 set { SetProperty<int>(IdProperty, value); }
35 }
36
37 protected static PropertyInfo<int> Id2Property = RegisterProperty<int>(c => c.Id2, "Id2");
38 public int Id2
39 {
40 get { return GetProperty<int>(Id2Property); }
41 set { SetProperty<int>(Id2Property, value); }
42 }
43
44 private int _id3;
45 protected static PropertyInfo<int> Id3Property = RegisterProperty<int>(c => c.Id3, "Id3");
46 public int Id3
47 {
48 get { return GetProperty<int>(Id3Property, _id3); }
49 set { SetProperty(Id3Property, ref _id3, value); }
50 }
51
52 private int _id4;
53 protected static PropertyInfo<int> Id4Property = RegisterProperty<int>(c => c.Id4, "Id4");
54 public int Id4
55 {
56 get { return GetProperty<int>(Id4Property, _id4); }
57 set { SetProperty(Id4Property, ref _id4, value); }
58 }
59
60 protected override void AddBusinessRules()
61 {
62 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.ReadProperty, IdProperty, new List<string> { "Admin" }));
63 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.WriteProperty, IdProperty, new List<string> { "Admin" }));
64 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.ReadProperty, Id2Property, new List<string> { "Random" }));
65 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.WriteProperty, Id2Property, new List<string> { "Random" }));
66 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.ReadProperty, Id3Property, new List<string> { "Admin" }));
67 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.WriteProperty, Id3Property, new List<string> { "Admin" }));
68 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.ReadProperty, Id4Property, new List<string> { "Random" }));
69 BusinessRules.AddRule(new Csla.Rules.CommonRules.IsInRole(Rules.AuthorizationActions.WriteProperty, Id4Property, new List<string> { "Random" }));
70 }
71
72 public void LoadIdByPass(int id)
73 {
74 using (this.BypassPropertyChecks)
75 {
76 Id = id;
77 }
78 }
79
80 public void LoadId(int id)
81 {
82 Id = id;
83 }
84
85 public int ReadIdByPass()
86 {
87 using (this.BypassPropertyChecks)
88 {
89 return Id;
90 }
91 }
92
93 public int ReadId()
94 {
95 return Id;
96 }
97
98 public void LoadId2ByPass(int id)
99 {
100 using (this.BypassPropertyChecks)
101 {
102 Id2 = id;
103 }
104 }
105
106 public void LoadId2(int id)
107 {
108 Id2 = id;
109 }
110
111 public int ReadId2ByPass()
112 {
113 using (this.BypassPropertyChecks)
114 {
115 return Id2;
116 }
117 }
118
119 public int ReadId2()
120 {
121 return Id2;
122 }
123
124
125 public void LoadId3ByPass(int id)
126 {
127 using (this.BypassPropertyChecks)
128 {
129 Id3 = id;
130 }
131 }
132
133 public void LoadId3(int id)
134 {
135 Id3 = id;
136 }
137
138 public int ReadId3ByPass()
139 {
140 using (this.BypassPropertyChecks)
141 {
142 return Id3;
143 }
144 }
145
146 public int ReadId3()
147 {
148 return Id3;
149 }
150
151 public void LoadId4ByPass(int id)
152 {
153 using (this.BypassPropertyChecks)
154 {
155 Id4 = id;
156 }
157 }
158
159 public void LoadId4(int id)
160 {
161 Id4 = id;
162 }
163
164 public int ReadId4ByPass()
165 {
166 using (this.BypassPropertyChecks)
167 {
168 return Id4;
169 }
170 }
171
172 public int ReadId4()
173 {
174 return Id4;
175 }
176
177 }
178}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Maintains metadata about a property.
IsInRole authorization rule.
Base class to be used when creating a data portal factory object.
static BypassBusinessBaseUsingFactory GetObject(IDataPortal< BypassBusinessBaseUsingFactory > dataPortal)
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
object Fetch(params object[] criteria)
Called by a factory method in a business class to retrieve an object, which is loaded with values fro...
@ Serializable
Prevents updating or inserting until the transaction is complete.