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.
ReadOnlyBindingListBase.cs
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// <copyright file="ReadOnlyBindingListBase.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//-----------------------------------------------------------------------
8#if NETFX_CORE
9using System;
10
11namespace Csla
12{
20 public abstract class ReadOnlyBindingListBase<T, C> : ReadOnlyListBase<T, C>
21 where T : ReadOnlyBindingListBase<T, C>
22 { }
23}
24#else
25using System;
26using System.Collections.Generic;
27using System.ComponentModel;
28using System.Linq.Expressions;
29using Csla.Properties;
30
31namespace Csla
32{
39 [System.Diagnostics.CodeAnalysis.SuppressMessage(
40 "Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")]
41 [Serializable()]
42 public abstract class ReadOnlyBindingListBase<T, C> :
43 Core.ReadOnlyBindingList<C>, Csla.Core.IReadOnlyCollection,
44 ICloneable, Server.IDataPortalTarget, Core.IUseApplicationContext
45 where T : ReadOnlyBindingListBase<T, C>
46 {
50 protected ApplicationContext ApplicationContext { get; private set; }
51 ApplicationContext Core.IUseApplicationContext.ApplicationContext
52 {
53 get => ApplicationContext;
54 set
55 {
56 ApplicationContext = value;
57 Initialize();
58 }
59 }
60
65 { }
66
67#region Initialize
68
74 protected virtual void Initialize()
75 { /* allows subclass to initialize events before any other activity occurs */ }
76
77#endregion
78
79#region ICloneable
80
81 object ICloneable.Clone()
82 {
83 return GetClone();
84 }
89 [EditorBrowsable(EditorBrowsableState.Advanced)]
90 protected virtual object GetClone()
91 {
92 return Core.ObjectCloner.GetInstance(ApplicationContext).Clone(this);
93 }
94
101 public T Clone()
102 {
103 return (T)GetClone();
104 }
105
106#endregion
107
108#region Data Access
109
110 private void DataPortal_Update()
111 {
112 throw new NotSupportedException(Resources.UpdateNotSupportedException);
113 }
114
115 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")]
116 [Delete]
117 private void DataPortal_Delete(object criteria)
118 {
119 throw new NotSupportedException(Resources.DeleteNotSupportedException);
120 }
121
127 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
128 [EditorBrowsable(EditorBrowsableState.Advanced)]
130 {
131
132 }
133
139 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
140 [EditorBrowsable(EditorBrowsableState.Advanced)]
142 {
143
144 }
145
152 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
153 [EditorBrowsable(EditorBrowsableState.Advanced)]
154 protected virtual void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
155 {
156
157 }
158
164 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
165 [EditorBrowsable(EditorBrowsableState.Advanced)]
167 {
168 }
169
175 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
176 [EditorBrowsable(EditorBrowsableState.Advanced)]
178 {
179 }
180
187 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")]
188 [EditorBrowsable(EditorBrowsableState.Advanced)]
189 protected virtual void Child_OnDataPortalException(DataPortalEventArgs e, Exception ex)
190 {
191 }
192
193#endregion
194
195#region ToArray
196
200 public C[] ToArray()
201 {
202 List<C> result = new List<C>();
203 foreach (C item in this)
204 result.Add(item);
205 return result.ToArray();
206 }
207#endregion
208
209#region IDataPortalTarget Members
210
211 void Csla.Server.IDataPortalTarget.CheckRules()
212 { }
213
214 void Csla.Server.IDataPortalTarget.MarkAsChild()
215 { }
216
217 void Csla.Server.IDataPortalTarget.MarkNew()
218 { }
219
220 void Csla.Server.IDataPortalTarget.MarkOld()
221 { }
222
223 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalInvoke(DataPortalEventArgs e)
224 {
226 }
227
228 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
229 {
231 }
232
233 void Csla.Server.IDataPortalTarget.DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
234 {
236 }
237
238 void Csla.Server.IDataPortalTarget.Child_OnDataPortalInvoke(DataPortalEventArgs e)
239 {
241 }
242
243 void Csla.Server.IDataPortalTarget.Child_OnDataPortalInvokeComplete(DataPortalEventArgs e)
244 {
246 }
247
248 void Csla.Server.IDataPortalTarget.Child_OnDataPortalException(DataPortalEventArgs e, Exception ex)
249 {
250 this.Child_OnDataPortalException(e, ex);
251 }
252
253#endregion
254 }
255}
256#endif
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.
T Clone()
Creates a clone of the object.
C[] ToArray()
Get an array containing all items in the list.
virtual object GetClone()
Creates a clone of the object.
virtual void Child_OnDataPortalInvokeComplete(DataPortalEventArgs e)
Called by the server-side DataPortal after calling the requested DataPortal_XYZ method.
virtual void DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e)
Called by the server-side DataPortal after calling the requested DataPortal_xyz method.
virtual void Child_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.
ApplicationContext ApplicationContext
Gets the current ApplicationContext
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 DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex)
Called by the server-side DataPortal if an exception occurs during data access.
ReadOnlyBindingListBase()
Creates an instance of the type.
virtual void Child_OnDataPortalInvoke(DataPortalEventArgs e)
Called by the server-side DataPortal prior to calling the requested DataPortal_XYZ method.
@ Serializable
Prevents updating or inserting until the transaction is complete.