我正在阅读"在VS 2015中内置支持jsx语法",但找不到它.它隐藏在IDE的设置中,还是需要安装一些扩展?
我正在从'App.config'中读取设置.我只是想出了如何使用ConfigurationSection,ConfigurationElementCollection和ConfigurationelElement.
App.config中:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="notificationSettingsGroup">
<section name="mailTemplates" type="Project.Lib.Configuration.MailTemplateSection, Project.Lib"
allowDefinition="Everywhere" allowExeDefinition="MachineToApplication" requirePermission="false"/>
</sectionGroup>
</configSections>
<notificationSettingsGroup>
<mailTemplates>
<items>
<mailTemplate name="actionChain" subject="Subject bla-bla">
<body>Body bla-bla</body>
</mailTemplate>
</items>
</mailTemplates>
</notificationSettingsGroup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的C#代码:
public class MailTemplateSection : ConfigurationSection
{
[ConfigurationProperty("items", IsDefaultCollection = false)]
public MailTemplateCollection MailTemplates
{
get { return (MailTemplateCollection)this["items"]; }
set { this["items"] = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
[ConfigurationCollection(typeof(MailTemplateElement), AddItemName = "mailTemplate",
CollectionType = ConfigurationElementCollectionType.AddRemoveClearMap)]
public …Run Code Online (Sandbox Code Playgroud) 我刚开始使用ASP.NET MVC 4开始新项目,我有疑问.
我如何在一个视图中使用多个模型(或ViewModel-s)?我通过Internet搜索,标准解决方案是"创建具有2个或更多属性的复杂视图模型",例如:
public class ComplexViewModel
{
public LoginModel LoginModel { get; set; }
public CartModel CartModel { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
但是,例如,在每个页面中,我将至少有 2个模型 - LoginModel和另一个模型(取决于页面).那么,我需要在每个ViewModel中定义LoginModel吗?
PS:我正在使用ASP.NET MVC 4,Entity Framework 5.