我有一个这样的视图模型:我如何创建一个具有不同资源文件的公共ViewModel?
public class MyViewModel
{
[Display(Name = "One_Name", ResourceType = typeof(Resources.User.Resource1))]
public string One { get; set; }
[Display(Name = "Two_Name", ResourceType = typeof(Resources.User.Resource1))]
public string Two { get; set; }
}
这是对页面1使用,而伟大的工程(如拉回资源)时,我做的东西是这样的:
@Html.LabelFor(model => model.One)
但我也想使用这个ViewModel,但我不想将这些属性指向不同的资源文件(例如Resources.User.Resource2
)。
我不想欺骗课堂,但我会接受一些OO技巧。
问题是属性参数必须是字符串,常量,typeof
或数组表达式。
解决此问题的最佳方法是什么?
@Darin Dimitrov当我需要他的时候。 :) – RPM1984 2012-03-01 22:50:29