我的 MVC 应用程序中有以下中心,我想从其中向客户端代码发送一条简单的消息:
using SignalR.Hubs;  
    
public  class Progress : Hub
{
       public void Send(string message)
       {
            // Call the addMessage method on all clients
            Clients.addMessage(message);
       }
          
        public Progress()
        {
            Clients.addMessage("Starting to analyze image");
        }                 
}
Run Code Online (Sandbox Code Playgroud)
在我看来以下 javascript
<script src="/Scripts/jquery.signalR.js" type="text/javascript"></script>
<script src="/signalr/hubs" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        // Proxy created on the fly
        var connection = $.connection('/signalr/hubs/progress');
        // Declare a function on the chat hub so the server can invoke it
        connection.addMessage = function (message) {
            $('#messages').append('<li>' + message.Content …Run Code Online (Sandbox Code Playgroud) 我发现很多解决方案都是用逗号开头,然后是指向,我想要这样的东西: 133.000,00
到目前为止我尝试过的是: @item.Price.ToString("C3", System.Globalization.CultureInfo.CreateSpecificCulture("da-DK"))
和
@String.Format("{0:#.##0,######}", item.Price)
在第二种格式中,我只会 133000.00
我想对我的方法进行测试,我可以传递 2 个字符串变量,但我不知道如何传递Dictionary<,>.
它看起来像这样:
[Test]
[TestCase("agr1", "askdwskdls", Dictionary<TypeMeasurement,double>)]
public void SendDataToAgregator_GoodVariables_ReturnsOn(string agrID,string devID, Dictionary<TypeMeasurement, double> measurement)
{
}
Run Code Online (Sandbox Code Playgroud)
TypeMeasurement是enum,我知道这不是你传递字典的方式,但我不知道如何,所以我把它放在那里,这样你就知道我想做什么。