小编Pet*_*ron的帖子

使用 clj-time 将 Clojure #inst 即时转换为 Joda 时间

#inst "2017-01-01T12:00:00"使用clj-time库将 Clojure 时间瞬间解析为 Joda 时间的正确方法是什么?

parsing clojure jodatime clj-time

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

Datomic:`:db.error/tempid-not-an-entity` tempid仅用作事务中的值

当我尝试使用字符串tempid对无数据组件v0.9.5656进行交易时,我得到以下异常:

(def tx1 {:db/id             "user"
          :contact/full-name "John Wayne"})
(def tx2 {:db/id    "other"
          :some-ref "user"
(let [!rx (d/transact conn [tx2])]
   (prn (:tempids @!rx))
=> 

datomic.impl.Exceptions$IllegalArgumentExceptionInfo: :db.error/tempid-not-an-entity tempid used only as value in transaction
    data: {#object[clojure.lang.Keyword 0x74af59e7 ":db/error"] #object[clojure.lang.Keyword 0x57972b49 ":db.error/tempid-not-an-entity"]}
             java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/tempid-not-an-entity tempid used only as value in transaction
Run Code Online (Sandbox Code Playgroud)

文档显示我应该能够使用字符串作为tempid.我错过了一个读取器宏来告诉它一个分区吗?

clojure datomic

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

构建后提交:好还是坏?

在成功构建之后自动化源代码控制提交是一个好的策略吗?


编辑:我问,因为我想在版本之间进行更频繁的增量提交,这使得更容易找到引入错误的点,而不是在v1.0和v1.1之间回滚2K +新的代码行.

mercurial post-build-event post-build

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

ASP.NET MVC Web API和StructureMap:"没有默认构造函数"

我配置了一个ASP.NET MVC 4的Web API项目使用StructureMap 2.6.2.0中描述的这个帖子,但访问/api/parts返回下面的错误,尽管显式调用StructuremapMvc.Start();Application_Start():

{
  "ExceptionType": "System.ArgumentException",
  "Message": "Type 'MyProject.Web.Controllers.PartsController' does not have
              a default constructor",
  "StackTrace": "   at System.Linq.Expressions.Expression.New(Type type)\r\n 
                    at System.Web.Http.Internal.TypeActivator.Create[TBase](Type instanceType)\r\n   
                    at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)"
}
Run Code Online (Sandbox Code Playgroud)

我实现IDependencyResolverIDependencyScope设置了Web API依赖关系解析器,如下所示~/App_Start/StructureMapMvc.cs:

GlobalConfiguration.Configuration.DependencyResolver =
    new StructureMapHttpDependencyResolver(container);
Run Code Online (Sandbox Code Playgroud)

为什么Web API仍然抱怨默认的consturctor?

structuremap asp.net-mvc dependency-injection asp.net-web-api

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

在已安装的文件夹中运行Docker镜像命令

我试图lein run一个安装的文件夹中执行Clojure Docker镜像/,但是当我尝试cd进入一个文件夹时,Docker抱怨unable to locate cd:

docker run -v /root/chortles:/test -i jphackworth/docker-clojure cd /test && lein run
=> Unable to locate cd
Run Code Online (Sandbox Code Playgroud)

如何指示Leiningen在不同的文件夹中运行,或者告诉Docker在运行命令之前更改目录?

clojure leiningen docker ubuntu-13.04

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

IntelliJ:快速显示文件路径

如何查看我在IntelliJ中编辑的当前文件的文件路径?我可以将鼠标悬停在选项卡上以获取文件,但需要几秒钟时间,我必须保持鼠标静止才能看到我无法复制的路径.

intellij-idea

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

AutoMapper 5自定义值解析器"无法将表达式类型X转换为返回类型Y"

我从旧版本的AutoMapper升级并转换了我的自定义解析器,但我很难过.

public class ProductMappingProfile : Profile
{
    public ProductMappingProfile()
    {
        CreateMap<Product, ProductViewModel>()
            .ForMember(
                dest => dest.Model,
                opt => opt.ResolveUsing<ModelNameResolver>(src => src.ModelId));
        // won't compile
    }
}
Run Code Online (Sandbox Code Playgroud)

Product具有int? ModelId属性且ProductViewModel具有string Name属性.

自定义解析器

public class ModelNameResolver : IValueResolver<short?, string, string>
{
    private readonly InventoryService _inventoryService;
    public ModelNameResolver(InventoryService inventoryService)
    {
        _inventoryService = inventoryService;
    }

    public string Resolve(short? source, string destination, string destMember, ResolutionContext context)
    {
        if (!source.HasValue)
            return "n/a";

        return _inventoryService.GetModel(source.Value)
            .Name;
    }
}
Run Code Online (Sandbox Code Playgroud)

编译错误:

The type 'MyNamespace.Web.Resolvers.ModelCodeResolver' cannot be …
Run Code Online (Sandbox Code Playgroud)

c# automapper automapper-5

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

为什么连接路径完全取代Rust中的原始路径?

我不明白Rust如何连接文件路径.为什么这不起作用:

fn main() {
    let root = std::path::Path::new("resources/");
    let uri = std::path::Path::new("/js/main.js");
    let path = root.join(uri);
    assert_eq!(path.to_str(), Some("resources/js/main.js"));
}
Run Code Online (Sandbox Code Playgroud)

失败了:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Some("/js/main.js")`,
 right: `Some("resources/js/main.js")`', src/main.rs:5:5
Run Code Online (Sandbox Code Playgroud)

我在文档中看到"推动绝对路径取代现有路径",但这似乎是一个可怕的想法,会吸引很多人.

在这种情况下,我如何安全地剥离绝对路径,或使其相对?

filepath rust

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

如何在Rust中添加或乘以两个i16以形成一个i32而不会溢出?

如何i16在Rust 中将两个数字相加或相乘成一个更大的数i32而不会溢出?

let a: i16 = i16::max_value();
let b: i16 = i16::max_value();
let c: i32 = a + b; // throws EO308 "Expected `u32`, found `u16`
Run Code Online (Sandbox Code Playgroud)

integer-overflow rust

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

通过强制转换(ChildClass)parentObject来调用子构造函数; 跟踪修订

为了跟踪Page类的修订,我有一个PageRevision继承自Page并添加修订ID(Guid RevisionID;)的类.

如果可能,我应该如何将现有Page对象PageRevision强制转换为a 并确保调用PageRevision构造函数来创建新的修订版ID?

我可以有一个PageRevision(Page page)生成Guid 的构造函数并复制所有的Page属性,但我想自动化它,特别是如果一个Page类有很多属性(后来我添加一个,忘了修改复制构造函数).

期望的用途

Page page = new Page(123, "Page Title", "Page Body"); // where 123 is page ID
PageRevision revision = (PageRevision)page;
// now revision.RevisionID should be a new Guid.
Run Code Online (Sandbox Code Playgroud)

Page,PageRevision班级:

public class Page
{
    public int ID { get; set; }
    public string Title { get; set; }
    public string Body { get; set; } …
Run Code Online (Sandbox Code Playgroud)

c# inheritance constructor revision parent-child

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