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.
ReadOnlyListBase.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ReadOnlyListBase.cs" company="Marimer LLC">
3// Copyright (c) Marimer LLC. All rights reserved.
4// Website: https://cslanet.com
5// </copyright>
6// <summary>This is the base class from which readonly collections</summary>
7//-----------------------------------------------------------------------
8using System.Collections.Generic;
9using System.ComponentModel;
10using System.Diagnostics.CodeAnalysis;
11using Csla.Properties;
12using System;
13
14namespace Csla
15{
22 [SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
24 public abstract class ReadOnlyListBase<T, C> :
25#if (ANDROID || IOS) || NETFX_CORE
26 Core.ReadOnlyBindingList<C>,
27#else
28 Core.ReadOnlyObservableBindingList<C>,
29#endif
30 Csla.Core.IReadOnlyCollection,
31 ICloneable, Server.IDataPortalTarget,
32 IReadOnlyListBase<C>, Core.IUseApplicationContext
33 where T : ReadOnlyListBase<T, C>
34 {
38 protected ApplicationContext ApplicationContext { get; private set; }
39 ApplicationContext Core.IUseApplicationContext.ApplicationContext
40 {
41 get => ApplicationContext;
42 set
43 {
44 ApplicationContext = value;
45 Initialize();
46 }
47 }
48
52 protected ReadOnlyListBase()
53 { }
54
55 #region Initialize
56
62 protected virtual void Initialize()
63 { /* allows subclass to initialize events before any other activity occurs */ }
64
65 #endregion
66
67 #region Identity
68
69 int Core.IBusinessObject.Identity
70 {
71 get { return 0; }
72 }
73
74 #endregion
75
76 #region ICloneable
77
78 object ICloneable.Clone()
79 {
80 return GetClone();
81 }
86 [EditorBrowsable(EditorBrowsableState.Advanced)]
87 protected virtual object GetClone()
88 {
89 return Core.ObjectCloner.GetInstance(ApplicationContext).Clone(this);
90 }
91
98 public T Clone()
99 {
100 return (T)GetClone();
101 }
102
103 #endregion
104
105 #region ToArray
106
110 public C[] ToArray()
111 {
112 return new List<C>(this).ToArray();
113 }
114 #endregion
115
116 #region Data Access
117
118 private void DataPortal_Update()
119 {
120 throw new NotSupportedException(Resources.UpdateNotSupportedException);
121 }
122
123 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")]
124 [Delete]
125 private void DataPortal_Delete(object criteria)
126 {
127 throw new NotSupportedException(Resources.DeleteNotSupportedException);
128 }
129
135 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
136 [EditorBrowsable(EditorBrowsableState.Advanced)]
138 {
139
140 }
141
147 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
148 [EditorBrowsable(EditorBrowsableState.Advanced)]
150 {
151
152 }
153
160 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
161 [EditorBrowsable(EditorBrowsableState.Advanced)]
162 protected virtual void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
163 {
164
165 }
166
172 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
173 [EditorBrowsable(EditorBrowsableState.Advanced)]
175 {
176 }
177
183 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
184 [EditorBrowsable(EditorBrowsableState.Advanced)]
186 {
187 }
188
195 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
196 [EditorBrowsable(EditorBrowsableState.Advanced)]
197 protected virtual void Child_OnDataPortalException(DataPortalEventArgs e, Exception ex)
198 {
199 }
200
201 #endregion
202
203 #region IDataPortalTarget Members
204
205 void Csla.Server.IDataPortalTarget.CheckRules()
206 { }
207
208 void Csla.Server.IDataPortalTarget.MarkAsChild()
209 { }
210
211 void Csla.Server.IDataPortalTarget.MarkNew()
212 { }
213
214 void Csla.Server.IDataPortalTarget.MarkOld()
215 { }
216
217 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalInvoke(DataPortalEventArgs e)
218 {
220 }
221
222 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
223 {
225 }
226
227 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
228 {
230 }
231
232 void Csla.Server.IDataPortalTarget.Child_OnDataPortalInvoke(DataPortalEventArgs e)
233 {
235 }
236
237 void Csla.Server.IDataPortalTarget.Child_OnDataPortalInvokeComplete(DataPortalEventArgs e)
238 {
240 }
241
242 void Csla.Server.IDataPortalTarget.Child_OnDataPortalException(DataPortalEventArgs e, Exception ex)
243 {
244 this.Child_OnDataPortalException(e, ex);
245 }
246
247 #endregion
248 }
249}
Provides consistent context information between the client and server DataPortal objects.
ApplicationContext(ApplicationContextAccessor applicationContextAccessor)
Creates a new instance of the type
Provides information about the DataPortal call.
A strongly-typed resource class, for looking up localized strings, etc.
static string DeleteNotSupportedException
Looks up a localized string similar to Invalid operation - delete not allowed.
static string UpdateNotSupportedException
Looks up a localized string similar to Invalid operation - update not allowed.
This is the base class from which readonly collections of readonly objects should be derived.
C[] ToArray()
Get an array containing all items in the list.
virtual object GetClone()
Creates a clone of the object.
ReadOnlyListBase()
Creates an instance of the type.
virtual void Initialize()
Override this method to set up event handlers so user code in a partial class can respond to events r...
virtual void Child_OnDataPortalInvoke(DataPortalEventArgs e)
Called by the server-side DataPortal prior to calling the requested DataPortal_XYZ method.
virtual void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
Called by the server-side DataPortal if an exception occurs during data access.
virtual void DataPortal_OnDataPortalInvoke(DataPortalEventArgs e)
Called by the server-side DataPortal prior to calling the requested DataPortal_xyz method.
virtual void Child_OnDataPortalInvokeComplete(DataPortalEventArgs e)
Called by the server-side DataPortal after calling the requested DataPortal_XYZ method.
ApplicationContext ApplicationContext
Gets the current ApplicationContext
virtual void Child_OnDataPortalException(DataPortalEventArgs e, Exception ex)
Called by the server-side DataPortal if an exception occurs during data access.
virtual void DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
Called by the server-side DataPortal after calling the requested DataPortal_xyz method.
T Clone()
Creates a clone of the object.
This is the base class from which readonly collections of readonly objects should be derived.
@ Serializable
Prevents updating or inserting until the transaction is complete.