UpdateAction Class |
Namespace: Kjs.AppLife.Update.Engine.Core
The UpdateAction type exposes the following members.
Name | Description | |
---|---|---|
![]() | UpdateAction |
Initializes a new instance of the UpdateAction class.
|
Name | Description | |
---|---|---|
![]() | Cleanup |
Performs any cleanup work needed by the UpdateAction after the target
application has been completely updated.
|
![]() | Equals | (Inherited from Object.) |
![]() | Execute |
Executes the UpdateAction, updating the target application.
|
![]() | Finalize | Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | OnProgressChanged |
Raises the ProgressChanged event.
|
![]() | Prepare |
Prepares the target application, performing any tasks needed before Execute(UpdateContext)
can be called.
|
![]() | RollbackExecute |
Rolls back any work performed in Execute(UpdateContext).
|
![]() | RollbackPrepare |
Rolls back any work performed in Prepare(UpdateContext).
|
![]() | ToString | (Inherited from Object.) |
Name | Description | |
---|---|---|
![]() | ProgressChanged |
Occurs when progress is made during Execute(UpdateContext), Prepare(UpdateContext),
Cleanup(UpdateContext), RollbackExecute(UpdateContext), or RollbackPrepare(UpdateContext).
|
To create a custom action, inherit from UpdateAction, provide a public parameterless constructor and implementations for Execute(UpdateContext) and RollbackExecute(UpdateContext).
For storage in projects and in update packages, actions are serialized using an XmlSerializer. In general, public read-write properties and fields will be automatically serialized. See the XmlSerializer documentation for more information on serialization.
When an update is performed, the following steps are taken in order:
If any error occurs when calling Prepare(UpdateContext), RollbackPrepare(UpdateContext) is called on all actions that completed Prepare(UpdateContext) in reverse order.
If any error occurs when calling Execute(UpdateContext), RollbackExecute(UpdateContext) is called on all actions that completed Execute(UpdateContext) in reverse order, then RollbackPrepare(UpdateContext) is called on all actions in reverse order.
Errors in Cleanup(UpdateContext) are ignored.
Execute(UpdateContext) should contain the primary task performed by the action, and RollbackExecute(UpdateContext) should reverse the effect of that task.
Prepare(UpdateContext) should contain any preparation that needs to be performed before any actions execute, and can throw an exception to abort the update before any changes are made. RollbackPrepare(UpdateContext) should reverse the effect of Prepare(UpdateContext).
Cleanup(UpdateContext) should perform nonessential cleanup that cannot be performed until the update has succeeded.
All five of these methods can optionally call OnProgressChanged(UpdateProgressChangedEventArgs) to report progress from 0 to 100 percent. If no progress events are raised in this way, AppLife Update will automatically report 100% progress for each method when it returns.
Custom actions will appear in the action palette automatically when an assembly that they reside in is added in the AppLife update creation application. The default editor for custom actions uses a PropertyGrid and so only public read-write properties can be edited. To use a custom editor for an action, provide an ActionBuilderAttribute on the action and specify the type of ActionBuilder to use. An ActionBuilder can also perform work when building the update package (such as copying files to go with the update) and customize the action's appearance in the action list.
To customize an action's appearance in the action palette, you can provide an ActionPaletteItemAttribute on the action and specify the type of ActionPaletteItem to use. Alternatively, you can specify one or more of the following attributes on the action, which will be automatically used by the default ActionPaletteItem:
Attribute | Effect |
---|---|
DisplayNameAttribute | Specifies the name of the action as it will appear in the palette. Unless a different name is specified by an ActionBuilder, this name will also be used in the action list |
CategoryAttribute | Specifies the palette category of the action. |
DescriptionAttribute | Specifies the action's tooltip in the palette. |
ToolboxBitmapAttribute | Specifies the image that will be used for the action in the palette. Unless a different image is specified by an ActionBuilder, this image will also be used in the action list. |
using Kjs.AppLife.Update.Engine.Core; public class MyAction : UpdateAction { private int mNumber; private string mText; public MyAction() { } public int Number { get { return mNumber; } set { mNumber = value; } } public string Text { get { return mText; } set { mText = value; } } public override void Execute(UpdateContext context) { return; } public override void RollbackExecute(UpdateContext context) { return; } }
using Kjs.AppLife.Update.Engine.Core; [System.ComponentModel.DisplayName("My other action")] public class MyOtherAction : UpdateAction { public MyOtherAction() { } public override void Execute(UpdateContext context) { return; } public override void RollbackExecute(UpdateContext context) { return; } }