using System; using System.ComponentModel; using Csla.Properties; namespace Csla { /// /// This is the base class from which readonly collections /// of readonly objects should be derived. /// /// Type of the list class. /// Type of child objects contained in the list. [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix")] [Serializable()] public abstract class ReadOnlyListBase : Core.ReadOnlyBindingList, Csla.Core.IReadOnlyCollection, ICloneable where T : ReadOnlyListBase { #region Constructors /// /// Creates an instance of the object. /// protected ReadOnlyListBase() { Initialize(); } #endregion #region Initialize /// /// Override this method to set up event handlers so user /// code in a partial class can respond to events raised by /// generated code. /// protected virtual void Initialize() { /* allows subclass to initialize events before any other activity occurs */ } #endregion #region ICloneable object ICloneable.Clone() { return GetClone(); } /// /// Creates a clone of the object. /// /// A new object containing the exact data of the original object. [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual object GetClone() { return Core.ObjectCloner.Clone(this); } /// /// Creates a clone of the object. /// /// /// A new object containing the exact data of the original object. /// public T Clone() { return (T)GetClone(); } #endregion #region Data Access [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")] private void DataPortal_Create(object criteria) { throw new NotSupportedException(Resources.CreateNotSupportedException); } /// /// Override this method to allow retrieval of an existing business /// object based on data in the database. /// /// An object containing criteria values to identify the object. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] protected virtual void DataPortal_Fetch(object criteria) { throw new NotSupportedException(Resources.FetchNotSupportedException); } private void DataPortal_Update() { throw new NotSupportedException(Resources.UpdateNotSupportedException); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")] private void DataPortal_Delete(object criteria) { throw new NotSupportedException(Resources.DeleteNotSupportedException); } /// /// Called by the server-side DataPortal prior to calling the /// requested DataPortal_xyz method. /// /// The DataPortalContext object passed to the DataPortal. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void DataPortal_OnDataPortalInvoke(DataPortalEventArgs e) { } /// /// Called by the server-side DataPortal after calling the /// requested DataPortal_xyz method. /// /// The DataPortalContext object passed to the DataPortal. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void DataPortal_OnDataPortalInvokeComplete(DataPortalEventArgs e) { } /// /// Called by the server-side DataPortal if an exception /// occurs during data access. /// /// The DataPortalContext object passed to the DataPortal. /// The Exception thrown during data access. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex) { } #endregion } }