在调整画布的父级时,我遇到了一个奇怪的问题,它恰好是一个ChildWindow.
从高层次来看,这是我在用户点击按钮时尝试做的事情:
步骤1和2工作正常.问题出在第3步:当我单步执行F#/ Silverlight代码时,所有大小似乎都设置正确.问题是,ChildWindow获取屏幕上呈现为多比它确实应该更高.
看一下下面的例子:
member this.btnWhatever_Click(sender : obj) (args : RoutedEventArgs) =
let parentWindow = this.Parent :?> ChildWindow // get the canvas' parent, and cast it to a ChildWindow
// if the RowDefinition height is set to our standard, the hide it by setting it to 0
if this.aRowDefinition.Height.Value.Equals STANDARD_ROW_HEIGHT then
this.aRowDefinition.Height <- new GridLength(0.)
this.Height <- this.Height - HEDGE_ROW_HEIGHT
parentWindow.Height <- parentWindow.Height - STANDARD_ROW_HEIGHT
this.btnCreateOrRemoveHedge.Content <- "On"
// otherwise, unhide the RowDefinition by …Run Code Online (Sandbox Code Playgroud) MongoDB架构迁移/升级有哪些选项?
我们(我的同事和我)有一个相当大(约1亿条记录)的MongoDB集合.此集合被映射(ORM'd)到已经过许多不同迭代的Scala lift-mongodb对象.我们在那里有各种代码来处理丢失的字段,重命名,删除,迁移等.
尽管整个"无模式"的东西可以很好和灵活,但在这种情况下,随着我们的对象不断发展,它会导致大量代码混乱.继续沿着这条"灵活对象"的道路前进是根本不可持续的.
你们是如何使用Scala在MongoDB中实现模式迁移/升级的?这个框架是否存在?我知道Foursquare使用Scala和MongoDB以及Rogue(他们自己的查询DSL)...有谁知道他们如何处理他们的迁移?
谢谢.
我将Java/JSON映射转换为可用的F#对象时遇到问题.
这是我的代码的核心:
member this.getMapFromRpcAsynchronously =
Rpc.getJavaJSONMap (new Action<_>(this.fillObjectWithJSONMap))
()
member this.fillObjectWithJSONMap (returnedMap : JSONMap<string, int> option) =
let container = Option.get(returnedMap)
let map = container.map
for thing in map do
this.myObject.add thing.key
// do stuff with thing
()
Run Code Online (Sandbox Code Playgroud)
我的RPC方法返回的JSON如下所示:
{"id":1, "result":
{"map":
{"Momentum":12, "Corporate":3, "Catalyst":1},
"javaClass":"java.util.HashMap"}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试将其映射到F#DataContract,如下所示:
[<DataContract>]
type JSONMap<'T, 'S> = {
[<DataMember>]
mutable map : KeyValuePair<'T, 'S> array
[<DataMember>]
mutable javaClass : string
}
[<DataContract>]
type JSONSingleResult<'T> = {
[<DataMember>]
mutable javaClass: string
[<DataMember>]
mutable result: 'T …Run Code Online (Sandbox Code Playgroud) 我有一个按钮,图像如下:
let btnFoo = new Button()
let imgBar = new BitmapImage(new System.Uri("images/whatever.png", System.UriKind.RelativeOrAbsolute))
Run Code Online (Sandbox Code Playgroud)
我希望按钮内容包含一些文本,以及图像.
我可以很好地完成这两件事中的任何一件,但是他们同时没有把我的文字和图片都拿到按钮上:
btnFoo.Content <- "Text"
btnFoo.Content <- imgBar
Run Code Online (Sandbox Code Playgroud)
这些都不起作用:
btnFoo.Content <- "Text " + imgBar // compiler hates this
btnFoo.Content <- "Text ", imgBar // compiler is OK, but result is ugly since the image is rendered as the class text
Run Code Online (Sandbox Code Playgroud)
我也无法将按钮的背景设置为图像:
btnFoo.Background <- imgBar // compiler doesn't like this because Background expects a Media.Brush
Run Code Online (Sandbox Code Playgroud)
有什么想法/想法吗?谢谢!
我正在开发一个Play 2.2应用程序,自从我尝试添加我的数据库层以来,事情已经在我身上发生了一些变化.
以下是我的build.sbt依赖项.如你所见,我使用mysql-connector-java和play-slick:
libraryDependencies ++= Seq(
jdbc,
anorm,
cache,
"joda-time" % "joda-time" % "2.3",
"mysql" % "mysql-connector-java" % "5.1.26",
"com.typesafe.play" %% "play-slick" % "0.5.0.8",
"com.aetrion.flickr" % "flickrapi" % "1.1"
)
Run Code Online (Sandbox Code Playgroud)
我application.conf有一些类似的简单数据库内容:
db.default.url="jdbc:mysql://localhost/myDb"
db.default.driver="com.mysql.jdbc.Driver"
db.default.user="root"
db.default.pass=""
Run Code Online (Sandbox Code Playgroud)
这是我的Play服务器启动时的样子:
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
[info] Compiling 1 Scala source to C:\bbq\cats\in\space
[info] play - database [default] connected at jdbc:mysql://localhost/myDb
[info] …Run Code Online (Sandbox Code Playgroud) 我需要一种方法来加载具有相同规则名称的多个样式表,然后将它们应用于页面上的不同元素.这可能吗?
这是我想做的事情的一个例子.选择下面的两个样式表:
style1.css:
.size{
color: #FF6600;
font-size: 18px;
}
Run Code Online (Sandbox Code Playgroud)
style2.css:
.size{
color: #FF0000;
font-size: 14px;
}
Run Code Online (Sandbox Code Playgroud)
我希望能够将它们都导入到页面中(可能具有某种类型的id),然后在一个特定div中设置文本以使用style1.css中的规则,另一个div应该使用style2中的规则的CSS.
我需要这样做,因为它允许我的应用程序的用户上传页面上不同小部件的自定义样式表.如果工作表使用相同的规则命名方案,则此方案应该有效.
我正在使用AWS PHP 开发人员指南 中描述的方法查询 DynamoDB 表。
我传递给 Dynamo 连接的数组如下所示:
Array(
[ConsistentRead] => false
[TableName] => bbq_lol_test
[KeyConditions] => Array(
[stinky_cheese] => Array(
[ComparisonOperator] => EQ
[AttributeValueList] => Array(
[S] => camembert)
)
)
)
Run Code Online (Sandbox Code Playgroud)
如您所见,它与示例使用的格式完全相同,但Type枚举除外(它只是一个字符串)。
$connection->query使用上述数组作为参数执行时,出现以下异常:
Guzzle\Service\Exception\ValidationException:
Validation errors: [KeyConditions][stinky_cheese][AttributeValueList][S][AttributeValue] must be of type object
Run Code Online (Sandbox Code Playgroud)
这很奇怪,因为堆栈跟踪中的数组似乎很好:
Aws/Common/Client/AbstractClient.php(103): Guzzle\Service\Client->__call("Query", array(array("ConsistentRead" => false, "TableName" => "bbq_lol_test", "KeyConditions" => array("stinky_cheese" => array("ComparisonOperator" => "EQ", "AttributeValueList" => array("S" => "camembert"))))))
Run Code Online (Sandbox Code Playgroud)
我确实在该stinky_cheese字段上有一个索引(因为我使用的是查询)。我可能正在做一些愚蠢的事情,但我现在似乎无法弄清楚。任何帮助将不胜感激 - 谢谢!
当我单步执行以下代码时,report第二行为null.但是,第三行生成NullReferenceException.
member this.setTaggedResearchReportList (index : int) (taggedResearchReport : TaggedResearchReportUIVO option) =
let report = Option.get(taggedResearchReport)
if not(report.Equals(null)) then
// do some stuff here
Run Code Online (Sandbox Code Playgroud)
为什么会这样,我该怎么做才能避免呢?谢谢!
这是调用的行this.setTaggedResearchReportList:
getMostRecentTaggedResearchReportForSecurityId (item.id) (new Action<_>(this.setTaggedResearchReportList 0))
Run Code Online (Sandbox Code Playgroud)
这是getMostRecentTaggedResearchReportForSecurityId方法:
let getMostRecentTaggedResearchReportForSecurityId (securityId : int) (callbackUI : Action<_>) =
getSingleRPCResult<JSONSingleResult<TaggedResearchReportUIVO>, TaggedResearchReportUIVO>
"TaggedResearchReportRPC"
"getMostRecentResearchReportForSecurityId"
(sprintf "%i" securityId)
callbackUI
(fun (x : option<JSONSingleResult<TaggedResearchReportUIVO>>) ->
match x.IsSome with
| true -> Some(Option.get(x).result)
| false -> None
)
Run Code Online (Sandbox Code Playgroud) 我正在使用Play 2.2在Scala中创建一个应用程序.我play-slick 0.5.0.8用作MySQL DB连接器.我有以下应用程序控制器:
package controllers
import models._
import models.database._
import play.api._
import play.api.mvc._
import play.api.Play.current
import play.api.db.slick._
object Application extends Controller {
// WORKS:
def test = DBAction {
implicit session => Ok(views.html.test(Cameras.findById(1)))
}
// DOES NOT WORK:
def photo = Action {
val p = PhotoFetcher.fetchRandomDisplayPhoto(someParametersBlah))
Ok(views.html.photo(p))
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,testDBAction 可以正常工作,并且能够从数据库中获取照片.不幸的是,photo行动不起作用.
我PhotoFetcher.fetchRandomDisplayPhoto(blah)做了很多不同的事情.埋在里面的是一个调用Cameras.findById(blah),它应该返回一个Camera对象(在testDBAction中工作).但是,使用此配置,我收到以下错误:
could not find implicit value for parameter s: slick.driver.MySQLDriver.simple.Session
Run Code Online (Sandbox Code Playgroud)
我已经尝试将photoAction转换为DBAction,如下所示: …