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.
Csla.test/Basic/Root.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="Root.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
12namespace Csla.Test.Basic
13{
14 [Serializable()]
15 public class Root : BusinessBase<Root>
16 {
17 public static PropertyInfo<Children> ChildrenProperty = RegisterProperty<Children>(c => c.Children);
18
19 public static PropertyInfo<string> DataProperty = RegisterProperty<string>(c => c.Data);
20 public string Data
21 {
22 get { return GetProperty(DataProperty); }
23 set { SetProperty(DataProperty, value); }
24 }
25
26 public static PropertyInfo<int> CreatedDomainProperty = RegisterProperty<int>(c => c.CreatedDomain);
27 public int CreatedDomain
28 {
29 get { return GetProperty(CreatedDomainProperty); }
30 private set { LoadProperty(CreatedDomainProperty, value); }
31 }
32
33 public Children Children
34 {
35 get { return GetProperty(ChildrenProperty); }
36 }
37
40 public override bool IsDirty
41 {
42 get
43 {
44 return base.IsDirty || ReadProperty(ChildrenProperty).IsDirty;
45 }
46 }
47
48 [Serializable()]
49 internal class Criteria
50 {
51 public string _data;
52
53 public Criteria()
54 {
55 _data = "<new>";
56 }
57
58 public Criteria(string data)
59 {
60 this._data = data;
61 }
62 }
63
64 private void DataPortal_Create(object criteria, [Inject] IDataPortal<Children> childrenDataPortal)
65 {
66 Criteria crit = (Criteria)(criteria);
67 using (BypassPropertyChecks)
68 {
69 LoadProperty(DataProperty, crit._data);
70 LoadProperty(ChildrenProperty, childrenDataPortal.Create());
71 }
72
73 CreatedDomain = AppDomain.CurrentDomain.Id;
74 TestResults.Add("Root", "Created");
75 }
76
77 protected void DataPortal_Fetch(object criteria, [Inject] IDataPortal<Children> childrenDataPortal)
78 {
79 Criteria crit = (Criteria)(criteria);
80 using (BypassPropertyChecks)
81 {
82 LoadProperty(DataProperty, crit._data);
83 LoadProperty(ChildrenProperty, childrenDataPortal.Create());
84 }
85 MarkOld();
86 TestResults.Add("Root", "Fetched");
87 }
88
89 [Insert]
90 protected void DataPortal_Insert()
91 {
92 TestResults.Add("clientcontext",
93 ApplicationContext.ClientContext["clientcontext"]?.ToString());
94
95 TestResults.AddOrOverwrite("globalcontext",
96 TestResults.GetResult("globalcontext"));
97
98 TestResults.AddOrOverwrite("globalcontext", "new global value");
99
100 TestResults.Add("Root", "Inserted");
101 }
102
103 [Update]
104 protected void DataPortal_Update()
105 {
106 //we would update here
107 TestResults.Add("Root", "Updated");
108 }
109
110 [DeleteSelf]
111 protected void DataPortal_DeleteSelf()
112 {
113 TestResults.Add("Root", "Deleted self");
114 }
115
116 [Delete]
117 protected void DataPortal_Delete(object criteria)
118 {
119 TestResults.Add("Root", "Deleted");
120 }
121
122 protected override void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
123 {
124 TestResults.Add("Deserialized", "root Deserialized");
125 }
126
128 {
129 TestResults.Add("dpinvoke", TestResults.GetResult("global"));
130 }
131
133 {
134 TestResults.Add("dpinvokecomplete", TestResults.GetResult("global"));
135 }
136
137 }
138}
Provides consistent context information between the client and server DataPortal objects.
ContextDictionary ClientContext
Returns the application-specific context data provided by the client.
Provides information about the DataPortal call.
Maintains metadata about a property.
static PropertyInfo< int > CreatedDomainProperty
override void DataPortal_OnDataPortalInvoke(DataPortalEventArgs e)
static readonly PropertyInfo< Children > ChildrenProperty
override void DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
void DataPortal_Delete(object criteria)
void DataPortal_Fetch(object criteria, [Inject] IDataPortal< Children > childrenDataPortal)
override void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
static PropertyInfo< string > DataProperty
override bool IsDirty
start editing
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
static string GetResult(string key)
Get a result of an operation from the underlying results dictionary
Definition: TestResults.cs:49
static void AddOrOverwrite(string key, string value)
Overwrite an item in the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:39
static void Add(string key, string value)
Add an item to the test results, to indicate an outcome of a particular operation
Definition: TestResults.cs:29
Interface defining the members of the data portal type.
Definition: IDataPortalT.cs:17
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Delete
Delete operation.