我说的是一个 Web 应用程序,它将独立的客户端应用程序(单页应用程序)和服务器端 RESTful API 之间的资源分开。
我正在考虑多片式,但这似乎并没有在这种情况下使用。
我试图重载一个使用 Guid 作为其参数的方法,另一个方法以字符串作为其参数。
// read a student object from the dictionary
static public User Retrieve(Guid ID)
{
User user;
// find the Guid in the Dictionary
user = Users[ID];
return user;
}
static public User Retrieve(string Email)
{
User user;
Guid id;
// find the Guid in the Dictionary
using (SHA1 sha1 = SHA1.Create())
{
byte[] hash = SHA1.ComputeHash(Encoding.Default.GetBytes(Email));
id = new Guid(hash);
}
user = Users[id];
return user;
}
Run Code Online (Sandbox Code Playgroud)
测试结果 结果消息:测试方法 SRS.CRUDUsers.UpdateStudent 抛出异常:System.ArgumentException:GUID 的字节数组长度必须正好为 16 个字节。
测试方法:
public void …Run Code Online (Sandbox Code Playgroud)