错误:'公共共享功能创建(分支为分支)为分支
的参数太多
我的代码:Branch.vb
...
Inherits Resources
Private Const Path As String = "branches"
...
Public Shared Function Create(branch As Branch) As Branch
Return Create(branch, Path) 'Path is underlined with error
End Function
我的Resources.vb文件:
Public Shared Function Create(Of T As {Resources, New})(resource As T, path As String) As T
Dim request = CreateRequest(path, Method.POST)
request.AddBody(resource)
Dim client = CreateClient()
Dim responce = client.Execute(Of T)(request)
If responce.StatusCode <> HttpStatusCode.Created Then
Throw New InvalidOperationException("Create Failed: " & Convert.ToString(responce.StatusCode))
End If
Return responce.Data
End Function
现在在我的资源文件中它在标题和我的branch.vb中使用了2个值我指定了2个值,但是我仍然有错误?这可能是什么?
答案 0 :(得分:0)
我认为这里的问题是你似乎认为Shared
方法是可继承的(它们不是')。因此,当您致电Branch
时,如果您处于Create
的上下文中,则会假定您递归调用Branch.Create
,而不是Resources.Create
。
您需要确保明确选择要呼叫的Create
电话,例如
Public Shared Function Create(branch As Branch) As Branch
Return Resources.Create(branch, Path)
End Function