我尝试在可观察数组中按名称搜索.这是我的代码:
<input class="form-control" data-bind="value: Query, valueUpdate: 'keyup'" autocomplete="off">
Run Code Online (Sandbox Code Playgroud)
我的代码在ViewModel中
viewModel.Query = ko.observable('');
viewModel.search = function(value) {
viewModel.TestList.removeAll();
for (var x in viewModel.TestList) {
if (viewModel.TestList[x].Name.toLowerCase().indexOf(value.toLowerCase()) >= 0) {
viewModel.TestList.push(viewModel.TestList[x]);
}
}
}
viewModel.Query.subscribe(viewModel.search);
Run Code Online (Sandbox Code Playgroud)
第一:我想按名称字符串搜索.二:有没有其他解决办法不从视图中删除所有元素?我的意思是当查询字符串为空时,应该再次列出所有列表.
现在我有错误信息:
TypeError: viewModel.TestList[x].Name is undefined
Run Code Online (Sandbox Code Playgroud) 可以在我的视图中直接更改用户控件的颜色吗?
<local:MyControl
// properties
/>
Run Code Online (Sandbox Code Playgroud)
我尝试过使用“Foreground”属性,但它不起作用。
嗨,我想在 ASP.NET Core 中模拟 IHttpConnectionFeature
在我的控制器中,我有:
var connectionId = HttpContext.Features.Get<IHttpConnectionFeature>().ConnectionId;
Run Code Online (Sandbox Code Playgroud)
但是我如何在我的单元测试中模拟它:
var controller = new MyController(logger.Object,
mockService.Object)
{
ControllerContext = new ControllerContext
{
HttpContext = new DefaultHttpContext()
}
};
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:
消息 = "未将对象引用设置为对象的实例。"
我正在使用EntityFrameworkCore 2.0.0-preview2-final,我想将ApplicationDbContext注入Startup类的Configure方法.
这是我的代码:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ApplicationDbContext context)
{
// rest of my code
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行我的应用程序时,我收到一条错误消息:
System.InvalidOperationException:无法从根提供程序解析作用域服务"ProjectName.Models.ApplicationDbContext".
这也是我在ConfigureServices方法中的代码:
services.AddDbContext<ApplicationDbContext>(options =>
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
}
else
{
options.UseSqlite("Data Source=travelingowe.db");
}
});
Run Code Online (Sandbox Code Playgroud)
你知道我怎么能解决这个问题?
c# entity-framework entity-framework-core .net-core asp.net-core
我有一个示例复选框:
<div class="form-check">
<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">
<label class="form-check-label" for="defaultCheck1">
Default checkbox
</label>
</div>
Run Code Online (Sandbox Code Playgroud)
我想在左侧有一个标签。你知道我该怎么做吗?我试过拉右,但它不起作用。
更新:我认为问题在于我在 HTML 标签中使用的 rtl 类。
我想知道OSK.exe进程(屏幕键盘)是否打开.
这是打开OSK的代码:
Process.Start("C:\\Windows\\System32\\osk.exe");
Run Code Online (Sandbox Code Playgroud)
您是否有任何想法如何检查它并阻止启动两次以上这个过程?
我想以我的格式加入多个字符串:
Like: string1:string2,string1:string2, and more...
Run Code Online (Sandbox Code Playgroud)
我有list1和string2值的列表.
string test = String.Join(",", mylist.Select(x => x.string1));
Run Code Online (Sandbox Code Playgroud)
如何以我的格式加入这些变量?
他我想用两个字符分割字符串.
例如,我有这样的字符串:
"xx-aa-[aa]-22-[bb]"
.我想要检索的字符串数组[aa]
和[bb]
.[]之间的所有字符.
首先,我可以拆分'-'
,所以我将有字符串数组
var tmp = myString.Split('-');
Run Code Online (Sandbox Code Playgroud)
但是现在我怎样才能只检索字符串[]
呢?
我想通过复选框传递我的布尔值。
这是我的财产
public bool MyBooleanValue{ get; set; } = true;
Run Code Online (Sandbox Code Playgroud)
这里是我的 HTML:
<input type="checkbox" id="@nameof(Model.MyBooleanValue)" name="my-boolean" value="1" class="" checked="checked" />
<label for="@nameof(Model.MyBooleanValue)">some text</label>
<input type="hidden" name="my-boolean" value="true" />
Run Code Online (Sandbox Code Playgroud)
默认情况下,我想检查字段。这段代码有什么问题?我使用 ASP.NET MVC 5。我总是得到相同的值
我正在尝试使用 VSTS 和 docker-compose 配置持续交付,我想将其推送到 Azure 容器注册表。这是我在 VSTS 上的构建定义:
我收到关于构建结果的错误消息:
No such command: docker_compose
Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the Compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
Run Code Online (Sandbox Code Playgroud)
你知道我该怎么处理吗?
更新:这是我的 docker-compose
version: '3'
services:
ci-build:
image: microsoft/aspnetcore-build:1.0-1.1
volumes:
- …
Run Code Online (Sandbox Code Playgroud) docker docker-compose azure-devops azure-pipelines-build-task azure-container-registry
c# ×5
.net ×3
asp.net-core ×2
checkbox ×2
string ×2
wpf ×2
.net-core ×1
arrays ×1
asp.net ×1
asp.net-mvc ×1
azure-devops ×1
bootstrap-4 ×1
css ×1
docker ×1
html ×1
httpcontext ×1
javascript ×1
knockout-2.0 ×1
knockout.js ×1
label ×1
linq ×1
razor ×1
regex ×1
split ×1
unit-testing ×1
xaml ×1