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.
NullableEntity.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Csla.Ios.Test
6{
8 public class NullableEntity : BusinessBase<NullableEntity>
9 {
10 public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name);
11
12 public string Name
13 {
14 get { return GetProperty(NameProperty); }
15 set { SetProperty(NameProperty, value); }
16 }
17
18 public static readonly PropertyInfo<int?> NullableIntegerProperty = RegisterProperty<int?>(c => c.NullableInteger);
19
20 public int? NullableInteger
21 {
22 get { return GetProperty(NullableIntegerProperty); }
23 set { SetProperty(NullableIntegerProperty, value); }
24 }
25
26 #region Rules
27
28 protected override void AddBusinessRules()
29 {
30 base.AddBusinessRules();
31
32 //Name
33 BusinessRules.AddRule(new ClearRule(NameProperty, NullableIntegerProperty));
34 }
35
36 private class ClearRule : Csla.Rules.PropertyRule
37 {
38
39 private Csla.Core.IPropertyInfo _clearProperty;
40
41 public ClearRule(Csla.Core.IPropertyInfo primaryProperty, Csla.Core.IPropertyInfo clearProperty)
42 : base(primaryProperty)
43 {
44 _clearProperty = clearProperty;
45 InputProperties = new List<Csla.Core.IPropertyInfo> { primaryProperty };
46 AffectedProperties.Add(_clearProperty);
47 }
48
49 protected override void Execute(Csla.Rules.IRuleContext context)
50 {
51 var input = (string)context.InputPropertyValues[PrimaryProperty];
52 if (string.IsNullOrEmpty(input))
53 {
54 context.AddOutValue(_clearProperty, null);
55 }
56 }
57 }
58
59 #endregion
60
62 {
64 }
65
66 protected override void DataPortal_Create()
67 {
68 Csla.ApplicationContext.GlobalContext.Add("NullableObject", "Created");
69 }
70 }
71}
Provides consistent context information between the client and server DataPortal objects.
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
Client side data portal used for making asynchronous data portal calls in .NET.
Definition: DataPortalT.cs:24
T Create(params object[] criteria)
Called by a factory method in a business class to create a new object, which is loaded with default v...
Definition: DataPortalT.cs:151
override void DataPortal_Create()
static readonly PropertyInfo< string > NameProperty
override void AddBusinessRules()
static readonly PropertyInfo< int?> NullableIntegerProperty
static NullableEntity NewNullableEntity()
Maintains metadata about a property.
Maintains metadata about a property.
Context information provided to a business rule when it is invoked.
Definition: IRuleContext.cs:22
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Execute
Execute operation.