【发布时间】:2011-03-26 17:55:10
【问题描述】:
我想知道是否有人可以确认我使用的命名约定是正确的,我刚刚开始并且真的不想养成一个坏习惯
这就是我所拥有的......(见 cmets)
基本上我有一个名为 GetTasks 的方法,但 uri 是 Tasks - 我想这是要走的路??
我还有一个名为 GetUser 的方法,其中 Uri 是(复数)Users/{id}
在我继续之前的任何确认都会很棒..谢谢..
这是我目前的方法..
[WebGet(UriTemplate = "Tasks")]
public List<SampleItem> GetTasks() //RETURNS a COLLECTION
{
// TODO: Replace the current implementation to return a collection of SampleItem instances
return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Hello" } };
}
[WebGet(UriTemplate = "Users/{id}")]
public SampleItem GetUser(string id) // RETURNS A USER
{
// TODO: Return the instance of SampleItem with the given id
//throw new NotImplementedException();
return new SampleItem() {Id = 1, StringValue = "Hello"};
}
[WebInvoke(UriTemplate = "Users/{id}", Method = "PUT")]
public SampleItem UpdateUser(string id, SampleItem instance) // UPDATES A USER
{
// TODO: Update the given instance of SampleItem in the collection
throw new NotImplementedException();
}
[WebInvoke(UriTemplate = "Users/{id}", Method = "DELETE")]
public void DeleteUser(string id) // DELETES A USER
{
// TODO: Remove the instance of SampleItem with the given id from the collection
throw new NotImplementedException();
}
【问题讨论】:
-
我有点困惑的一件事是“GetUser”,其中 Uri 是(复数)Users/{id} 还是应该是(单数)User/{id}
标签: wcf visual-studio-2010 rest wcf-rest