using System; using System.ComponentModel; using Csla.Properties; namespace Csla { /// /// This is the base class from which command /// objects will be derived. /// /// /// /// Command objects allow the execution of arbitrary server-side /// functionality. Most often, this involves the invocation of /// a stored procedure in the database, but can involve any other /// type of stateless, atomic call to the server instead. /// /// To implement a command object, inherit from CommandBase and /// override the DataPortal_Execute method. In this method you can /// implement any server-side code as required. /// /// To pass data to/from the server, use instance variables within /// the command object itself. The command object is instantiated on /// the client, and is passed by value to the server where the /// DataPortal_Execute method is invoked. The command object is then /// returned to the client by value. /// /// [Serializable()] public abstract class CommandBase : Core.ICommandObject { #region Constructors /// /// Creates an instance of the object. /// protected CommandBase() { 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 Data Access [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void DataPortal_Create(object criteria) { throw new NotSupportedException(Resources.CreateNotSupportedException); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void DataPortal_Fetch(object criteria) { throw new NotSupportedException(Resources.FetchNotSupportedException); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void DataPortal_Update() { throw new NotSupportedException(Resources.UpdateNotSupportedException); } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "criteria")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] private void DataPortal_Delete(object criteria) { throw new NotSupportedException(Resources.DeleteNotSupportedException); } /// /// Override this method to implement any server-side code /// that is to be run when the command is executed. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] protected virtual void DataPortal_Execute() { throw new NotSupportedException(Resources.ExecuteNotSupportedException); } /// /// 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 server-side processing. /// /// The DataPortalContext object passed to the DataPortal. /// The Exception thrown during processing. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", MessageId = "Member")] [EditorBrowsable(EditorBrowsableState.Advanced)] protected virtual void DataPortal_OnDataPortalException(DataPortalEventArgs e, Exception ex) { } #endregion } }