小编Ame*_*sed的帖子

VS2017和NUnit 3.9没有可用的测试

我使用的是最新的VS2017版本15.6.4,NUnit3TestAdapter 3.10.0和Nunit版本3.9.0.0.

当我尝试在测试资源管理器中运行单元测试时,测试显示为灰色,当我右键单击并运行选定的测试时,我看到以下错误:没有测试可用 这里是我的测试类看起来如何

    [TestFixture]
    public partial class ListViewBOTest
    {
    [Test]
     public void TestSearch_DateTime()
      {
        Assert.AreEqual(1,0);
      }

    }
Run Code Online (Sandbox Code Playgroud)

这是我测试的屏幕截图

输出中的文字:

[3/26/2018 10:53:55 AM Informational] ------ Run test started ------
[3/26/2018 10:53:55 AM Informational] NUnit Adapter 3.10.0.21: Test execution started
[3/26/2018 10:53:55 AM Informational] Running all tests in C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll
[3/26/2018 10:53:56 AM Informational] NUnit failed to load C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll
[3/26/2018 10:53:56 AM Informational] NUnit Adapter 3.10.0.21: Test execution complete
[3/26/2018 10:53:56 AM Warning] No test is available in C:\Projects\MVPPlant\DEV\CMMSdg.Plant\CMMSdg.Plant\Sln.2010\CMMSdg.Plant.BusinessObjects.Test\bin\Debug\CMMSdg.Plant.BusinessObjects.Test.dll. Make sure that …
Run Code Online (Sandbox Code Playgroud)

c# nunit visual-studio visual-studio-2017

19
推荐指数
2
解决办法
1万
查看次数

Newtonsoft.Json自定义序列化日期

Newtonsoft.Json用来序列化我的日期从C#到javscript我想要做的是让json序列化程序使用当前文化将日期格式化为字符串

这是我的Json序列化器得到的:

JsonConvert.SerializeObject(DateTime.Now);
Run Code Online (Sandbox Code Playgroud)

结果是:

"2016-07-08T17:10:17.6722753-05:00"
Run Code Online (Sandbox Code Playgroud)

但我更喜欢的是:

"08/07/2016 17:10:57"
Run Code Online (Sandbox Code Playgroud)

因为我目前的文化是巴西,我希望我的日期以上述方式显示.

是否有可能在全局范围内(对于任何可能序列化的日期)告诉Newtonsoft.Json中的json序列化程序使用它就好像它正在执行date.ToString()(因为ToString尊重文化System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat并相应地给出正确的格式)

c# serialization json json.net

13
推荐指数
1
解决办法
2万
查看次数

无声的本地通知IOS

我们可以在IOS应用程序中获得静默本地通知吗?在后台进行一些数据处理而不与用户进行交互.

我想要做的是创建一个静默的本地通知,每天早上8点开始触发,用户收到它之后我想做一些数据处理并重新创建一个新用户,用户可以看到我查看后处理的新数据第一个静默的本地通知.

我尽量避免使用推送通知.

xamarin.ios ios xamarin

11
推荐指数
1
解决办法
3507
查看次数

CheckBoxList ListItem在动态添加数据后始终为0

我在代码中有以下aspx代码.我想在ListItem复选框中添加复选框, ColumnsList并在按钮单击时找到所有选中的复选框.

但是当我尝试获取所选项目按钮时,单击ColumnsList计数变为0.

<asp:checkboxlist runat="server" EnableViewState="true" id="ColumnsList"/>
Run Code Online (Sandbox Code Playgroud)

在后面的代码中,我将数据添加到我的ColumnsList,如下所示

public override void OnLoad()
{
    if(!this.IsPostBack)
    {
       this.ColumnsList.Items.Add(new ListItem { Text= "Text1",  Value = "value1"    });
       this.ColumnsList.Items.Add(new ListItem { Text= "Text2",  Value = "value2"  });
    }
}
Run Code Online (Sandbox Code Playgroud)

//这是按钮单击侦听器

private void Button_Click(object sender, EventArgs eventArgs)
{
    // Count is 0 instead of 2
    var count = this.ColumnsList.Items.Count;
    foreach(ListItem item in this.ColumnsList.Items)
    {
        var selected = item.Selected;
        // add selected to a list..etc

    }
}           
Run Code Online (Sandbox Code Playgroud)

注意:该应用程序已在部署点2010中部署.

c# asp.net sharepoint sharepoint-2010 comboboxlist

9
推荐指数
2
解决办法
627
查看次数

解析Java中的缩进文本树

我有一个缩进文件,需要使用java进行解析,我需要一些方法将其放在Section类中,如下所示

    root
     root1
       text1
         text1.1
         text1.2
       text2
         text2.1
         text2.2

     root2
       text1
         text1.1
         text1.2
       text2
         text2.1
         text2.2.2
Run Code Online (Sandbox Code Playgroud)

我有上课的地方像缩进的东西

public class Section 
{

    private List<Section> children;
    private String text;
    private int depth;
    public Section(String t)
    {
       text =t;
    }

    public List<Section> getChildren()
    {
        if (children == null)
      {
            children = new ArrayList<Section>();
       }
        return children;
}

public void setChildren(List<Section> newChildren)
{
    if (newChildren == null) {
        children = newChildren;
    } else {
        if (children == null) {
            children = new ArrayList<Section>();
        } …
Run Code Online (Sandbox Code Playgroud)

java algorithm

5
推荐指数
1
解决办法
2448
查看次数

Xamarin.Forms.DatePicker文本颜色

对于Xamarin.Forms.DatePicker日期字段是"tapable"并不明显我想将其文本颜色更改为蓝色,以便用户认为它是可点击的?

我看到背景颜色属性但不是forecolor/text颜色?

让我知道我该怎么做.

xamarin.ios xamarin xamarin.forms

3
推荐指数
1
解决办法
4569
查看次数

不引人注目的JQuery验证在弹出的PartialViews中不起作用

我在asp.net 5 mvc 6 project中有以下局部视图。部分视图显示为jquery ui对话框,当用户单击父视图页面中的按钮时将动态加载该部分视图。问题在于,输入无效的整数并单击提交后,Unobtrusive JQuery Validation无效。

我已经完成了使不引人入胜的JQuery验证工作所需的所有过程,并且可以在非局部视图中工作。

这是我的代码

我的局部视图名称EquipmentEditTemplatecshtml

    @model MyProject.Models.EquipmentViewModel  
Run Code Online (Sandbox Code Playgroud)

@*<form role="form" name="FormPost" asp-controller="Asset" method="post" asp-action="SaveEq" data-ajax="true" id="FrmGrid_grdLocation1" class="FormGrid form-horizontal" style="width:477px;height:703px;">*@
    @*<form asp-controller="Asset" asp-action="SaveEq" method="post" style="width:600px;height:703px;" class="form-horizontal" >*@
    <div class="FormError bg-danger" style="display:none;"></div><div class="tinfo topinfo"></div><div class="modal-body">
        <div style="margin-left:15px;">

            <div class="form-group">
                <label asp-for="EquipmentID" class="col-sm-2 control-label">Equipment ID:</label>
                <div class="col-sm-10">
                    <input asp-for="EquipmentID" class="FormElement form-control" />
                    <span asp-validation-for="EquipmentID" class="text-danger"></span>
                </div>

            </div>

        <div class="form-group">
            <label asp-for="Email" class="col-sm-2 control-label">Email:</label>
            <div class="col-sm-10">
                <input asp-for="Email" class="FormElement form-control" />
            </div>
        </div>

        <div …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc unobtrusive-validation asp.net-core-mvc

3
推荐指数
1
解决办法
2244
查看次数

找不到名为“ XX”的视图组件

我正在使用aspnet 5和MVC 6。

我已经按照此处的说明创建了一个视图组件,但是在运行网站时出现错误

找不到名为“ XX”的视图组件。在

@Component.Invoke("XX"))
Run Code Online (Sandbox Code Playgroud)

这是我项目的结构

namespace Test
{
public class XXViewComponent : ViewComponent
{
   public IViewComponentResult Invoke()
    {       
        return View();
    }
}
Run Code Online (Sandbox Code Playgroud)

}

然后在views文件夹中,我有Views / Assets / index.cshtml

<div>
    <div class="col-md-4">
        @Component.Invoke("XX"))
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

vc在

Views/Assets/Components/XX/default.cshtml
<div class="col-md-6" id="listOfCustomers">
    <table class="table table-condensed">
      <span> Test partial View</span>
    </table>
</div>
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-core-mvc

2
推荐指数
2
解决办法
5368
查看次数

Bootstrap3日期时间选择器24小时选项不起作用

我正在从eonasdan.github中的链接使用bootstrap 3 datetime picker, 但是当我尝试为use24Hours设置选项时,我在第1477行看到控制台错误,其中关键是use24Hours?

 throw new TypeError('option ' + key + ' is not recognized!');
Run Code Online (Sandbox Code Playgroud)

我正在使用版本/ *!版本:bootstrap-datetimepicker.js为4.17.37

这就是我在javsacript中创建日期时间选择器的方式。

("#mydiv").datetimepicker({ use24Hours: false });
Run Code Online (Sandbox Code Playgroud)

我也尝试了use24Hours的小写如下

("#mydiv").datetimepicker({ use24hours: false });
Run Code Online (Sandbox Code Playgroud)

基于答案就是做到这一点的方法。我的错是什么?

就像一个注释:我不能使用format:HH:mm,因为我将整个datetime选择器更改为仅使用时间格式。但是我想要的是将日期格式保持为我选择的当前语言,例如...,fr ...等等,但是无论我的文化如何,都可以根据需要更改时间。

javascript twitter-bootstrap twitter-bootstrap-3

2
推荐指数
1
解决办法
1688
查看次数

Array.sort和Linq OrderBy给出不同的结果

我试图在C#和javascript中对数组进行排序.但我遇到的问题是排序结果都不匹配.它们的排序方式不同,例如输入数组是否有下划线.

在C#下面是一个示例代码,是一个dotnetfiddle链接.

using System;
using System.Linq;

public class Program
{
    public static void Main()
    {
        var array= new string[]{"Meter_2","Meter0Add","Meter0Replace","Meter_1","ZZZ"};

        var temp= array.OrderBy(x => x).ToArray();

        foreach(string x in temp)
        {
            Console.WriteLine(x);
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

结果:Meter_1,Meter_2,Meter0Add,Meter0Replace,ZZZ

在javascript下面是一个代码示例是一个js小提琴链接.

var array  = ["Meter_2","Meter0Add","Meter0Replace","Meter_1","ZZZ"];
array.sort();
document.writeln(array.join(", "));
Run Code Online (Sandbox Code Playgroud)

结果Meter0Add,Meter0Replace,Meter_1,Meter_2,ZZZ

问题是如何使javascript与C#相同?

javascript c# arrays sorting

2
推荐指数
1
解决办法
823
查看次数

System.Drawing.Graphics Drawimage 将IOS拍摄的图片旋转90度

我有以下代码可以上传图像并使用 System.Drawing.Graphics 以 150 x 200 div 的大小绘制它,但是当图像是从 IOS 设备获取时,图片会向右旋转 90 度。

仅供参考:我在 JavaScript 画布中绘制图像时遇到了同样的问题,这个解决方案对我有用。因此我在 C# 中寻找等效的解决方案

     private System.Drawing.Image ResizeAndDraw(System.Drawing.Image objTempImage)
            {
                Size objSize = new Size(150, 200);
                Bitmap objBmp;
                objBmp = new Bitmap(objSize.Width, objSize.Height);

                Graphics g = Graphics.FromImage(objBmp);
                g.SmoothingMode = SmoothingMode.HighQuality;
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                //Rectangle rect = new Rectangle(x, y, thumbSize.Width, thumbSize.Height);
                Rectangle rect = new Rectangle(0,0,150,200);
                //g.DrawImage(objTempImage, rect, 0, 0, objTempImage.Width, objTempImage.Height, GraphicsUnit.Pixel);
                g.DrawImage(objTempImage, rect);
                return objBmp;
            }
Run Code Online (Sandbox Code Playgroud)

c# system.drawing image bitmapimage ios

2
推荐指数
1
解决办法
1038
查看次数

ASP.NET RC2 IFormFile 文件扩展名和文件最大大小自定义验证

我想在 MVC-6 RC2 中使用自定义 jquery 不显眼的验证器

旧答案类似,我在This one 中看到了一些 RC2 示例,但我不知道如何为文件实现它。

这是我的查看模式

public class FileUploadViewModel
    {
        //TODO [FileType(Validtype="jpeg,png,jif", MaxSize=112222)]// this is what I want
        [Required(ErrorMessage = "Please select a file")]
        public IFormFile File { get; set; }

        [Required(ErrorMessage = "Please select link")]
        public string FileName { get; set; }

        public string ExternalLink { get; set; }

        public string Description { get; set; }    
    }
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc unobtrusive-validation asp.net-core-mvc .net-core-rc2

0
推荐指数
1
解决办法
6290
查看次数