我使用Scala的Java Reflection时遇到了问题.我的代码:
case class MyClass(id: String, value: Double)
def create(values: Map[String, Any]): MyClass = {
val constructor = classOf[MyClass].getConstructors.head
val arguments = classOf[MyClass].getDeclaredFields().map( f => values(f.getName) )
constructor.newInstance(arguments: _*).asInstanceOf[MyClass]
}
create(Map("id" -> "CE0D23A", "value" -> 828.32))
Run Code Online (Sandbox Code Playgroud)
我的问题是,我需要传递Map [String,Any],因为其中一个值是Double,但newInstance需要Object,而不是Any.
我尝试使用scalas宇宙:
case class MyClass(id: String, value: Double)
def create(values: Map[String, Any]): MyClass = {
val m = universe.runtimeMirror(getClass.getClassLoader)
val myClass = universe.typeOf[MyClass].typeSymbol.asClass
val cm = m.reflectClass(myClass)
val ctro = universe.typeOf[MyClass].declaration(universe.nme.CONSTRUCTOR).asMethod
val ctorm = cm.reflectConstructor(ctro)
ctorm(values: _*).asInstanceOf[MyClass]
}
create(Map("id" -> "CE0D23A", "value" -> …Run Code Online (Sandbox Code Playgroud) 我想在node.js中使用spawn执行像"doSomething ./myfiles/*.csv"这样的命令.我想使用spawn而不是exec,因为它是某种监视进程,我需要stdout输出.
我试过这个
var spawn = require('child_process').spawn;
spawn("doSomething", ["./myfiles/*.csv"]);
Run Code Online (Sandbox Code Playgroud)
但是,通配符*.csv将不会被解释.
使用spawn()时是否无法使用通配符?还有其他可能解决这个问题吗?
谢谢
托本
您好,可以按名称访问JavaScript变量的值吗?例:
var MyVariable = "Value of variable";
function readValue(name) {
....
}
alert(readValue("MyVariable"));
Run Code Online (Sandbox Code Playgroud)
这是可能的,所以输出是"变量值"吗?如果是,我该如何编写此功能?
谢谢
我想用JavaScript禁用ASP.NET RequiredFieldValidator.其实我正在使用以下代码:
function doSomething()
{
var myVal = document.getElementById('myValidatorClientID');
ValidatorEnable(myVal, false);
}
Run Code Online (Sandbox Code Playgroud)
这会禁用验证器.但我的问题是,我正在使用ValidationSummary.即使我禁用验证器,此摘要也会显示验证消息.
有人能告诉我,如何在ValidationSummary中禁用验证器?
是否有可能在VB.NET中为IF条件内的变量赋值?
像这样的东西:
Dim customer As Customer = Nothing
If IsNothing(customer = GetCustomer(id)) Then
Return False
End If
Run Code Online (Sandbox Code Playgroud)
谢谢
我有以下数据
| Item | Value | Date |
------------------------------
| 1 | 10 | 01.01.2010
| 1 | 20 | 02.01.2010
| 1 | 30 | 03.01.2010
| 1 | 40 | 04.01.2010
| 1 | 50 | 05.01.2010
| 1 | 80 | 10.01.2010
| 2 | 30 | 04.01.2010
| 2 | 60 | 06.01.2010
| 2 | 70 | 07.01.2010
| 2 | 80 | 08.01.2010
| 2 | 100 | 09.01.2010
Run Code Online (Sandbox Code Playgroud)
以下声明
SELECT Item, Value, MIN(Date) …Run Code Online (Sandbox Code Playgroud) 我正在使用一个宏,它将文本插入页脚.宏完成后,页眉和页脚工具处于活动状态,因此我处于页脚的编辑模式.有谁知道如何用VBA关闭这个编辑模式?
谢谢
我需要帮助极地图表的y轴,如spiderweb或windrose.我有一个带有仪表板的应用程序,其中包含一些小部件,每个小部件都包含一个带有Highcharts图表的iframe.因为这些小部件是可重用的,所以我有一些javascript用于调整图表容器的大小.
$(window).bind("resize", resizeChart);
function resizeChart() {
var width = $(document).width() - 55;
var height = $(document).height() - 60;
$("#container").css("width", width);
$("#container").css("height", height);
}
Run Code Online (Sandbox Code Playgroud)
一些例子:http://jsfiddle.net/CwnDw/
我的问题是,y轴的比例通常看起来非常难看.当图表加载时,y轴只有一个刻度.将图表的大小调整为+ 10像素后,它不包含刻度线,并且在调整为初始大小后,y轴呈现5个刻度.我不明白为什么.在我的例子中,当我将图表从小尺寸调整到更大尺寸时,我只能获得这些效果.
有没有更好的方法来调整图表的大小?我尝试了chart.setSize()函数,但没有效果.或者:有没有办法重新渲染/重新计算y轴?
谢谢Torben
我有一个Web应用程序,它使用SQL Server 2005数据库.
我的问题是,该应用程序没有角色管理.因此,应用程序始终使用一个默认用户访问数据库.但现在我必须保存并仅为当前用户访问值.
有没有办法做到这一点?也许类似于Web服务器上的会话?如果有可能从T-SQL访问Web服务器的当前会话ID,最好的方法是.
有谁理解我的问题?:)
t-sql sql-server sql-server-2005 user-management sql-server-2008
highcharts ×2
javascript ×2
sql-server ×2
t-sql ×2
asp.net ×1
exec ×1
java ×1
ms-word ×1
node.js ×1
reflection ×1
scala ×1
spawn ×1
sql ×1
vb.net ×1
vba ×1
word-vba ×1