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