小编Pao*_*oni的帖子

post-build powershell脚本

我有以下post-build事件:

powershell Set-ExecutionPolicy Unrestricted
powershell -file "$(SolutionDir)Obfuscation\_obfuscate.ps1" "$(SolutionDir)" "$(ProjectDir)"
powershell Set-ExecutionPolicy Restricted
Run Code Online (Sandbox Code Playgroud)

和PS脚本开头:

param
(   
    [string]$slnDir,
    [string]$projectDir
)
Run Code Online (Sandbox Code Playgroud)

当MSBuild试图运行它时,我的第一个参数"$(SolutionDir)"被分成两个参数,因为解决方案路径包含一个空格字符:D:\Projects\Dion2 Mercurial\repo\Dion2Web\.所以我的脚本D:\Projects\Dion2作为第一个参数和Mercurial\repo\Dion2Web\第二个参数接收.

将这些参数发送到脚本文件的正确方法是什么?

注意:当脚本只有一个参数时,这样的构建后脚本可以正常工作.

c# powershell building post-build-event visual-studio

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

在运行时编辑JavaFX CSS

我正在为JavaFX 8应用程序创建CSS样式表。

我将重复这些步骤几次:

  1. 编辑CSS
  2. 运行应用程序并查看更改
  3. 停止申请

我发现这种方法非常耗时,并且正在寻找更智能的方法。

是否可以在运行时编辑JavaFX应用程序的CSS并实时查看结果?

我正在寻找类似Google Chrome检查工具的工具

使用Oracle Scene Builder可以部分实现此目的。实际上,我可以加载CSS文件并运行预览。对CSS文件的任何更改都可以在预览中正确显示,而无需重新启动。

不幸的是,这只是一个预览:许多组件为空/未初始化。当然,这无疑是非常有用的,但是许多改进都需要运行实际的应用程序。

java javafx

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

为什么IntegerProperty实现Property <Number>而不是Property <Integer>?

PropertyJavaFX添加的接口有一个类型参数T,它是属性包装的值的类型.

其中的实现Property接口,还有一些用于数字:IntegerProperty,FloatProperty,等所有这些类实现Property<Number>.

我们IntegerProperty举个例子.它实施的原因是什么,Property<Number>而不是Property<Integer>我所期望的?


这是一个UML图,阐明了以下层次结构IntegerProperty:

在此输入图像描述

java generics javafx

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

Java通用"捕获#n-of"编译错误

我有以下定义:

public interface MessageResponseHandler<T extends MessageBody> {
    public void responsed(Message<T> msg);
}

public class DeviceClientHelper {
    public MessageResponseHandler<? extends MessageBody> messageHandler;

    setHandler(MessageResponseHandler<? extends MessageBody> h){
        this.messageHandler = h;
    }

    public someMethod(Object message){
        Message<? extends MessageBody> msg = (Message<? extends MessageBody>) message;
        if (this.messageHandler != null) {
            this.messageHandler.responsed(msg);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚为什么在someMethod()方法中调用

this.messageHandler.responsed(msg);
Run Code Online (Sandbox Code Playgroud)

会在eclipse中给我一个有线编译器错误.就像是:

the method responsed(Message<capture#3-of ? extends MessageBody>) in
the type MessageResponseHandler<capture#3-of ? extends MessageBody> is
not applicable for the arguments (Message<capture#4-of ? extends
MessageBody>)
Run Code Online (Sandbox Code Playgroud)

什么是"catpure"在错误信息中意味着什么?

java eclipse generics

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

验证提供给构造函数的值的最佳实践?

上下文:我正在为学校写一个信号量类,其中一个要求是它可能没有用负值初始化.

现在我的构造函数抛出异常:

/**
 * Constructor
 */
public Semaphore(int value) throws Exception
{   
    if (value < 0)
        throw new Exception("Negative value provided for initial constructor.");
    this.value = value;
}
Run Code Online (Sandbox Code Playgroud)

处理异常以实例化信号量对我来说似乎过于沉重,所以我正在考虑将任何负值静默设置为零,即:

/**
 * Constructor
 */
public Semaphore(int value) 
{   
    if (value < 0)
        this.value = 0;
    else
        this.value = value;
}
Run Code Online (Sandbox Code Playgroud)

java

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