【发布时间】:2016-02-16 06:19:49
【问题描述】:
我的 c# 中有一个像这样的复杂类:
public class Channel
{
public int Id { get; set; }
public string ChannelName { get; set; }
public Dictionary<int, Question> Questions { get; set; }
public Dictionary<int, ChatMessage> ChatMessages { get; set; }
public Dictionary<int, User> Users { get; set; }
public bool IsAdmin { get; set; }
public int TimeLeft { get; set; }
}
要将它传递给我的客户,我会:
Clients.Caller.CheckVersion(ChannelInstance);
我的问题是,当我在客户端收到对象时,它仍然会有 CamelCasing,而不是 camelCasing。有没有办法做到这一点,所以 SignalR 会自动将我的对象转换为具有适当可变大小写的对象?
我知道这是一件很琐碎的事情,但我发现在我的 javascript 中定义这样的类很烦人:
function Channel() {
this.Id;
this.ChannelName;
this.etc;
}
当这看起来更正确的 JavaScript 时:
function Channel() {
this.id;
this.channelName;
this.etc;
}
有什么办法可以做到这一点,还是我只需要使用奇怪的 CamelCasing?
【问题讨论】:
标签: javascript c# signalr