10 changed files with 1496 additions and 0 deletions
@ -0,0 +1,451 @@
@@ -0,0 +1,451 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <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.AspxCSharp { |
||||
using ICSharpCode.AspNet.Mvc; |
||||
using System; |
||||
|
||||
|
||||
public partial class Edit : EditBase { |
||||
|
||||
private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue; |
||||
|
||||
|
||||
#line 57 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
|
||||
MvcTextTemplateHost MvcHost { |
||||
get { return (MvcTextTemplateHost)Host; } |
||||
} |
||||
|
||||
public string GetViewPageType() |
||||
{ |
||||
string viewDataTypeName = MvcHost.ViewDataTypeName; |
||||
if (!String.IsNullOrEmpty(viewDataTypeName)) { |
||||
return String.Format("<{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 3 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
if (MvcHost.IsPartialView) { |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("<%@ Control Language=\"C#\" Inherits=\"System.Web.Mvc.ViewUserControl"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( GetViewPageType() )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.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\AspxCSharp\Edit.tt"
|
||||
} else if (MvcHost.IsContentPage) { |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("<%@ Page Language=\"C#\" MasterPageFile=\""); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.MasterPageFile )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\" Inherits=\"System.Web.Mvc.ViewPage"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( GetViewPageType() )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\" %>\r\n\r\n<asp:Content ID=\"Content1\" ContentPlaceHolderID=\"Title\" runat=\"server\">\r\n" + |
||||
""); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 10 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewName )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 10 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\r\n</asp:Content>\r\n\r\n<asp:Content ID=\"Content2\" ContentPlaceHolderID=\""); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 13 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.PrimaryContentPlaceHolderID )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 13 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\" runat=\"server\">\r\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 14 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
|
||||
PushIndent("\t"); |
||||
} else { |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("<%@ Page Language=\"C#\" Inherits=\"System.Web.Mvc.ViewPage"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( GetViewPageType() )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\" %>\r\n\r\n<!DOCTYPE html>\r\n<html>\r\n\t<head runat=\"server\">\r\n\t\t<title>"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewName )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("</title>\r\n\t</head>\r\n\t<body>\r\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 26 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
|
||||
PushIndent("\t\t"); |
||||
} |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 30 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("<% using (Html.BeginForm()) { %>\r\n\t<%: Html.ValidationSummary(true) %>\r\n\t<fieldse" + |
||||
"t>\r\n\t\t<legend>"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 33 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write(this.ToStringHelper.ToStringWithCulture( MvcHost.ViewDataType.Name )); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 33 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("</legend>\r\n\t\t\r\n\t\t<p>\r\n\t\t\t<input type=\"submit\" value=\"Save\"/>\r\n\t\t</p>\r\n\t</fieldset" + |
||||
">\r\n<% } %>\r\n<div>\r\n\t<%: Html.ActionLink(\"Back\", \"Index\") %>\r\n</div>\r\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 43 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
|
||||
if (MvcHost.IsPartialView) { |
||||
// Do nothing.
|
||||
} else if (MvcHost.IsContentPage) { |
||||
PopIndent(); |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 49 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("</asp:Content>\r\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 50 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
|
||||
} else { |
||||
PopIndent(); |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 54 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
this.Write("\t</body>\r\n</html>\r\n"); |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 56 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\AspxCSharp\Edit.tt"
|
||||
} |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return this.GenerationEnvironment.ToString(); |
||||
} |
||||
|
||||
protected virtual void Initialize() { |
||||
} |
||||
} |
||||
|
||||
public class EditBase { |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,70 @@
@@ -0,0 +1,70 @@
|
||||
<#@ template language="C#" HostSpecific="true" #> |
||||
<#@ import namespace="ICSharpCode.AspNet.Mvc" #> |
||||
<# if (MvcHost.IsPartialView) { #> |
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<#= GetViewPageType() #>" %> |
||||
|
||||
<# } else if (MvcHost.IsContentPage) { #> |
||||
<%@ Page Language="C#" 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("\t"); |
||||
} else { |
||||
#> |
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<#= GetViewPageType() #>" %> |
||||
|
||||
<!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="Save"/> |
||||
</p> |
||||
</fieldset> |
||||
<% } %> |
||||
<div> |
||||
<%: Html.ActionLink("Back", "Index") %> |
||||
</div> |
||||
<# |
||||
if (MvcHost.IsPartialView) { |
||||
// Do nothing. |
||||
} else if (MvcHost.IsContentPage) { |
||||
PopIndent(); |
||||
#> |
||||
</asp:Content> |
||||
<# |
||||
} else { |
||||
PopIndent(); |
||||
#> |
||||
</body> |
||||
</html> |
||||
<# } #> |
||||
<#+ |
||||
MvcTextTemplateHost MvcHost { |
||||
get { return (MvcTextTemplateHost)Host; } |
||||
} |
||||
|
||||
public string GetViewPageType() |
||||
{ |
||||
string viewDataTypeName = MvcHost.ViewDataTypeName; |
||||
if (!String.IsNullOrEmpty(viewDataTypeName)) { |
||||
return String.Format("<{0}>", viewDataTypeName); |
||||
} |
||||
return String.Empty; |
||||
} |
||||
#> |
@ -0,0 +1,402 @@
@@ -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 Edit : EditBase { |
||||
|
||||
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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.tt"
|
||||
|
||||
} else { |
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 21 "D:\projects\dotnet\SharpDevelop.AspNetMvc\src\AddIns\BackendBindings\AspNet.Mvc\Project\ItemTemplates\CSharp\CodeTemplates\AddView\CSHTML\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.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\Edit.tt"
|
||||
this.Write("</legend>\r\n\t\t\r\n\t\t<p>\r\n\t\t\t<input type=\"submit\" value=\"Save\"/>\r\n\t\t</p>\r\n\t</fieldset" + |
||||
">\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\Edit.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\Edit.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\Edit.tt"
|
||||
} |
||||
|
||||
#line default
|
||||
#line hidden
|
||||
return this.GenerationEnvironment.ToString(); |
||||
} |
||||
|
||||
protected virtual void Initialize() { |
||||
} |
||||
} |
||||
|
||||
public class EditBase { |
||||
|
||||
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(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,66 @@
@@ -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="Save"/> |
||||
</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; |
||||
} |
||||
#> |
@ -0,0 +1,72 @@
@@ -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="Save"/> |
||||
</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 |
||||
#> |
@ -0,0 +1,68 @@
@@ -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="Save"/> |
||||
</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 |
||||
#> |
@ -0,0 +1,169 @@
@@ -0,0 +1,169 @@
|
||||
// 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.AspxCSharp; |
||||
using NUnit.Framework; |
||||
|
||||
namespace AspNet.Mvc.Tests.CodeTemplates |
||||
{ |
||||
[TestFixture] |
||||
public class AspxCSharpEditViewTemplateTests |
||||
{ |
||||
Edit templatePreprocessor; |
||||
TestableMvcTextTemplateHost mvcHost; |
||||
|
||||
void CreateViewTemplatePreprocessor() |
||||
{ |
||||
mvcHost = new TestableMvcTextTemplateHost(); |
||||
templatePreprocessor = new Edit(); |
||||
templatePreprocessor.Host = mvcHost; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetViewPageType_HostViewDataTypeNameIsMyAppMyModel_ReturnsMyAppMyModelSurroundedByAngleBrackets() |
||||
{ |
||||
CreateViewTemplatePreprocessor(); |
||||
mvcHost.ViewDataTypeName = "MyApp.MyModel"; |
||||
|
||||
string viewPageType = templatePreprocessor.GetViewPageType(); |
||||
|
||||
Assert.AreEqual("<MyApp.MyModel>", viewPageType); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetViewPageType_HostViewDataTypeNameIsNull_ReturnsEmptyString() |
||||
{ |
||||
CreateViewTemplatePreprocessor(); |
||||
mvcHost.ViewDataTypeName = null; |
||||
|
||||
string viewPageType = templatePreprocessor.GetViewPageType(); |
||||
|
||||
Assert.AreEqual(String.Empty, viewPageType); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetViewPageType_HostViewDataTypeNameIsEmptyString_ReturnsEmptyString() |
||||
{ |
||||
CreateViewTemplatePreprocessor(); |
||||
mvcHost.ViewDataTypeName = String.Empty; |
||||
|
||||
string viewPageType = templatePreprocessor.GetViewPageType(); |
||||
|
||||
Assert.AreEqual(String.Empty, viewPageType); |
||||
} |
||||
|
||||
[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 = |
||||
@"<%@ Page Language=""C#"" Inherits=""System.Web.Mvc.ViewPage<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=""Save""/> |
||||
</p> |
||||
</fieldset> |
||||
<% } %> |
||||
<div> |
||||
<%: Html.ActionLink(""Back"", ""Index"") %> |
||||
</div> |
||||
</body> |
||||
</html> |
||||
";
|
||||
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 = |
||||
@"<%@ Page Language=""C#"" MasterPageFile=""~/Views/Shared/Site.master"" Inherits=""System.Web.Mvc.ViewPage<AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithNoProperties>"" %>
|
||||
|
||||
<asp:Content ID=""Content1"" ContentPlaceHolderID=""Title"" runat=""server""> |
||||
MyView |
||||
</asp:Content> |
||||
|
||||
<asp:Content ID=""Content2"" ContentPlaceHolderID=""Main"" runat=""server""> |
||||
<% using (Html.BeginForm()) { %> |
||||
<%: Html.ValidationSummary(true) %> |
||||
<fieldset> |
||||
<legend>ModelWithNoProperties</legend> |
||||
|
||||
<p> |
||||
<input type=""submit"" value=""Save""/> |
||||
</p> |
||||
</fieldset> |
||||
<% } %> |
||||
<div> |
||||
<%: Html.ActionLink(""Back"", ""Index"") %> |
||||
</div> |
||||
</asp:Content> |
||||
";
|
||||
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 = |
||||
@"<%@ Control Language=""C#"" Inherits=""System.Web.Mvc.ViewUserControl<AspNet.Mvc.Tests.CodeTemplates.Models.ModelWithNoProperties>"" %>
|
||||
|
||||
<% using (Html.BeginForm()) { %> |
||||
<%: Html.ValidationSummary(true) %> |
||||
<fieldset> |
||||
<legend>ModelWithNoProperties</legend> |
||||
|
||||
<p> |
||||
<input type=""submit"" value=""Save""/> |
||||
</p> |
||||
</fieldset> |
||||
<% } %> |
||||
<div> |
||||
<%: Html.ActionLink(""Back"", ""Index"") %> |
||||
</div> |
||||
";
|
||||
Assert.AreEqual(expectedOutput, output); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,170 @@
@@ -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 RazorCSharpEditViewTemplateTests |
||||
{ |
||||
Edit templatePreprocessor; |
||||
TestableMvcTextTemplateHost mvcHost; |
||||
|
||||
void CreateViewTemplatePreprocessor() |
||||
{ |
||||
mvcHost = new TestableMvcTextTemplateHost(); |
||||
templatePreprocessor = new Edit(); |
||||
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=""Save""/> |
||||
</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=""Save""/> |
||||
</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=""Save""/> |
||||
</p> |
||||
</fieldset> |
||||
} |
||||
<div> |
||||
@Html.ActionLink(""Back"", ""Index"") |
||||
</div> |
||||
";
|
||||
Assert.AreEqual(expectedOutput, output); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue