我想为库存管理创建一个向导UI.xaml中的相关行是:
<ContentPresenter Content="{Binding Current}" ContentTemplateSelector="{StaticResource inventorySelector}"/>
Run Code Online (Sandbox Code Playgroud)
"当前"是当前活动的视图模型,其中包括AvailableInventoriesViewModel,GroupsViewModel,NewArticlesViewModel,ResultViewModel.我已经定义了DataTemplateSelector:
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using Centron.WPF.WarehousingExtension.InventoryModule.ViewModels.WizardViewModels;
namespace Centron.WPF.WarehousingExtension.InventoryModule.UI.DataTemplateSelectors
{
public class InventoryDatatemplateSelector : DataTemplateSelector
{
public DataTemplate AvailableDatatype { get; set; }
public DataTemplate GroupsDatatype { get; set; }
public DataTemplate NewDatatype { get; set; }
public DataTemplate ResultDatatype { get; set; }
public InventoryDatatemplateSelector()
{
Debug.WriteLine("");
}
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is AvailableInventoriesViewModel)
return AvailableDatatype;
else if (item is GroupsViewModel)
return GroupsDatatype;
else if …Run Code Online (Sandbox Code Playgroud) 我想用NEST实现全文搜索和标记化搜索,所以我想得到像这样的多字段:
"tweet": {
"properties": {
"message": {
"type": "string",
"store": true,
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
目前,我与NEST的映射是
[ElasticType(Name = "tweet")]
internal class Tweet
{
[ElasticProperty(Name = "message")]
public string Message { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我搜索了NEST和ElasticSearch.net上的文档但没有任何结果.
是否有任何选项可以自动在字段中获取原始字段,还是应该定义嵌套类并指定自己的原始字段(我更喜欢更简洁的方式)?
我正在尝试从material2为闪亮的新datepicker实现我自己的日期格式.根据文档,我必须提供我的MD_DATE_FORMATS版本:
providers: [
{provide: DateAdapter, useValue: NativeDateAdapter },
{provide: MD_DATE_FORMATS, useValue: MY_DATE_FORMATS },
],
Run Code Online (Sandbox Code Playgroud)
当我使用默认实现时:
export const MD_NATIVE_DATE_FORMATS: MdDateFormats = {
parse: {
dateInput: null,
},
display: {
dateInput: {year: 'numeric', month: 'numeric', day: 'numeric'},
monthYearLabel: {year: 'numeric', month: 'short'},
dateA11yLabel: {year: 'numeric', month: 'long', day: 'numeric'},
monthYearA11yLabel: {year: 'numeric', month: 'long'},
}
};
Run Code Online (Sandbox Code Playgroud)
我收到日期输入为空的错误.但它到底是什么类型的?文档说任何.
如果我尝试放一些虚拟函数,我会得到错误: _dateAdapter.parse is not a function.
function dateInput() {
return 'ddd';
}
const MY_DATE_FORMATS: MdDateFormats = Object.assign({}, MD_NATIVE_DATE_FORMATS, {parse: dateInput });
Run Code Online (Sandbox Code Playgroud)
如何使它工作?
我在Docker(在Kubernetes中)运行.NET Core应用程序,将环境变量传递给Docker容器并在我的应用程序中使用它们.
在我的.NET Core应用程序中,我有以下C#类:
public class EnvironmentConfiguration
{
public string EXAMPLE_SETTING { get; set; }
public string MY_SETTING_2 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我设置了appsettings这样的:
config.
AddJsonFile("appsettings.json").
AddJsonFile($"appsettings.docker.json", true).
AddEnvironmentVariables();
Run Code Online (Sandbox Code Playgroud)
DI设置:
services.Configure<EnvironmentConfiguration>(Configuration);
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我使用它:
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/my")]
public class MyController : Controller
{
private readonly IOptions<EnvironmentConfiguration> _environmentConfiguration;
public MyController(IOptions<EnvironmentConfiguration> environmentConfiguration)
{
_environmentConfiguration = environmentConfiguration;
}
}
Run Code Online (Sandbox Code Playgroud)
我跑码头:
docker run -p 4000:5000 --env-file=myvariables
Run Code Online (Sandbox Code Playgroud)
该文件myvariables如下所示:
EXAMPLE_SETTING=example!!!
MY_SETTING_2=my-setting-2!!!!
Run Code Online (Sandbox Code Playgroud)
这有效.我可以使用我的_environmentConfiguration并看到我的变量已设置.
但是...我想将环境变量与appsettings合并,以便在找不到环境变量时将appsettings的值用作回退.以某种方式合并这两行:
services.Configure<EnvironmentConfiguration>(settings => Configuration.GetSection("EnvironmentConfiguration").Bind(settings));
services.Configure<EnvironmentConfiguration>(Configuration);
Run Code Online (Sandbox Code Playgroud)
这有点可能吗?
我的后备计划是继承EnvironmentConfiguration该类并使用单独的DI来注入两个单独的配置,然后在代码中"手动"合并它们,但这种解决方案是不可取的.
我正在使用Elastic 5.5轻松过滤文档
使用“无痛”,查找带有strings字段的文档。
仅strings返回带字段的文档
所有文件均已退回。
只要有带strings字段的文档,所有文档都会返回。这可能是某种缓存问题。
PUT /test_idx
POST /test_idx/t/1
{
"strings": ["hello", "world"]
}
POST /test_idx/t/2
{
"numbers": [1, 2, 3]
}
Run Code Online (Sandbox Code Playgroud)
GET /test_idx/_search
{
"query": {
"bool": {
"filter": [
{
"script": {
"script": {
"lang": "painless",
"inline": "return doc.containsKey(params.keypath)",
"params": {"keypath": "strings"}
}
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": …Run Code Online (Sandbox Code Playgroud) 我在我的应用程序中为Application Insights编写了一个自定义记录器.在Azure门户中查看App Insights时,我没有看到任何异常或任何事件.这是logger类代码,当我调试代码时,我确实看到了一个分配给InstrumentationKey属性的键,任何想法我在这里做错了什么?我是否需要将其他信息附加到客户端或配置?
public class AppInsightsLogger:ILogger
{
private TelemetryClient ai;
public AppInsightsLogger()
{
ai = new TelemetryClient();
if (string.IsNullOrEmpty(ai.InstrumentationKey))
{
// attempt to load instrumentation key from app settings
var appSettingsTiKey = AppSettings.InsightsKey;
if (!string.IsNullOrEmpty(appSettingsTiKey))
{
TelemetryConfiguration.Active.InstrumentationKey = appSettingsTiKey;
ai.InstrumentationKey = appSettingsTiKey;
}
else
{
throw new Exception("Could not find instrumentation key for Application Insights");
}
}
}
public void LogException(Exception ex)
{
ai.TrackException(ex);
}
}
Run Code Online (Sandbox Code Playgroud) 我的问题可能很简单,但就是找不到在诸如 (click) 之类的事件中使用管道的方法。像这样的东西:
<button (click)="quizAnswers(answer?.texte | translate | async)"></button>
Run Code Online (Sandbox Code Playgroud)
我总是得到一个错误。我试图用()or{}或[]...包装它......有一些解决方法,比如将内容放在一个属性中,然后在事件中使用它,this.attribute但我确定有一种正确的方法!
在此先感谢您的帮助
一开始我的印象combineLast是很合适,但是当我阅读文档时,它似乎不是:“请注意,combineLatest在每个可观察对象发出至少一个值之前,它不会发出初始值。”......当然我正好碰到那个异常。我试着forkJoin和merge不同的组合,但我不能得到它的权利。
用例非常简单,该方法someObs返回一个0或更多的可观察对象,我在其上循环。基于SomeObs对象上的一个值,我将一个新构造的 observable 推入OtherObs[]一个Arrayof Observable<OtherObs[]>。这个数组“需要”被合并成一个单一的 observable,在返回它之前我想做一些转换。
具体来说,我很难用combineLast合适的东西替换操作员……
public obs(start: string, end: string): Observable<Array<OtherObs>> {
return this.someObs().pipe(
mergeMap((someObs: SomeObs[]) => {
let othObs: Array<Observable<OtherObs[]>> = [];
someObs.forEach((sobs: SomeObs) => {
othObs.push(this.yetAnotherObs(sobs));
});
return combineLatest<Event[]>(othObs).pipe(
map(arr => arr.reduce((acc, cur) => acc.concat(cur)))
);
})
);
}
private yetAnotherObs(): Observable<OtherObs[]> {
/// ...
}
private somObs(): Observable<SomeObs[]> {
/// ...
}
Run Code Online (Sandbox Code Playgroud) 使用新版本的RxJS 6,尤其是管道运算符。当前,使用管道来获取API调用的结果,并将其传递给一系列其他任务。
一切正常,但在遇到问题时似乎无法找到取消或终止管道的方法。例如,我正在使用tap运算符检查该值是否为null。然后,我抛出一个错误,但是管道仍然似乎移至下一个任务,在本例中为concatmap。
因此,如何过早结束或取消管道?提前致谢。
getData(id: String): Observable<any[]> {
return this.http.get<any>(`${this.baseUrl}/path/${id}`).pipe(
tap(evt => {
if (evt == null) {
return throwError(new Error("No data found..."));
}
}),
concatMap(
evt =>
<Observable<any[]>>(
this.http.get<any[]>(
`${this.baseUrl}/path/relatedby/${evt.child_id}`
).map(res =>( {"response1":evt, "response2":res}) )
)
),
retry(3),
catchError(this.handleError("getData", []))
);}
Run Code Online (Sandbox Code Playgroud) 在本地编译(针对.NET Framework 4.6.1)的项目在TeamCity上失败,并显示以下消息:
[CoreCompile] Csc [Csc]使用目录中编译器的共享编译:C:\ Program Files(x86)\ MSBuild\14.0\bin
[19:02:15] [Csc] Services\MyFile.cs(20,55):错误CS1525:无效的表达式术语'int'
[19:02:15] [Csc] Services\MyFile.cs(20,59):错误CS1003:语法错误,','预计
在红色写作的失败编译中我也得到了很多这些:
[步骤5/9]在"C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v14.0\Web\Microsoft.Web.Publishing.targets(845,131)"的BeforeTargets属性中列出的目标"MvcBuildViews"在项目中不存在,将被忽略.