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.netcore.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<string> DataProperty = RegisterProperty<string>(c => c.Data);
18 public string Data
19 {
20 get { return GetProperty(DataProperty); }
21 set { SetProperty(DataProperty, value); }
22 }
23
24 public static PropertyInfo<int> CreatedDomainProperty = RegisterProperty<int>(c => c.CreatedDomain);
25 public int CreatedDomain
26 {
27 get { return GetProperty(CreatedDomainProperty); }
28 private set { LoadProperty(CreatedDomainProperty, value); }
29 }
30
31 public static readonly PropertyInfo<Children> ChildrenProperty = RegisterProperty<Children>(c => c.Children);
33 {
34 get { return GetProperty(ChildrenProperty); }
35 private set { LoadProperty(ChildrenProperty, value); }
36 }
37
38 [Serializable()]
39 public class Criteria
40 {
41 public string _data;
42
43 public Criteria()
44 {
45 _data = "<new>";
46 }
47
48 public Criteria(string data)
49 {
50 this._data = data;
51 }
52 }
53
54 [Create]
55 private void DataPortal_Create(Criteria criteria, [Inject] IChildDataPortal<Children> dataPortal)
56 {
57 using (BypassPropertyChecks)
58 {
59 Data = criteria._data;
60 Children = dataPortal.CreateChild();
61 }
62 CreatedDomain = AppDomain.CurrentDomain.Id;
63 TestResults.Add("Root", "Created");
64 }
65
66 [Fetch]
67 protected void DataPortal_Fetch(Criteria criteria, [Inject] IChildDataPortal<Children> dataPortal)
68 {
69 using (BypassPropertyChecks)
70 {
71 Data = criteria._data;
72 Children = dataPortal.CreateChild();
73 }
74 MarkOld();
75 TestResults.Add("Root", "Fetched");
76 }
77
78 [Insert]
79 protected void DataPortal_Insert()
80 {
81 TestResults.Add("Root", "Inserted");
82 }
83
84 [Update]
85 protected void DataPortal_Update()
86 {
87 //we would update here
88 TestResults.Add("Root", "Updated");
89 }
90
91 [DeleteSelf]
92 protected void DataPortal_DeleteSelf()
93 {
94 TestResults.Add("Root", "Deleted self");
95 }
96
97 [Delete]
98 protected void DataPortal_Delete(object criteria)
99 {
100 TestResults.Add("Root", "Deleted");
101 }
102
103 protected override void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
104 {
105 TestResults.Add("Deserialized", "root Deserialized");
106 }
107
109 {
110 TestResults.Add("dpinvoke", "Invoked");
111 }
112
114 {
115 TestResults.Add("dpinvokecomplete", "InvokeCompleted");
116 }
117
118 internal int GetEditLevel()
119 {
120 return EditLevel;
121 }
122 }
123}
This is the base class from which most business objects will be derived.
Definition: BusinessBase.cs:38
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)
override void OnDeserialized(System.Runtime.Serialization.StreamingContext context)
void DataPortal_Fetch(Criteria criteria, [Inject] IChildDataPortal< Children > dataPortal)
static PropertyInfo< string > DataProperty
Static dictionary-like class that offers similar functionality to GlobalContext This is used in tests...
Definition: TestResults.cs:21
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 child data portal type.
@ Serializable
Prevents updating or inserting until the transaction is complete.
@ Update
Update operation (includes insert, update and delete self).
@ Fetch
Fetch operation.
@ Create
Create operation.
@ Delete
Delete operation.