问题列表 - 第15139页

使用Fluent Nhibernate映射自定义枚举类

阅读Jimmy Boggard的一些 帖子并想知道 - 如何用流利的nhibernate映射那些野兽到底是什么意思?

映射如何看起来像这样?

public class EmployeeType : Enumeration{
    public static readonly EmployeeType 
     Manager = new EmployeeType(0, "Manager"),
     Servant = new EmployeeType(1, "Servant"),
     AssistantToTheRegionalManager = new EmployeeType
       (2, "Assistant to the Regional Manager");

    private EmployeeType() { }
    private EmployeeType(int value, string displayName) : 
        base(value, displayName) { }
}
Run Code Online (Sandbox Code Playgroud)

enums nhibernate-mapping fluent-nhibernate

6
推荐指数
1
解决办法
1243
查看次数

如何覆盖不可继承的类中的属性?

在MSDN文档中,System.Reflection.Assembly有一个名为CodeBase的属性,该属性被定义为可覆盖.

Public Overridable ReadOnly Property CodeBase As String
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试创建一个继承System.Reflection.Assembly的新类,我会收到一条错误消息,告诉我它不能被继承.那么如何覆盖这个属性呢?

.net inheritance overriding

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

Visual Studio 2010 beta 2字体和颜色对话框

预览框中的字符是否意味着什么?

替代文字

已经绞尽脑汁,可能错过了明显的,或者我有点愚蠢,我应该已经知道了!

visual-studio-2010 visual-studio

0
推荐指数
1
解决办法
458
查看次数

如何在html输入值中使用引号

我有以下问题 - 从服务器端我得到一个字符串像'hoschi'兄弟'我想把这个字符串放入<input value"MYSTRING" />.这导致一些<input value"hoschi" brother" />显然不起作用的东西 .

有什么办法吗?是否在值标记中"使用&quot;工作转义字符?

谢谢你的帮助,tobi

html escaping

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

如何判断字段是否是自动实现属性的后备字段?

我正在使用反射来访问和存储属性和字段.但是,为了避免冗余数据,我想摆脱自动实现的属性的支持字段,这些字段也被枚举为普通字段.看起来这些支持字段被命名为"{PropertyName} k_BackingField",看起来我只能解析这个字符串,但我想知道是否有更好的方法,而不是依赖于编译器提供的内部错位名称.

谢谢.

.net reflection

4
推荐指数
2
解决办法
656
查看次数

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

如何使用PHPUnit测试多个异常?

使用PHPUnit测试异常时,要求每个语句或断言必须抛出异常才能使测试通过的最佳方法是什么?

我基本上想做这样的事情:

public function testExceptions()
{

    $this->setExpectedException('Exception');

    foo(-1); //throws exception
    foo(1); //does not throw exception

}

//Test will fail because foo(1) did not throw an exception
Run Code Online (Sandbox Code Playgroud)

我想出了以下内容,它完成了这项工作,但IMO非常难看.

public function testExceptions()
{

    try {
        foo(-1);
    } catch (Exception $e) {
        $hit = true;
    }

    if (!isset($hit))
        $this->fail('No exception thrown');

    unset($hit);

    try {
        foo(1);
    } catch (Exception $e) {
        $hit = true;
    }

    if (!isset($hit))
        $this->fail('No exception thrown');

    unset($hit);

}
Run Code Online (Sandbox Code Playgroud)

php phpunit unit-testing

25
推荐指数
3
解决办法
9194
查看次数

Mono真的是跨平台吗?

官方Mono项目网站称Mono在Windows,Linux和Mac OS X上成功运行.这是真的吗?
我想构建至少在Windows和Linux上运行的应用程序.Mono可以吗?

PS我知道类似的主题已经存在(例如跨平台.Net?),但它们可能已经过时了.

.net linux windows macos mono

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

Ruby on Rails:嵌套属性,belongs_to关系

我有一个具有当前位置字段(城市和国家/地区)的用户实体.为了保存这些信息,我创建了一个名为Location的实体has_many Users.

我不完全确定我是否应该在用户模型中添加"has_one"或"belongs_to",但是如果我想要它拥有该位置的外键我应该放入"belongs_to".我还希望能够在编辑用户时编辑用户的当前位置.所以我使用嵌套属性.但是当我编辑用户时,我每次都会添加一个新位置,而不会将其与已编辑的用户相关联.你能帮我吗?

我的代码如下:

#User Model
class User < ActiveRecord::Base
  ## Relationships
  belongs_to :current_location, :class_name => 'Location'
  accepts_nested_attributes_for :current_location
end

#Location Model
class Location < ActiveRecord::Base
  #Relationship
  has_many :users
end

# part of the _form_edit.haml
- form_edit.fields_for :current_location do |location_form|
  = location_form.label :location, "Current Location"
  = location_form.text_field :location

#Application Helper
#nested attributes for user and location
def setup_user(user)
  returning(user) do |u|
    u.build_current_location if u.current_location.nil?
  end
end

#in the user controller (added after edit)
def update
    @user = @current_user
    if @user.update_attributes(params[:user]) …
Run Code Online (Sandbox Code Playgroud)

attributes nested ruby-on-rails belongs-to

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

在Javascript中左边修剪

有很多脚本在javascript中修剪一个字符串,但没有如何左边修剪字符串.

这是我用来修剪:

String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,"");
}
Run Code Online (Sandbox Code Playgroud)

但是我想稍微改变它并创建一个名为leftTrim的新函数,它只删除前导空格.我的正则表达式非常有限,所以非常感谢任何帮助.

干杯

javascript regex trim

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