我正在使用此代码,但我收到编译器警告,不推荐使用此创建方法.由于我想删除警告,并转移到较新版本,我想更正代码,但我无法使CommandLineParser 1.9.7库工作.
CommandLine.Parser OptionParser = new CommandLine.Parser(new CommandLine.ParserSettings
{
CaseSensitive = UseCaseSensitive,
IgnoreUnknownArguments = IgnoreUnknownOptions,
MutuallyExclusive = EnableMutuallyExclusive
}
);
bool Result = OptionParser.ParseArguments(Args, this);
Run Code Online (Sandbox Code Playgroud)
根据命令行的参数和传递的选项,此代码有效,结果为True/False.但是,会发布以下警告.
Warning 1 'CommandLine.Parser.Parser(CommandLine.ParserSettings)' is obsolete: 'Use constructor that accepts Action<ParserSettings>.'
Run Code Online (Sandbox Code Playgroud)
联机帮助将此作为使用该功能的示例.
new CommandLine.Parser(configuration: () => new CommandLine.ParserSettings(Console.Error))
Run Code Online (Sandbox Code Playgroud)
我尝试更改代码,但我没有让Lambda正确,我不知道如何让它工作.代码执行时,我只获取默认函数,我似乎无法更改Case Sensitive,Mutually Exclusive等...选项.
使用构造函数的行(来自内联IDE帮助)
bool Result = new CommandLine.Parser(configuration: (Settings) => new CommandLine.ParserSettings(UseCaseSensitive, EnableMutuallyExclusive, IgnoreUnknownOptions, null)).ParseArguments(Args, this);
Run Code Online (Sandbox Code Playgroud)
使用虚拟设置再次尝试:
bool Result = new CommandLine.Parser(configuration: (Settings) => new CommandLine.ParserSettings
{
CaseSensitive = UseCaseSensitive,
IgnoreUnknownArguments = IgnoreUnknownOptions,
MutuallyExclusive = EnableMutuallyExclusive …Run Code Online (Sandbox Code Playgroud) 我一直在关注Dan Wahlin和在线示例的教程,以配置Gulp和Typescript.我有代码运行,但我无法让tslint()工作.tslint()调用总是抛出异常:
node_modules\tslint\lib\language\walker\ruleWalker.js:18
this.limit = this.sourceFile.getFullWidth();
^
TypeError: Cannot read property 'getFullWidth' of undefined
at EnableDisableRulesWalker.RuleWalker [as constructor] (C:\Users\sscott\Development\OntarioDarts.com\node_modules\tslint\lib\language\walker\ruleWalker.js:18:37)
at EnableDisableRulesWalker.SkippableTokenAwareRuleWalker [as constructor] (C:\Users\sscott\Development\OntarioDarts.com\node_modules\tslint\lib\language\walker\skippableTokenAwareRuleWalker.js:11:16)
at new EnableDisableRulesWalker (C:\Users\sscott\Development\OntarioDarts.com\node_modules\tslint\lib\enableDisableRules.js:13:16)
at Linter.lint (C:\Users\sscott\Development\OntarioDarts.com\node_modules\tslint\lib\tslint.js:16:27)
at C:\Users\sscott\Development\OntarioDarts.com\node_modules\gulp-tslint\index.js:96:34
at respond (C:\Users\sscott\Development\OntarioDarts.com\node_modules\rcloader\index.js:73:7)
at respond (C:\Users\sscott\Development\OntarioDarts.com\node_modules\rcfinder\index.js:140:7)
at next (C:\Users\sscott\Development\OntarioDarts.com\node_modules\rcfinder\index.js:164:16)
at nextTickCallbackWith0Args (node.js:433:9)
at process._tickCallback (node.js:362:13)
Run Code Online (Sandbox Code Playgroud)
我使用的是Windows 10.我有typescript,tslint,gulp-typescript和gulp-tslint.
已安装的版本:
??? gulp-typescript@2.10.0
? ??? typescript@1.7.3
??? gulp-uglify@1.5.1
? ??? uglify-js@2.6.0
? ??? yargs@3.10.0
? ??? cliui@2.1.0
? ??? wordwrap@0.0.2
??? tslint@3.2.1
? ??? optimist@0.6.1
? ??? wordwrap@0.0.3
??? typescript@1.7.5 …Run Code Online (Sandbox Code Playgroud) 我有一个复杂的数据结构,需要转换为JSON。问题是我的字段名称和值在数组中。
例如,我有以下内容(从我的代码库简化):
let SampleData = [
{ Field: 'Key', Value: '7'},
{ Field: 'City', Value: 'Some City'},
{ Field: 'Description', Value: 'Some Description'}
];
Run Code Online (Sandbox Code Playgroud)
基本上,我的数据是一个数组,其中第一个元素是数据库列名称,第二个元素是列中的数据。我正在尝试获取一个JSON对象,该对象是:
{ Key: 7, City: 'Some City', Description: 'Some Description' }
Run Code Online (Sandbox Code Playgroud)
我真正的代码具有字段和数据是对象内的结构,所以不能简单地使用的Object.create()或Object.assign()据我可以得到工作。
我尝试遍历以构建一个简单的字符串,然后使用JSON.parse对其进行分解,但是对于我认为会更简单的操作而言,这似乎有很多开销。
我认为这个问题在我的示例中很简单,因为当我引用名称时一切正常,但是当我尝试使用自定义短名称时却没有。
当我引用内部字段PercentComplete时,我有一个百分比完整的组件可以移动该栏,但是当我在装饰器中使用自定义名称时,我无法使其正常工作。
我的组件:
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'progress-bar',
templateUrl: 'progress-bar.html'
})
export class ProgressBarComponent {
@Input() // @Input('Percent') does not work
PercentComplete: number = 0;
@Output()
PercentChange: EventEmitter<number> = new EventEmitter<number>();
constructor() { }
Increment() {
this.PercentComplete ++;
this.PercentChange.emit(this.PercentComplete);
}
}
Run Code Online (Sandbox Code Playgroud)
简单的HTML标头
<ion-header>
<ion-toolbar color="light" mode="md">
<progress-bar [PercentComplete]="15"></progress-bar>
</ion-toolbar>
</ion-header>
Run Code Online (Sandbox Code Playgroud)
组件HTML:
<div class="progress-outer">
<div class="progress-inner" [style.width]="PercentComplete + '%'">
{{PercentComplete}}%
</div>
</div>
<div>
<button ion-button round (click)="Increment()">
<ion-icon name="add-circle"> </ion-icon>
</button>
</div>
Run Code Online (Sandbox Code Playgroud)
如果我将所有HTML引用从PercentComplete更改为Percent,则它将无法正常工作。
假设我有一个具有内部私有属性的类:
export class foo {
private bar_:string;
private baz_:number;
constructor() { }
Run Code Online (Sandbox Code Playgroud)
我知道我可以通过为变量编写一个getter来获取bar和baz的值.
get bar():string {
return this.bar_;
}
get baz():number {
return this.baz_;
}
Run Code Online (Sandbox Code Playgroud)
然后,这允许我使用以下方式访问数据:
let A:foo = new foo();
console.log(foo.baz);
Run Code Online (Sandbox Code Playgroud)
有没有办法让一个简单的通用getter,所以当使用更结构化的类时,我可以访问任何字段而无需编写单独的get.
console.log(A.field2);
Run Code Online (Sandbox Code Playgroud)
field2不是定义的getter,但我希望能够在类中执行以下操作:
export class foo {
private bar_:string;
private baz_:number;
private field2_:string;
constructor() { }
get X():any { // X here is some placeholder that could be used, which contains the field name being asked (bar_, baz_, etc.)
return this.X; // This would assume that a field …Run Code Online (Sandbox Code Playgroud) 我在 Jenkins 2.5 中配置了一个多配置作业,它在我们产品的不同配置版本和不同的操作系统映像上执行测试套件。
该作业配置为在不同的操作系统节点(Windows 7、Windows 8.1、Windows 10、POS Ready 7 等)上运行。在这些操作系统中的每一个上,我们然后使用不同的配置运行测试,这些配置必须一次运行 1 个。
目前,多配置项目将在不同的计算机上按顺序运行每个测试场景。作业配置为Execute concurrent builds if necessary启用了标志,但作业不会并行运行。
使用节点设置Node Configuration http://i.stack.imgu用于不同的操作系统映像,然后使用不同配置的设置,将在同一操作系统上运行多个执行,尽管作业按顺序运行。
我希望在每个节点上同时运行一个配置,以便每个操作系统映像运行一个配置。使用 4 个操作系统和 3 个配置,有 12 个作业要运行。每个 1 小时,这是 12 小时,如果作业并行运行(每个操作系统上一个),那么 3 种不同的配置将运行,并且总共应该在大约 3 小时内完成。
理想情况下,执行将是:(Windows 7 / Config1) & (Windows 8.1 / Config1) & (Windows 10 / Config1) 全部同时运行,然后每个操作系统使用 Config2,然后每个操作系统使用 Config3。正如我所指出的,即使配置在任何操作系统上混合(config1 或 config2 或 config3),只要每个操作系统同时运行一个测试,并且每个操作系统一次只运行 1 个配置测试。