Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: icsharpcode/SharpDevelop
...
head fork: icsharpcode/SharpDevelop
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
16 src/AddIns/BackendBindings/AspNet.Mvc/Project/AspNet.Mvc.csproj
@@ -54,6 +54,10 @@
<Compile Include="ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Empty.cs">
<DependentUpon>Empty.tt</DependentUpon>
</Compile>
+ <Compile Include="ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.cs">
+ <DependentUpon>Create.tt</DependentUpon>
+ <AutoGen>True</AutoGen>
+ </Compile>
<Compile Include="ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Empty.cs">
<DependentUpon>Empty.tt</DependentUpon>
</Compile>
@@ -206,6 +210,12 @@
<CustomToolNamespace>ICSharpCode.AspNet.Mvc.AspxCSharp</CustomToolNamespace>
<LastGenOutput>Empty.cs</LastGenOutput>
</None>
+ <None Include="ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt">
+ <Generator>TextTemplatingFilePreprocessor</Generator>
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ <LastGenOutput>Create.cs</LastGenOutput>
+ <CustomToolNamespace>ICSharpCode.AspNet.Mvc.CSHtml</CustomToolNamespace>
+ </None>
<None Include="ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Empty.tt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Generator>TextTemplatingFilePreprocessor</Generator>
@@ -215,11 +225,17 @@
<None Include="ItemTemplates\VisualBasic\CodeTemplates\AddController\Controller.tt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
+ <None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\AspxVisualBasic\Create.tt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\AspxVisualBasic\Empty.tt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="Resources\CSharpRazor.xshd" />
<EmbeddedResource Include="Resources\VisualBasicRazor.xshd" />
+ <None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\VBHTML\Create.tt">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </None>
<None Include="ItemTemplates\VisualBasic\CodeTemplates\AddView\VBHTML\Empty.tt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
View
402 src/AddIns/BackendBindings/AspNet.Mvc/Project/ItemTemplates/CSharp/CodeTemplates/AddView/CSHTML/Create.cs
@@ -0,0 +1,402 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.239
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace ICSharpCode.AspNet.Mvc.CSHtml {
+ using ICSharpCode.AspNet.Mvc;
+ using System;
+
+
+ public partial class Create : CreateBase {
+
+ private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue;
+
+
+ #line 53 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+
+ MvcTextTemplateHost MvcHost {
+ get { return (MvcTextTemplateHost)Host; }
+ }
+
+ public string GetModelDirective()
+ {
+ string viewDataTypeName = MvcHost.ViewDataTypeName;
+ if (!String.IsNullOrEmpty(viewDataTypeName)) {
+ return String.Format("@model {0}", viewDataTypeName);
+ }
+ return String.Empty;
+ }
+
+ #line default
+ #line hidden
+
+
+ public global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost Host {
+ get {
+ return this.hostValue;
+ }
+ set {
+ this.hostValue = value;
+ }
+ }
+
+ public virtual string TransformText() {
+ this.GenerationEnvironment = null;
+
+ #line 4 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( GetModelDirective() ));
+
+ #line default
+ #line hidden
+
+ #line 4 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("\r\n\r\n");
+
+ #line default
+ #line hidden
+
+ #line 6 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+
+ if (MvcHost.IsPartialView) {
+ // Do nothing.
+ } else if (MvcHost.IsContentPage) {
+
+
+ #line default
+ #line hidden
+
+ #line 11 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("@{\r\n\tViewBag.Title = \"");
+
+ #line default
+ #line hidden
+
+ #line 12 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewName ));
+
+ #line default
+ #line hidden
+
+ #line 12 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("\";\r\n\tLayout = \"");
+
+ #line default
+ #line hidden
+
+ #line 13 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.MasterPageFile ));
+
+ #line default
+ #line hidden
+
+ #line 13 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("\";\r\n}\r\n\r\n<h2>");
+
+ #line default
+ #line hidden
+
+ #line 16 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewName ));
+
+ #line default
+ #line hidden
+
+ #line 16 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("</h2>\r\n\r\n");
+
+ #line default
+ #line hidden
+
+ #line 18 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+
+ } else {
+
+
+ #line default
+ #line hidden
+
+ #line 21 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("<!DOCTYPE html>\r\n<html>\r\n\t<head runat=\"server\">\r\n\t\t<title>");
+
+ #line default
+ #line hidden
+
+ #line 24 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewName ));
+
+ #line default
+ #line hidden
+
+ #line 24 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("</title>\r\n\t</head>\r\n\t<body>\r\n");
+
+ #line default
+ #line hidden
+
+ #line 27 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+
+ PushIndent("\t\t");
+ }
+
+
+ #line default
+ #line hidden
+
+ #line 31 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("@using (Html.BeginForm()) {\r\n\t@Html.ValidationSummary(true)\r\n\t<fieldset>\r\n\t\t<lege" +
+ "nd>");
+
+ #line default
+ #line hidden
+
+ #line 34 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewDataType.Name ));
+
+ #line default
+ #line hidden
+
+ #line 34 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("</legend>\r\n\t\t\r\n\t\t<p>\r\n\t\t\t<input type=\"submit\" value=\"Create\"/>\r\n\t\t</p>\r\n\t</fields" +
+ "et>\r\n}\r\n<div>\r\n\t@Html.ActionLink(\"Back\", \"Index\")\r\n</div>\r\n");
+
+ #line default
+ #line hidden
+
+ #line 44 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+
+ if (MvcHost.IsPartialView) {
+ // Do nothing.
+ } else if (!MvcHost.IsContentPage) {
+ PopIndent();
+
+
+ #line default
+ #line hidden
+
+ #line 50 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ this.Write("\t</body>\r\n</html>\r\n");
+
+ #line default
+ #line hidden
+
+ #line 52 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Create.tt"
+ }
+
+ #line default
+ #line hidden
+ return this.GenerationEnvironment.ToString();
+ }
+
+ protected virtual void Initialize() {
+ }
+ }
+
+ public class CreateBase {
+
+ private global::System.Text.StringBuilder builder;
+
+ private global::System.Collections.Generic.IDictionary<string, object> session;
+
+ private global::System.CodeDom.Compiler.CompilerErrorCollection errors;
+
+ private string currentIndent = string.Empty;
+
+ private global::System.Collections.Generic.Stack<int> indents;
+
+ private bool endsWithNewline;
+
+ private ToStringInstanceHelper _toStringHelper = new ToStringInstanceHelper();
+
+ public virtual global::System.Collections.Generic.IDictionary<string, object> Session {
+ get {
+ return this.session;
+ }
+ set {
+ this.session = value;
+ }
+ }
+
+ public global::System.Text.StringBuilder GenerationEnvironment {
+ get {
+ if ((this.builder == null)) {
+ this.builder = new global::System.Text.StringBuilder();
+ }
+ return this.builder;
+ }
+ set {
+ this.builder = value;
+ }
+ }
+
+ protected global::System.CodeDom.Compiler.CompilerErrorCollection Errors {
+ get {
+ if ((this.errors == null)) {
+ this.errors = new global::System.CodeDom.Compiler.CompilerErrorCollection();
+ }
+ return this.errors;
+ }
+ }
+
+ public string CurrentIndent {
+ get {
+ return this.currentIndent;
+ }
+ }
+
+ private global::System.Collections.Generic.Stack<int> Indents {
+ get {
+ if ((this.indents == null)) {
+ this.indents = new global::System.Collections.Generic.Stack<int>();
+ }
+ return this.indents;
+ }
+ }
+
+ public ToStringInstanceHelper ToStringHelper {
+ get {
+ return this._toStringHelper;
+ }
+ }
+
+ public void Error(string message) {
+ this.Errors.Add(new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message));
+ }
+
+ public void Warning(string message) {
+ global::System.CodeDom.Compiler.CompilerError val = new global::System.CodeDom.Compiler.CompilerError(null, -1, -1, null, message);
+ val.IsWarning = true;
+ this.Errors.Add(val);
+ }
+
+ public string PopIndent() {
+ if ((this.Indents.Count == 0)) {
+ return string.Empty;
+ }
+ int lastPos = (this.currentIndent.Length - this.Indents.Pop());
+ string last = this.currentIndent.Substring(lastPos);
+ this.currentIndent = this.currentIndent.Substring(0, lastPos);
+ return last;
+ }
+
+ public void PushIndent(string indent) {
+ this.Indents.Push(indent.Length);
+ this.currentIndent = (this.currentIndent + indent);
+ }
+
+ public void ClearIndent() {
+ this.currentIndent = string.Empty;
+ this.Indents.Clear();
+ }
+
+ public void Write(string textToAppend) {
+ if (string.IsNullOrEmpty(textToAppend)) {
+ return;
+ }
+ if ((((this.GenerationEnvironment.Length == 0)
+ || this.endsWithNewline)
+ && (this.CurrentIndent.Length > 0))) {
+ this.GenerationEnvironment.Append(this.CurrentIndent);
+ }
+ this.endsWithNewline = false;
+ char last = textToAppend[(textToAppend.Length - 1)];
+ if (((last == '\n')
+ || (last == '\r'))) {
+ this.endsWithNewline = true;
+ }
+ if ((this.CurrentIndent.Length == 0)) {
+ this.GenerationEnvironment.Append(textToAppend);
+ return;
+ }
+ int lastNewline = 0;
+ for (int i = 0; (i
+ < (textToAppend.Length - 1)); i = (i + 1)) {
+ char c = textToAppend[i];
+ if ((c == '\r')) {
+ if ((textToAppend[(i + 1)] == '\n')) {
+ i = (i + 1);
+ if ((i
+ == (textToAppend.Length - 1))) {
+ goto breakLoop;
+ }
+ }
+ }
+ else {
+ if ((c != '\n')) {
+ goto continueLoop;
+ }
+ }
+ i = (i + 1);
+ int len = (i - lastNewline);
+ if ((len > 0)) {
+ this.GenerationEnvironment.Append(textToAppend, lastNewline, (i - lastNewline));
+ }
+ this.GenerationEnvironment.Append(this.CurrentIndent);
+ lastNewline = i;
+ continueLoop:
+ ;
+ }
+ breakLoop:
+ if ((lastNewline > 0)) {
+ this.GenerationEnvironment.Append(textToAppend, lastNewline, (textToAppend.Length - lastNewline));
+ }
+ else {
+ this.GenerationEnvironment.Append(textToAppend);
+ }
+ }
+
+ public void Write(string format, params object[] args) {
+ this.Write(string.Format(format, args));
+ }
+
+ public void WriteLine(string textToAppend) {
+ this.Write(textToAppend);
+ this.GenerationEnvironment.AppendLine();
+ this.endsWithNewline = true;
+ }
+
+ public void WriteLine(string format, params object[] args) {
+ this.WriteLine(string.Format(format, args));
+ }
+
+ public class ToStringInstanceHelper {
+
+ private global::System.IFormatProvider formatProvider = global::System.Globalization.CultureInfo.InvariantCulture;
+
+ public global::System.IFormatProvider FormatProvider {
+ get {
+ return this.formatProvider;
+ }
+ set {
+ if ((this.formatProvider == null)) {
+ throw new global::System.ArgumentNullException("formatProvider");
+ }
+ this.formatProvider = value;
+ }
+ }
+
+ public string ToStringWithCulture(object objectToConvert) {
+ if ((objectToConvert == null)) {
+ throw new global::System.ArgumentNullException("objectToConvert");
+ }
+ global::System.Type type = objectToConvert.GetType();
+ global::System.Type iConvertibleType = typeof(global::System.IConvertible);
+ if (iConvertibleType.IsAssignableFrom(type)) {
+ return ((global::System.IConvertible)(objectToConvert)).ToString(this.formatProvider);
+ }
+ global::System.Reflection.MethodInfo methInfo = type.GetMethod("ToString", new global::System.Type[] {
+ iConvertibleType});
+ if ((methInfo != null)) {
+ return ((string)(methInfo.Invoke(objectToConvert, new object[] {
+ this.formatProvider})));
+ }
+ return objectToConvert.ToString();
+ }
+ }
+ }
+}
View
66 src/AddIns/BackendBindings/AspNet.Mvc/Project/ItemTemplates/CSharp/CodeTemplates/AddView/CSHTML/Create.tt
@@ -0,0 +1,66 @@
+<#@ template language="C#" HostSpecific="true" #>
+<#@ import namespace="ICSharpCode.AspNet.Mvc" #>
+<#@ output extension=".cshtml" #>
+<#= GetModelDirective() #>
+
+<#
+ if (MvcHost.IsPartialView) {
+ // Do nothing.
+ } else if (MvcHost.IsContentPage) {
+#>
+@{
+ ViewBag.Title = "<#= MvcHost.ViewName #>";
+ Layout = "<#= MvcHost.MasterPageFile #>";
+}
+
+<h2><#= MvcHost.ViewName #></h2>
+
+<#
+ } else {
+#>
+<!DOCTYPE html>
+<html>
+ <head runat="server">
+ <title><#= MvcHost.ViewName #></title>
+ </head>
+ <body>
+<#
+ PushIndent("\t\t");
+ }
+#>
+@using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+ <fieldset>
+ <legend><#= MvcHost.ViewDataType.Name #></legend>
+
+ <p>
+ <input type="submit" value="Create"/>
+ </p>
+ </fieldset>
+}
+<div>
+ @Html.ActionLink("Back", "Index")
+</div>
+<#
+ if (MvcHost.IsPartialView) {
+ // Do nothing.
+ } else if (!MvcHost.IsContentPage) {
+ PopIndent();
+#>
+ </body>
+</html>
+<# } #>
+<#+
+ MvcTextTemplateHost MvcHost {
+ get { return (MvcTextTemplateHost)Host; }
+ }
+
+ public string GetModelDirective()
+ {
+ string viewDataTypeName = MvcHost.ViewDataTypeName;
+ if (!String.IsNullOrEmpty(viewDataTypeName)) {
+ return String.Format("@model {0}", viewDataTypeName);
+ }
+ return String.Empty;
+ }
+#>
View
72 ...endBindings/AspNet.Mvc/Project/ItemTemplates/VisualBasic/CodeTemplates/AddView/AspxVisualBasic/Create.tt
@@ -0,0 +1,72 @@
+<#@ template language="VB" HostSpecific="true" #>
+<#@ import namespace="ICSharpCode.AspNet.Mvc" #>
+<#@ import namespace="Microsoft.VisualBasic.Constants" #>
+<# If MvcHost.IsPartialView Then #>
+<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl<#= GetViewPageType() #>" %>
+
+<# ElseIf MvcHost.IsContentPage Then #>
+<%@ Page Language="VB" MasterPageFile="<#= MvcHost.MasterPageFile #>" Inherits="System.Web.Mvc.ViewPage<#= GetViewPageType() #>" %>
+
+<asp:Content ID="Content1" ContentPlaceHolderID="Title" runat="server">
+<#= MvcHost.ViewName #>
+</asp:Content>
+
+<asp:Content ID="Content2" ContentPlaceHolderID="<#= MvcHost.PrimaryContentPlaceHolderID #>" runat="server">
+<#
+ PushIndent(vbTab)
+ Else
+#>
+<%@ Page Language="VB" Inherits="System.Web.Mvc.ViewPage<#= GetViewPageType() #>" %>
+
+<!DOCTYPE html>
+<html>
+ <head runat="server">
+ <title><#= MvcHost.ViewName #></title>
+ </head>
+ <body>
+<#
+ PushIndent(vbTab & vbTab)
+ End If
+#>
+<% Using Html.BeginForm() %>
+ <%: Html.ValidationSummary(True) %>
+ <fieldset>
+ <legend><#= MvcHost.ViewDataType.Name #></legend>
+
+ <p>
+ <input type="submit" value="Create"/>
+ </p>
+ </fieldset>
+<% End Using %>
+<div>
+ <%: Html.ActionLink("Back", "Index") %>
+</div>
+<#
+ If MvcHost.IsPartialView Then
+ ' Do nothing.
+ ElseIf MvcHost.IsContentPage Then
+ PopIndent()
+#>
+</asp:Content>
+<#
+ Else
+ PopIndent()
+#>
+ </body>
+</html>
+<# End If #>
+<#+
+ ReadOnly Property MvcHost As MvcTextTemplateHost
+ Get
+ Return DirectCast(Host, MvcTextTemplateHost)
+ End Get
+ End Property
+
+ Public Function GetViewPageType() As String
+ Dim viewDataTypeName As String = MvcHost.ViewDataTypeName
+ If Not String.IsNullOrEmpty(viewDataTypeName) Then
+ Return String.Format("(Of {0})", viewDataTypeName)
+ End If
+ Return String.Empty
+ End Function
+#>
View
68 ...dIns/BackendBindings/AspNet.Mvc/Project/ItemTemplates/VisualBasic/CodeTemplates/AddView/VBHTML/Create.tt
@@ -0,0 +1,68 @@
+<#@ template language="VB" HostSpecific="true" #>
+<#@ import namespace="ICSharpCode.AspNet.Mvc" #>
+<#@ import namespace="Microsoft.VisualBasic.Constants" #>
+<#@ output extension=".vbhtml" #>
+<#= GetModelDirective() #>
+
+<#
+ If MvcHost.IsPartialView Then
+ ' Do nothing.
+ ElseIf MvcHost.IsContentPage Then
+#>
+@Code
+ ViewData("Title") = "<#= MvcHost.ViewName #>"
+ Layout = "<#= MvcHost.MasterPageFile #>"
+End Code
+
+<h2><#= MvcHost.ViewName #></h2>
+
+<#
+ Else
+#>
+<!DOCTYPE html>
+<html>
+ <head runat="server">
+ <title><#= MvcHost.ViewName #></title>
+ </head>
+ <body>
+<#
+ PushIndent(vbTab & vbTab)
+ End If
+#>
+@Using Html.BeginForm()
+ @Html.ValidationSummary(True)
+ @<fieldset>
+ <legend><#= MvcHost.ViewDataType.Name #></legend>
+
+ <p>
+ <input type="submit" value="Create"/>
+ </p>
+ </fieldset>
+End Using
+<div>
+ @Html.ActionLink("Back", "Index")
+</div>
+<#
+ If MvcHost.IsPartialView Then
+ ' Do nothing.
+ ElseIf Not MvcHost.IsContentPage Then
+ PopIndent()
+#>
+ </body>
+</html>
+<# End If #>
+<#+
+ ReadOnly Property MvcHost As MvcTextTemplateHost
+ Get
+ Return DirectCast(Host, MvcTextTemplateHost)
+ End Get
+ End Property
+
+ Function GetModelDirective() As String
+ Dim viewDataTypeName As String = MvcHost.ViewDataTypeName
+ If Not String.IsNullOrEmpty(viewDataTypeName) Then
+ Return String.Format("@ModelType {0}", viewDataTypeName)
+ End If
+ Return String.Empty
+ End Function
+#>
View
1  src/AddIns/BackendBindings/AspNet.Mvc/Test/AspNet.Mvc.Tests.csproj
@@ -88,6 +88,7 @@
<Compile Include="Src\CodeTemplates\AspxCSharpCreateViewTemplateTests.cs" />
<Compile Include="Src\CodeTemplates\AspxCSharpEmptyViewTemplateTests.cs" />
<Compile Include="Src\CodeTemplates\Models\ModelWithNoProperties.cs" />
+ <Compile Include="Src\CodeTemplates\RazorCSharpCreateViewTemplateTests.cs" />
<Compile Include="Src\CodeTemplates\RazorCSharpEmptyViewTemplateTests.cs" />
<Compile Include="Src\IsMvcControllerFolderSelectedConditionEvaluatorTests.cs" />
<Compile Include="Src\IsMvcViewFolderSelectedConditionEvaluatorTests.cs" />
View
170 src/AddIns/BackendBindings/AspNet.Mvc/Test/Src/CodeTemplates/RazorCSharpCreateViewTemplateTests.cs
@@ -0,0 +1,170 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using AspNet.Mvc.Tests.CodeTemplates.Models;
+using AspNet.Mvc.Tests.Helpers;
+using ICSharpCode.AspNet.Mvc.CSHtml;
+using NUnit.Framework;
+
+namespace AspNet.Mvc.Tests.CodeTemplates
+{
+ [TestFixture]
+ public class RazorCSharpCreateViewTemplateTests
+ {
+ Create templatePreprocessor;
+ TestableMvcTextTemplateHost mvcHost;
+
+ void CreateViewTemplatePreprocessor()
+ {
+ mvcHost = new TestableMvcTextTemplateHost();
+ templatePreprocessor = new Create();
+ templatePreprocessor.Host = mvcHost;
+ }
+
+ [Test]
+ public void GetModelDirective_HostViewDataTypeNameIsMyAppMyModel_ReturnsRazorModelFollowedByMyAppMyModel()
+ {
+ CreateViewTemplatePreprocessor();
+ mvcHost.ViewDataTypeName = "MyApp.MyModel";
+
+ string modelDirective = templatePreprocessor.GetModelDirective();
+
+ Assert.AreEqual("@model MyApp.MyModel", modelDirective);
+ }
+
+ [Test]
+ public void GetModelDirective_HostViewDataTypeNameIsNull_ReturnsEmptyString()
+ {
+ CreateViewTemplatePreprocessor();
+ mvcHost.ViewDataTypeName = null;
+
+ string modelDirective = templatePreprocessor.GetModelDirective();
+
+ Assert.AreEqual(String.Empty, modelDirective);
+ }
+
+ [Test]
+ public void GetModelDirective_HostViewDataTypeNameIsEmptyString_ReturnsEmptyString()
+ {
+ CreateViewTemplatePreprocessor();
+ mvcHost.ViewDataTypeName = String.Empty;
+
+ string modelDirective = templatePreprocessor.GetModelDirective();
+
+ Assert.AreEqual(String.Empty, modelDirective);
+ }
+
+ [Test]
+ public void TransformText_ModelHasNoPropertiesAndNoMasterPage_ReturnsFullHtmlPageWithFormAndFieldSetForModel()
+ {
+ CreateViewTemplatePreprocessor();
+ Type modelType = typeof(ModelWithNoProperties);
+ mvcHost.ViewDataType = modelType;
+ mvcHost.ViewDataTypeName = modelType.FullName;
+ mvcHost.ViewName = "MyView";
+
+ string output = templatePreprocessor.TransformText();
+
+ string expectedOutput =
+@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithNoProperties
+
+<!DOCTYPE html>
+<html>
+ <head runat=""server"">
+ <title>MyView</title>
+ </head>
+ <body>
+ @using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+ <fieldset>
+ <legend>ModelWithNoProperties</legend>
+
+ <p>
+ <input type=""submit"" value=""Create""/>
+ </p>
+ </fieldset>
+ }
+ <div>
+ @Html.ActionLink(""Back"", ""Index"")
+ </div>
+ </body>
+</html>
+";
+ Assert.AreEqual(expectedOutput, output);
+ }
+
+ [Test]
+ public void TransformText_ModelHasNoPropertiesAndIsPartialView_ReturnsControlWithFormAndFieldSetForModel()
+ {
+ CreateViewTemplatePreprocessor();
+ mvcHost.IsPartialView = true;
+ Type modelType = typeof(ModelWithNoProperties);
+ mvcHost.ViewDataType = modelType;
+ mvcHost.ViewDataTypeName = modelType.FullName;
+ mvcHost.ViewName = "MyView";
+
+ string output = templatePreprocessor.TransformText();
+
+ string expectedOutput =
+@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithNoProperties
+
+@using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+ <fieldset>
+ <legend>ModelWithNoProperties</legend>
+
+ <p>
+ <input type=""submit"" value=""Create""/>
+ </p>
+ </fieldset>
+}
+<div>
+ @Html.ActionLink(""Back"", ""Index"")
+</div>
+";
+ Assert.AreEqual(expectedOutput, output);
+ }
+
+ [Test]
+ public void TransformText_ModelHasNoPropertiesAndIsContentPage_ReturnsContentPageWithFormAndFieldSetForModel()
+ {
+ CreateViewTemplatePreprocessor();
+ mvcHost.IsContentPage = true;
+ Type modelType = typeof(ModelWithNoProperties);
+ mvcHost.ViewDataType = modelType;
+ mvcHost.ViewDataTypeName = modelType.FullName;
+ mvcHost.ViewName = "MyView";
+ mvcHost.MasterPageFile = "~/Views/Shared/Site.master";
+ mvcHost.PrimaryContentPlaceHolderID = "Main";
+
+ string output = templatePreprocessor.TransformText();
+
+ string expectedOutput =
+@"@model AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithNoProperties
+
+@{
+ ViewBag.Title = ""MyView"";
+ Layout = ""~/Views/Shared/Site.master"";
+}
+
+<h2>MyView</h2>
+
+@using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+ <fieldset>
+ <legend>ModelWithNoProperties</legend>
+
+ <p>
+ <input type=""submit"" value=""Create""/>
+ </p>
+ </fieldset>
+}
+<div>
+ @Html.ActionLink(""Back"", ""Index"")
+</div>
+";
+ Assert.AreEqual(expectedOutput, output);
+ }
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.