Skip to content

Commit d9ec746

Browse files
2 parents 4c845ca + dbf9ece commit d9ec746

File tree

1 file changed

+31
-12
lines changed
  • src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands

1 file changed

+31
-12
lines changed

src/toolkit/Community.VisualStudio.Toolkit.Shared/Commands/BaseCommand.cs

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,9 @@ namespace Community.VisualStudio.Toolkit
2424
/// </code>
2525
/// </example>
2626
/// <typeparam name="T">The implementation type itself.</typeparam>
27-
public abstract class BaseCommand<T> where T : class, new()
27+
public abstract class BaseCommand<T> : BaseCommand
28+
where T : class, new()
2829
{
29-
/// <summary>
30-
/// The command object associated with the command ID (GUID/ID).
31-
/// </summary>
32-
public OleMenuCommand Command { get; private set; } = null!; // This property is initialized in `InitializeAsync`, so it's never actually null.
33-
34-
/// <summary>
35-
/// The package class that initialized this class.
36-
/// </summary>
37-
public AsyncPackage Package { get; private set; } = null!; // This property is initialized in `InitializeAsync`, so it's never actually null.
38-
3930
/// <summary>
4031
/// Initializes the command. This method must be called from the <see cref="AsyncPackage.InitializeAsync"/> method for the command to work.
4132
/// </summary>
@@ -80,12 +71,40 @@ public static async Task<T> InitializeAsync(AsyncPackage package)
8071
/// <summary>Allows the implementor to manipulate the command before its execution.</summary>
8172
/// <remarks>
8273
/// This method is invoked right after the <see cref="InitializeAsync(AsyncPackage)"/> method is executed and allows you to
83-
/// manipulate the <see cref="Command"/> property etc. as part of the initialization phase.
74+
/// manipulate the <see cref="BaseCommand.Command"/> property etc. as part of the initialization phase.
8475
/// </remarks>
8576
protected virtual Task InitializeCompletedAsync()
8677
{
8778
return Task.CompletedTask;
8879
}
80+
}
81+
82+
/// <summary>
83+
/// A base class that makes it easier to handle commands.
84+
/// </summary>
85+
/// <example>
86+
/// <code>
87+
/// [Command("489ba882-f600-4c8b-89db-eb366a4ee3b3", 0x0100)]
88+
/// public class TestCommand : BaseCommand&lt;TestCommand&gt;
89+
/// {
90+
/// protected override Task ExecuteAsync(OleMenuCmdEventArgs e)
91+
/// {
92+
/// return base.ExecuteAsync(e);
93+
/// }
94+
/// }
95+
/// </code>
96+
/// </example>
97+
public abstract class BaseCommand
98+
{
99+
/// <summary>
100+
/// The command object associated with the command ID (GUID/ID).
101+
/// </summary>
102+
public OleMenuCommand Command { get; protected set; } = null!; // This property is initialized in `InitializeAsync`, so it's never actually null.
103+
104+
/// <summary>
105+
/// The package class that initialized this class.
106+
/// </summary>
107+
public AsyncPackage Package { get; protected set; } = null!; // This property is initialized in `InitializeAsync`, so it's never actually null.
89108

90109
/// <summary>Executes synchronously when the command is invoked.</summary>
91110
/// <remarks>

0 commit comments

Comments
 (0)