我上下搜索谷歌但我找不到关于该主题的任何适当信息.
我想做的是:
我怎么能用C#3.5做到这一点?
更新:
查看:
private void OnTextChanged(...)
{
if (SearchFormatEvent != null)
{
ICollection<object> collection = SearchFormatEvent("MySearchString");
// Do stuff on the returned collection
}
}
Run Code Online (Sandbox Code Playgroud)
SearchProvider:
// This is the delegate invoked for the async search taking the searchstring typed by the user
public delegate ICollection<object> SearchInputTextStrategy<T>(string param);
public class SearchProvider : ISearchProvider
{
private ITextView _view;
private SearchInputTextStrategy<object> searchInputDelegate;
public SearchProvider(ITextView view)
{
_view = view;
_view.SearchFormatEvent += new ConstructSearchFormatDelegate(CostructSearchFormat); …
Run Code Online (Sandbox Code Playgroud) 那些名称空间在某种程度上是彼此相关的,但我不明白其中的区别,当我需要那个或那个时?!
有人可以向我解释一下吗?
我正在使用asp.net web api 2和Entity Framework 6.
原始的伪代码
public IHttpActionResult GetProductLabel(int productId)
{
var productDetails = repository.GetProductDetails(productId);
var label = labelCalculator.Render(productDetails);
return Ok(label);
}
Run Code Online (Sandbox Code Playgroud)
修改代码
public async Task<IHttpActionResult> GetProductLabel(int productId)
{
var productDetails = await repository.GetProductDetailsAsync(productId); // 1 long second as this call goes into sub services
var label = labelCalculator.Render(productDetails); // 1.5 seconds synchrounous code
return Ok(label);
}
Run Code Online (Sandbox Code Playgroud)
在我改变之前,一切都是同步的.
在我改变之后,对再次调用数据库的远程服务的调用是以async-await方式完成的.
然后我对一个只提供同步方法的渲染库进行同步调用.计算需要1.5秒.
还有一个好处,我做远程database_service调用async-await方式,但第二个调用不?还有什么我还能改进的吗?
注意
我问这个的原因是因为:
"当进程等待I/O完成时,使用异步控制器,它的线程被释放,供服务器用于处理其他请求."
所以当第一个远程database_service调用正在处理并等待1秒时,该线程将返回给IIS ?? !!
但是第二个标签计算需要1.5秒才能再次阻止当前线程1.5秒?
所以我发布并阻止线程,这没有意义或你怎么想?
根据bs3到bs4的迁移文档:
纽扣
Renamed .btn-default to .btn-secondary.
Run Code Online (Sandbox Code Playgroud)
但是辅助设备并不是所有旧的默认按钮.
我的意思是白色阴影按钮/下拉菜单......
当我做的btn-light不是原来的btn-default.
那么我如何获取按钮/下拉菜单等的默认主题...?
AFAIR字面上现在...... bs4中有一个正确的默认按钮,但它是以前的alpha版本.我想这是真的.
我可以通过Ajax.ActionLink("获取客户","GetCustomers","客户")调用asp.net mvc控制器;
我可以使用Html.ActionLink和jquery ajax调用来做同样的事情.
区别在哪里?
我正在运行集成测试,当我到达那行代码时:
WebApiDependencyResolverConfig.Register(config);
Run Code Online (Sandbox Code Playgroud)
(在里面使用autofac容器)
我得到这个例外:
{"Could not load file or assembly 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"}
Run Code Online (Sandbox Code Playgroud)
Fusionlog:
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/TLP/TLP.API.IntegrationTests/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : Autofac.Integration.WebApi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da.
===
LOG: This bind starts in default load context.
LOG: Using application configuration …
Run Code Online (Sandbox Code Playgroud) 我正在进行web api集成测试.
我想将我的不记名令牌传递给Http请求的标头:
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "eJ43k5l435j34l5j43l5j34l5jl35j34l5j344l.4534535.534534sample...");
Run Code Online (Sandbox Code Playgroud)
当这行代码完成后,我查看httpClient.DefaultRequestHeaders.Authorization
属性,它是NULL?
为什么这个?
UPDATE
这是来自我的集成测试类的基类:
protected HttpClient Client { get { return server.HttpClient; } }
Run Code Online (Sandbox Code Playgroud)
当我手动在测试类中新建一个http客户端时:
var client = new HttpClient();
client.DefaultRequestHeaders.Add("key","value");
Run Code Online (Sandbox Code Playgroud)
它工作但不是我的客户!
更新2
好的我发现了这个:
var c = Client;
c.DefaultRequestHeaders.Add("bla", "bla");
Run Code Online (Sandbox Code Playgroud)
它工作,但为什么我必须在一个新变量中读取我的客户端?
ApplicationComponent
import { Component } from '@angular/core';
import {Router, ROUTER_DIRECTIVES, Routes, ROUTER_PROVIDERS} from '@angular/router';
import {SchoolyearsComponent} from "./schoolyear/schoolyears.component";
@Component({
directives: [ROUTER_DIRECTIVES],
providers: [
ROUTER_PROVIDERS
],
templateUrl: './app/application.component.html',
styleUrls: ['./app/application.component.css']
})
@Routes([
{
path: '/',
component: SchoolyearsComponent,
},
])
export class ApplicationComponent {}
Run Code Online (Sandbox Code Playgroud)
SchoolyearsComponent
import { Component } from '@angular/core';
import { Routes, ROUTER_DIRECTIVES } from '@angular/router';
import { SchoolyearsHomeComponent } from './schoolyears.home.component';
import { CreateSchoolyearComponent } from './create.schoolyear.component';
@Routes([
{
path: '',
component: SchoolyearsHomeComponent,
},
{
path: '/create',
component: CreateSchoolyearComponent …
Run Code Online (Sandbox Code Playgroud) 我有这个 Seeder 类,它在 Configure 方法的 Startup.cs 文件的末尾被调用:
public class UserSeeder
{
private readonly ApplicationDbContext _context;
private readonly UserManager<ApplicationUser> _userManager;
public UserSeeder(ApplicationDbContext context, UserManager<ApplicationUser> userManager)
{
_context = context;
_userManager = userManager;
}
public async Task Seed()
{
if (!await _context.Users.AnyAsync())
{
var user = new ApplicationUser()
{
UserName = "admin",
Email = "admin@test.com"
};
await _userManager.CreateAsync(user, "passwort4admin");
}
}
}
Run Code Online (Sandbox Code Playgroud)
代码被执行,我什至在方法调用周围放置了一个 try/catch 但没有发生错误并且没有用户插入到数据库中!
为什么不?
https://api.flutter.dev/flutter/material/Radio-class.html
我将作者单选按钮示例复制/粘贴到我的应用程序中,如下所示:
我的代码:
return Row(
children: <Widget>[
Expanded(child: ListTile(
title: const Text('Left radio button'),
leading: Radio(
value: SingingCharacter.lafayette,
groupValue: _character,
onChanged: (SingingCharacter value) {
setState(() {
_character = value;
});
},
),
),),
Expanded(child: ListTile(
title: Text('right radio button'),
leading: Radio(
value: SingingCharacter.jefferson,
groupValue: _character,
onChanged: (SingingCharacter value) {
setState(() {
_character = value;
});
},
),
),
)],
);
Run Code Online (Sandbox Code Playgroud)
如何删除图像上画为红线的空格/边距?我在代码中的任何地方都找不到这些边距...
该图像是使用 Dart Dev Tools 拍摄的,并且打开了“选择小部件模式”,您可以看到元素单选和标签周围的空间。
或者创建我自己的单选按钮组是否更好......?还有一个问题是无法通过点击标签来选择收音机...
c# ×3
asp.net-mvc ×2
asynchronous ×2
actionlink ×1
ajax ×1
angular ×1
asp.net ×1
asp.net-core ×1
async-await ×1
autofac ×1
bootstrap-4 ×1
delegates ×1
flutter ×1
jquery ×1
typescript ×1