Fetch the repository succeeded.
This action will force synchronization from lucky7/Stardust, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
#Stardust
Stardust是一个.net微服务架构的一个简单实现。
http://www.cnblogs.com/loogn/p/6664594.html
##Service:
public class User
{
public string Name { get; set; }
}
//[StardustName("User")] //默认是类名,如果类名以Service结尾,会把Service去掉
public class UserService : IStardustService
{
//[StardustName("hello")] //默认是方法名,可以StardustNameAttribute来自定义
public string Hello(string name, int count = 1)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < count; i++)
{
sb.AppendFormat("Hello,{0}!{1}", name, Environment.NewLine);
}
return sb.ToString();
}
public Task<string> HelloAsync()
{
return new Task<string>(() =>
{
return "Hello World";
});
}
public List<User> UpdateUsers(List<User> list)
{
foreach (var user in list)
{
user.Name = "Updated:" + user.Name;
}
return list;
}
}
##Client:
var client = new StardustClient("server1", "1.1");
var str = client.Invoke<string>("user", "hello", new { name = "Jack", count = 2 });
//var task=client.InvokeAsync<string>("user", "hello", new { name = "Jack", count = 2 }); // 或者异步调用
Sign in for post a comment
Comments ( 0 )