ControllerGenerator/ControllerGenerator.cs
(完整代码) 1KBusing CommonUtils;
using ControllerGenerator.Commands;
using Microsoft;
using Microsoft.VisualStudio.Shell;
using System;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using System.Threading;
using Task = System.Threading.Tasks.Task;
namespace ControllerGenerator
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[Guid("e15fb2dd-d91c-465e-9f74-f9343cd43da2")]
[ProvideMenuResource("Menus.ctmenu", 1)]
public sealed class ControllerGenerator : AsyncPackage
{
static readonly Guid _menuGroupId = new Guid("f0a65cda-66ff-4da1-a8c5-a10f3c89245f");
static OleMenuCommandService _commandService;
private static void AddMenuCommand(int id, EventHandler handler)
=> _commandService.AddCommand(new MenuCommand(handler, new CommandID(_menuGroupId, id)));
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(DisposalToken);
_commandService = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;
Assumes.Present(_commandService);
EditorUtil.SetServiceProvider(this);
///显示顺序是按照ID来的,跟添加顺序和ASCII顺序无关,ID随便写,但是要与vsct中统一
AddMenuCommand(9000, DbContextGenerator.Handler);
AddMenuCommand(9001, DbControllerGenerator.Handler);
AddMenuCommand(9002, FileControllerGenerator.Handler);
"欢迎使用Controller生成插件.".Print();
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。