小编Łuk*_*asz的帖子

是否有C#类型表示整数范围?

我需要存储一个整数范围.C#4.0中是否存在现有类型?

当然,我可以使用int Fromint To属性编写自己的类,并构建适当的逻辑来确保这一点From <= To.但是如果一种类型已经存在,我当然宁愿使用它.

c#

102
推荐指数
3
解决办法
6万
查看次数

Angular2 - 使用服务在组件之间共享数据

我有一个对象,我想在我的组件之间共享一个Angular2应用程序.

这是第一个组件的来源:

/* app.component.ts */

// ...imports
import {ConfigService} from './config.service';

@Component({
    selector: 'my-app',
    templateUrl: 'app/templates/app.html',
    directives: [Grid],
    providers: [ConfigService]
})
export class AppComponent {
    public size: number;
    public square: number;

    constructor(_configService: ConfigService) {
        this.size = 16;
        this.square = Math.sqrt(this.size);

        // Here I call the service to put my data
        _configService.setOption('size', this.size);
        _configService.setOption('square', this.square);
    }
}
Run Code Online (Sandbox Code Playgroud)

和第二部分:

/* grid.component.ts */

// ...imports
import {ConfigService} from './config.service';

@Component({
    selector: 'grid',
    templateUrl: 'app/templates/grid.html',
    providers: [ConfigService]
})
export class Grid {
    public config; …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-services angular

27
推荐指数
2
解决办法
3万
查看次数

如何从scala制作一个jar文件

我在网上看过,可以从scala代码创建一个可以从cli运行的jar文件.所有写的都是以下代码.如何从中制作jar文件?我正在使用sbt 0.13.7.

object Main extends App {
    println("Hello World from Scala!")
}
Run Code Online (Sandbox Code Playgroud)

scala jar sbt

17
推荐指数
2
解决办法
2万
查看次数

如何在Slick 3.0.0中使用StaticQuery?

在Slick 2.1中,我有以下代码从文件执行sql-query:

def fetchResult[T](sql: String)(implicit getResult: GetResult[T]): List[T] = {
    val query = Q.queryNA[T](sql)
    try {
        Database.forDataSource(DB.getDataSource())
            .withSession { implicit session => query.list }
    }
    catch {
      case e: Throwable =>
        throw new RunSqlException(s"Query $name execution error", e)
    }
}
Run Code Online (Sandbox Code Playgroud)

在Slick 3.0.0中,您使用dbConfig.db.run方法来执行DBIOAction并获得结果的未来.但是我找不到将Q.queryNA(也就是StaticQuery[Unit, R])的结果转换成的方法DBIOAction.这样的方式存在吗?

我现在结束了不赞成的电话.帮助我变得更好!

def fetchResult[T](sql: String)(implicit getResult: GetResult[T]): Future[List[T]] = Future {
    val query = Q.queryNA[T](sql)
    try {
        this.dbConfig.db.withSession { implicit session => query.list }
    }
    catch {
      case e: Throwable =>
        throw new RunSqlException(s"Query …
Run Code Online (Sandbox Code Playgroud)

scala slick typesafe slick-3.0

9
推荐指数
1
解决办法
1230
查看次数

阿卡调度员的继承权

我正在和Akka一起工作,我们仍然要相互了解.

我的方案是:我为主管(父)演员选择了一个非默认调度员,他的角色是管理(监督)并创建子演员来完成工作.

问题:儿童演员是否继承了父母的演员

我知道您可以为配置中指定的父actor的子actor 明确指定一个不同的调度程序.

akka.actor.deployment {
  /my-parent-actor {
    dispatcher = dispatcher-for-parent
  }

  "/my-parent-actor/*" {
    dispatcher = dispatcher-for-children
  }
}
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果您指定父actor调度程序,而没有明确指定子actor的调度程序,是否继承父项actor的子项.

inheritance scala parent-child dispatcher akka

8
推荐指数
1
解决办法
838
查看次数

Newtonsoft.Json解析不正确的json

我遇到了一个奇怪的问题:如果这样的字符串{"text":"s","cursorPosition":189,"dataSource":"json_northwind",不是正确的json,它仍然会被成功解析.

这是班级:

public class CompletionDataRequest
{
    public CompletionDataRequest(string text, int cursorPosition, string dataSource, string project)
    {
        Text = text;
        CursorPosition = cursorPosition;
        DataSource = dataSource;
        Project = project;
    }

    public string Text { get; }
    public int CursorPosition { get; }
    public string DataSource { get; }
    public string Project { get; }
}
Run Code Online (Sandbox Code Playgroud)

这是令人惊讶的成功的测试:

var s = @"{""text"":""s"",""cursorPosition"":189,""dataSource"":""json_northwind"",";
var request = JsonConvert.DeserializeObject<CompletionDataRequest>(s);
request.Text.Should().Be("s");
request.CursorPosition.Should().Be(189);
request.DataSource.Should().Be("json_northwind");
request.Project.Should().BeNull();
Run Code Online (Sandbox Code Playgroud)

库是否有一些松散的解析规则或者这可能是一个错误?我是图书馆版本9.0.1

c# json json.net

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

如何使用ace编辑器动态触发自动完成:输入命令和完整选项

  1. 我知道如何在网页中使用ace编辑器
  2. 我知道如何添加完成者

我想这样做,输入一个命令,一个空格,然后按-(破折号),让ace编辑器自动完成选项(参数),我该怎么办?

例如,这里是一个命令Print的选项-a|-b|-c|-d,当我输入Print -,如何可以触发自动完成,让你选择 -a-b-c-d

javascript autocomplete editor ace-editor

4
推荐指数
1
解决办法
858
查看次数

重复初始化Clearscript V8引擎时出现内存不足(GC问题?)

我创建了一个基本的默认ASP.NET 5项目.我有一个创建的控制器

var engine = new V8ScriptEngine();
Run Code Online (Sandbox Code Playgroud)

并返回一些模拟json.当我刷新页面一定次数时,我得到了

堆设置中的致命错误

分配失败 - 处理内存不足

并跟踪堆栈跟踪

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at V8Isolate.Create(StdString* , V8IsolateConstraints* , Boolean , Int32 )
   at Microsoft.ClearScript.V8.V8IsolateProxyImpl..ctor(String …
Run Code Online (Sandbox Code Playgroud)

c# asp.net garbage-collection memory-leaks v8

4
推荐指数
1
解决办法
747
查看次数

Angular 2 - 共享服务的实现

我正在尝试实现我在Stack Overflow中找到的解决方案,但面临困难.我有一个服务和一个组件,并且在实现上有些不正确.

错误:TypeError:无法读取undefined属性'next'可能有什么错误或缺失?有什么更多的缺失?同样在我的终端窗口,我收到此错误,但它没有反映在我的浏览器控制台上:错误TS1005:'=>'预期.

import {Injectable} from 'angular2/core';
import {Observable} from 'rxjs/Observable';
import {Observer} from 'rxjs/Observer';
@Injectable()
export class GlobalService {
data: any;
dataChange: Observable<any>;
constructor() {
this.dataChange = new Observable((observer:Observer) { // this is the TS1005 error.
  this.dataChangeObserver = observer;
});
}
setData(data:any) {
this.data = data;
this.dataChangeObserver.next(this.data); //Line of the critical error (next)
} 
}
Run Code Online (Sandbox Code Playgroud)

这是消耗服务的组件....(我只会放置相关的行)

import {GlobalService} from "../../../global.service";
import(...)
@Component({
    providers: [GlobalService],
template: `<p>{{myData}}<>/p><span (click)="addTag(1, 'test')">Add more</span>` 
});
export class MyComponent  {
    addTag (id,desc){
       this._global.setData({ attr: 'some …
Run Code Online (Sandbox Code Playgroud)

typescript angular2-services angular

3
推荐指数
1
解决办法
8042
查看次数

使用reactivemongo进程的embedmongo不会退出

我正在尝试使用ScalaTest + embedmongo + reactivemongo 进行一些测试但是我失败了.我的第一个问题是,在测试mongod进程没有关闭后,我在控制台中有这条消息:

INFO: stopOrDestroyProcess: process has not exited
Run Code Online (Sandbox Code Playgroud)

并且暂停测试直到我手动终止该过程.即使我的测试体是空的,也会发生这种情况.我正在运行Windows 8.1.

另一个问题是,当我尝试使用反应式mongo连接到db里面并向db插入任何内容时,我得到以下异常:

reactivemongo.core.errors.ConnectionNotInitialized: MongoError['Connection is missing metadata (like protocol version, etc.) The connection pool is probably being initialized.']
Run Code Online (Sandbox Code Playgroud)

我真的不知道如何设置它.这是我的测试代码:

package model

import com.github.simplyscala.MongoEmbedDatabase
import org.scalatest.{OptionValues, Matchers, BeforeAndAfter, FlatSpec}
import reactivemongo.api.MongoDriver
import reactivemongo.api.collections.bson.BSONCollection
import scala.concurrent.duration._
import reactivemongo.bson.BSONDocument
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Await


class MongoBookingRepositoryTest extends FlatSpec
  with Matchers
  with OptionValues
  with MongoEmbedDatabase
  with BeforeAndAfter {

  "A MongoBookingRepository" should "..." in withEmbedMongoFixture(port = 12345) { mongoProps =>
    val driver = …
Run Code Online (Sandbox Code Playgroud)

scala mongodb scalatest reactivemongo

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