Skip to content

SignalR APIs For Client

Penghan Wang edited this page May 20, 2016 · 27 revisions

OpenProject

参数列表

参数 类型 备注
projectName string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
gitUrl string HTTPS 或 GIT 协议
gitUserNickName string git所需要的昵称
gitUserEmail string git所需要的电子邮箱地址
gitUserPassword string git所需要的电子邮箱地址
介绍

返回值

 isSucceeded 是否成功

 msg  "Success OpenProject"  / <error> 错误信息

该方法被Invoke时,会检测项目是否被Clone过,如果没有Clone则执行Clone动作。克隆完毕或已经存在项目则节点端会在拼合后的绝对路径中启动OmniSharp服务端,并在节点端端口占用表中检查,避免OmniSharp端口冲突(默认情况下OmniSharp端口为2000)。

获取该项目的全部分支,并回调客户端的OnBranchesReceived方法。

获取该项目当前分支,并回调客户端的OnBranchSwitched方法。

如果项目没有找到或其他原因导致该方法逻辑不能正常运行,将回调客户端ShowMessage方法。


ReadFile

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 欲读取文件的相对路径

介绍

该方法被Invoke时,节点端会读取该文件全部文本,如果读取成功,返回{"isSucceeded": true, "msg": "文件内容"}。若失败则返回{"isSucceeded": false, "msg": "错误详情"}


WriteFile

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 欲创建文件的相对路径
文件内容 string -

介绍

该方法被Invoke时,节点端向指定目标写入内容,如果该文件不存在则会自动创建,如果写入成功,返回{"isSucceeded": true, "isNew": 是否是新文件, "hasRestore" = 是否需要restore, "isRestored" = 是否已经restore}。若失败则返回{"isSucceeded": false, "msg": "错误详情"}。如果被修改文件的文件名为project.json则需要执行dnu restoredotnet restore


RemoveFile

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 欲删除文件的相对路径

介绍

该方法被Invoke时,节点端将删除指定的文件,如果删除成功,返回{"isSucceeded": true, "msg": "删除成功"},若失败,返回{"isSucceeded": false, "msg": "错误详情"}, 删除不存在文件,返回{"isSucceeded": true, "msg": "文件不存在}


CreateFolder

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
欲创建文件夹的目录 string 将在这个目录下创建文件夹,留空表示在根目录创建
文件夹名称 string 欲创建的文件夹的名称

介绍

该方法被Invoke时,节点端将在指定位置创建文件夹,如果创建成功,返回{"isSucceeded": true, "msg": "创建成功"},若失败,返回{"isSucceeded": false, "msg": "错误详情"}, 若文件夹已存在,返回{"isSucceeded": true, "msg": "文件夹已存在}


RemoveFolder

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件夹相对路径 string 将删除这个目录及这个目录下的全部子文件

介绍

该方法被Invoke时,节点端将删除指定的文件夹,如果删除成功,返回{"isSucceeded": true, "msg": "删除成功"},若失败,返回{"isSucceeded": false, "msg": "错误详情"}, 删除不存在文件夹,返回{"isSucceeded": true, "msg": "文件夹不存在}


RenameFile

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件所在目录 string 欲修改文件名的文件所在目录
当前文件名 string 欲修改文件名的文件当前的文件名
新文件名 string 欲修改成的文件名

介绍

该方法被Invoke时,节点端将重命名指定的文件。如果修改成功,返回{"isSucceeded": true, "msg": "重命名成功},若失败,返回{"isSucceeded": false, "msg": "错误详情"},如果当前文件不存在,返回{"isSucceeded": false, "msg": "源文件不存在},如果新文件已存在,返回{"isSucceeded": false, "msg": "目标文件已存在}


RenameFolder

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
欲重命名的文件夹所在目录 string 表示欲重命名的文件夹在该目录下,留空表示欲重命名的文件夹在根目录下。
当前名称 string 文件夹的当前名称
新名称 string 文件夹重命名后的名称

介绍

该方法被Invoke时,节点端将重命名指定的文件夹。如果修改成功,返回{"isSucceeded": true, "msg": "重命名成功},若失败,返回{"isSucceeded": false, "msg": "错误详情"},如果当前文件夹不存在,返回{"isSucceeded": false, "msg": "源文件夹不存在},如果新文件夹已存在,返回{"isSucceeded": false, "msg": "目标文件夹已存在}


AutoComplete

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 表示欲执行代码联想的代码文件的响度路径
行号 int 欲执行代码联想的位置(行)
列号 int 欲执行代码联想的位置(列)
字符串 string 欲执行代码联想的字符或字符串
代码内容 string 客户端传递的当前编辑中的代码内容

介绍

成功时返回json样式:{"isSucceeded": "true", "msg": "[{"CompletionText":"string","Description":null,"DisplayText":"string","RequiredNamespaceImport":null,"MethodHeader":null,"ReturnType":null,"Snippet":"string","Kind":null},{"CompletionText":"String","Description":null,"DisplayText":"string","RequiredNamespaceImport":null,"MethodHeader":"string","ReturnType":null,"Snippet":"string$0","Kind":null}]"}, 失败时返回:{"isSucceeded": "false", "msg": "错误详情"}


CodeCheck

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 表示欲执行代码检查的代码文件相对路径
代码内容 string 客户端传递的当前编辑中的代码内容

介绍

成功时返回json样式:{"isSucceeded": "true", "msg": "{"QuickFixes":[{"LogLevel":"Error","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":11,"Column":16,"EndLine":11,"EndColumn":16,"Text":"; expected","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Error","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":7,"Column":18,"EndLine":7,"EndColumn":25,"Text":"The namespace 'ConsoleApplication' already contains a definition for 'Program'","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Error","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":9,"Column":28,"EndLine":9,"EndColumn":32,"Text":"Type 'Program' already defines a member called 'Main' with the same parameter types","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Error","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":11,"Column":13,"EndLine":11,"EndColumn":16,"Text":"The name 'str' does not exist in the current context","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Error","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\Program.cs","Line":9,"Column":28,"EndLine":9,"EndColumn":32,"Text":"Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Hidden","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":2,"Column":1,"EndLine":2,"EndColumn":19,"Text":"Unnecessary using directive.","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Hidden","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":3,"Column":1,"EndLine":3,"EndColumn":26,"Text":"Unnecessary using directive.","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"LogLevel":"Hidden","FileName":"D:\\Pomelo\\Pomelo.NetCore.Node\\newtest\\test.cs","Line":1,"Column":1,"EndLine":1,"EndColumn":14,"Text":"Unnecessary using directive.","Projects":["newtest+netcoreapp1.0","newtest+net451"]}]}"}, 失败时返回:{"isSucceeded": "false", "msg": "错误详情"}


Highlight

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
文件相对路径 string 表示欲执行代码高亮的代码文件相对路径
代码内容 string 客户端传递的当前编辑中的代码内容

介绍

成功时返回json样式:{"isSucceeded": "true", "msg": "{"Highlights":[{"StartLine":1,"StartColumn":1,"EndLine":1,"EndColumn":6,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":1,"StartColumn":7,"EndLine":1,"EndColumn":13,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":1,"StartColumn":13,"EndLine":1,"EndColumn":14,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":2,"StartColumn":1,"EndLine":2,"EndColumn":6,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":2,"StartColumn":7,"EndLine":2,"EndColumn":13,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":2,"StartColumn":13,"EndLine":2,"EndColumn":14,"Kind":"operator","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":2,"StartColumn":14,"EndLine":2,"EndColumn":18,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":2,"StartColumn":18,"EndLine":2,"EndColumn":19,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":3,"StartColumn":1,"EndLine":3,"EndColumn":6,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":3,"StartColumn":7,"EndLine":3,"EndColumn":13,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":3,"StartColumn":13,"EndLine":3,"EndColumn":14,"Kind":"operator","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":3,"StartColumn":14,"EndLine":3,"EndColumn":25,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":3,"StartColumn":25,"EndLine":3,"EndColumn":26,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":5,"StartColumn":1,"EndLine":5,"EndColumn":10,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":5,"StartColumn":11,"EndLine":5,"EndColumn":29,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":6,"StartColumn":1,"EndLine":6,"EndColumn":2,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":7,"StartColumn":5,"EndLine":7,"EndColumn":11,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":7,"StartColumn":12,"EndLine":7,"EndColumn":17,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":7,"StartColumn":18,"EndLine":7,"EndColumn":25,"Kind":"class name","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":8,"StartColumn":5,"EndLine":8,"EndColumn":6,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":9,"EndLine":9,"EndColumn":15,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":16,"EndLine":9,"EndColumn":22,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":23,"EndLine":9,"EndColumn":27,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":28,"EndLine":9,"EndColumn":32,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":32,"EndLine":9,"EndColumn":33,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":33,"EndLine":9,"EndColumn":39,"Kind":"keyword","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":39,"EndLine":9,"EndColumn":40,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":40,"EndLine":9,"EndColumn":41,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":42,"EndLine":9,"EndColumn":46,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":9,"StartColumn":46,"EndLine":9,"EndColumn":47,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":10,"StartColumn":9,"EndLine":10,"EndColumn":10,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":11,"StartColumn":13,"EndLine":11,"EndColumn":16,"Kind":"identifier","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":12,"StartColumn":9,"EndLine":12,"EndColumn":10,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":13,"StartColumn":5,"EndLine":13,"EndColumn":6,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]},{"StartLine":14,"StartColumn":1,"EndLine":14,"EndColumn":2,"Kind":"punctuation","Projects":["newtest+netcoreapp1.0","newtest+net451"]}]}, 失败时返回:{"isSucceeded": "false", "msg": "错误详情"}


GetProjectInfo

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node

介绍

该方法被Invoke时,将获取整个项目目录,读取全部的project.json文件,并分析提取出项目的标题以及project.json中的位置。JSON格式如下:{"Project":[{"Title":"newtest","Path":"\\newtest"},{"Title":"test","Path":"\\test"}]},若失败,返回{"isSucceeded": false, "msg": "错误详情"}


RunCommand

参数列表

参数 类型 备注
项目名称 string 项目Clone至~/中,假如项目为Polemo.NetCore.Node,该参数传递的是Polemo.NetCore.Node
命令 string 如web、ef或kestrel等在project.json中commands段中定义的命令。
项目路径 string 该command所属的project.json所在路径

介绍

该方法被Invoke时,将调用dnu restoredotnet restore。然后即执行传递的命令。运行后节点端会生成一个会话ID,与进程一一对应,同时回调客户端的OnProjectRun方法,将会话ID一并传递。每当控制台输出时,将回调客户端的OnConsoleOutput方法。若运行失败则回调客户端的ShowMessage方法反馈错误信息。

ConsoleWrite

参数列表

参数 类型 备注
会话ID string 在执行RunCommand命令时由节点端提供的ID(用于与进程对应的)
顺序 int 防止后键入的字符先被写入标准输入流
字符 char 键入的字符

介绍

该方法被Invoke时,节点端将通过标准输入流向控制台输入指定的字符。该方法不回调客户端方法。