Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"activationEvents": [
"onLanguage:csharp",
"onCommand:csharpextensions.createClass",
"onCommand:csharpextensions.createInterface"
"onCommand:csharpextensions.createInterface",
"onCommand:csharpextensions.createMVCControllerClass"
],
"main": "./out/src/extension",
"contributes": {
Expand All @@ -31,17 +32,28 @@
{
"command": "csharpextensions.createInterface",
"title": "New C# Interface"
},
{
"command": "csharpextensions.createMVCControllerClass",
"title": "New C# MVC Controller Class"
}
],
"menus": {
"explorer/context": [
{
"when":"explorerResourceIsFolder",
"group": "navigation@-1",
"command": "csharpextensions.createClass"
},
{
"when":"explorerResourceIsFolder",
"group": "navigation@-1",
"command": "csharpextensions.createInterface"
},
{
"when":"explorerResourceIsFolder && resourceFilename == Controllers",
"group": "navigation@-1",
"command": "csharpextensions.createMVCControllerClass"
}
]
},
Expand Down
5 changes: 5 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function activate(context: vscode.ExtensionContext) {
//context.subscriptions.push(disposable);
context.subscriptions.push(vscode.commands.registerCommand('csharpextensions.createClass', createClass));
context.subscriptions.push(vscode.commands.registerCommand('csharpextensions.createInterface', createInterface));
context.subscriptions.push(vscode.commands.registerCommand('csharpextensions.createMVCControllerClass', createMVCControllerClass));

const codeActionProvider = new CodeActionProvider();
let disposable = vscode.languages.registerCodeActionsProvider(documentSelector, codeActionProvider);
Expand All @@ -46,6 +47,10 @@ function createInterface(args) {
promptAndSave(args, 'interface');
}

function createMVCControllerClass(args) {
promptAndSave(args, 'mvccontrollerclass');
}

function promptAndSave(args, templatetype: string) {
if (args == null) {
args = { _fsPath: vscode.workspace.rootPath }
Expand Down
17 changes: 17 additions & 0 deletions templates/mvccontrollerclass.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace ${namespace}
{
public class ${classname} : Controller
{
public ActionResult Index()
{
return View();${cursor}
}
}
}