updated SpringAir 2005 with master page DI demo
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>.</OutputPath>
|
||||
<OutputPath>./bin</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
<div id="copyright">
|
||||
<img class="divider" src="<%= Page.ImagesRoot %>/line.jpg" alt="" width="500" height="1"/>
|
||||
<br/>
|
||||
© Copyright 2005-2006, <a href="http://www.springframework.net/" title="Spring.NET Framework">
|
||||
Spring.NET</a>, under the terms of the Apache 2.0 software license
|
||||
license.
|
||||
<%= CopyrightText %>
|
||||
<br/>
|
||||
|
||||
<asp:LinkButton ID="english" Runat="server" CommandArgument="en-US" CausesValidation="False">English</asp:LinkButton>
|
||||
|
||||
@@ -32,82 +32,96 @@ using Spring.Web.UI;
|
||||
/// SpringAir2 master page.
|
||||
/// </summary>
|
||||
/// <author>Aleksandar Seovic</author>
|
||||
/// <version>$Id: StandardTemplate.master.cs,v 1.2 2007/05/28 19:07:12 markpollack Exp $</version>
|
||||
public partial class StandardTemplate : MasterPage
|
||||
{
|
||||
private static bool lookupInitialized = false;
|
||||
private static bool needsTranslaction = false;
|
||||
#region Culture Support
|
||||
|
||||
private void SetLanguage(object sender, CommandEventArgs e)
|
||||
{
|
||||
string cultureString = e.CommandArgument as string;
|
||||
if (cultureString != null)
|
||||
{
|
||||
UserCulture = new CultureInfo(TranslateCultureIfNecessary(cultureString));
|
||||
}
|
||||
}
|
||||
private static bool lookupInitialized = false;
|
||||
private static bool needsTranslation = false;
|
||||
|
||||
/// <summary>
|
||||
/// Translates the culture if necessary due to changes in Serbian culture for recent
|
||||
/// .NET 2.0 releases.
|
||||
/// </summary>
|
||||
/// <remarks>If 'sr-Latn-CS' is a valid culture, then translate the following;
|
||||
/// sr-SP-Latn->sr-Latn-CS and sr-SP-Cyrl->sr-Cyrl-CS. See
|
||||
/// http://blogs.msdn.com/kierans/archive/2006/08/02/687267.aspx
|
||||
/// and http://blogs.msdn.com/shawnste/archive/2006/11/14/problems-compiling-resources-in-net-2-0-apps-after-updates.aspx
|
||||
/// for additional information.</remarks>
|
||||
/// <param name="cultureString">The culture string.</param>
|
||||
/// <returns>Translated culture string if necessary.</returns>
|
||||
private string TranslateCultureIfNecessary(string cultureString)
|
||||
/// <summary>
|
||||
/// Translates the culture if necessary due to changes in Serbian culture for recent
|
||||
/// .NET 2.0 releases.
|
||||
/// </summary>
|
||||
/// <remarks>If 'sr-Latn-CS' is a valid culture, then translate the following;
|
||||
/// sr-SP-Latn->sr-Latn-CS and sr-SP-Cyrl->sr-Cyrl-CS. See
|
||||
/// http://blogs.msdn.com/kierans/archive/2006/08/02/687267.aspx
|
||||
/// and http://blogs.msdn.com/shawnste/archive/2006/11/14/problems-compiling-resources-in-net-2-0-apps-after-updates.aspx
|
||||
/// for additional information.</remarks>
|
||||
/// <param name="cultureString">The culture string.</param>
|
||||
/// <returns>Translated culture string if necessary.</returns>
|
||||
private static string TranslateCultureIfNecessary(string cultureString)
|
||||
{
|
||||
if (!lookupInitialized)
|
||||
{
|
||||
lock (typeof(StandardTemplate))
|
||||
{
|
||||
if (!lookupInitialized)
|
||||
{
|
||||
lock(typeof(StandardTemplate))
|
||||
lookupInitialized = true;
|
||||
//TODO maybe check .NET 2.0 build # instead.
|
||||
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
|
||||
{
|
||||
if (ci.Name.Equals("sr-Latn-CS"))
|
||||
{
|
||||
lookupInitialized = true;
|
||||
//TODO maybe check .NET 2.0 build # instead.
|
||||
foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
|
||||
{
|
||||
if (ci.Name.Equals("sr-Latn-CS"))
|
||||
{
|
||||
needsTranslaction = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
needsTranslation = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needsTranslaction)
|
||||
{
|
||||
if (cultureString.Equals("sr-SP-Latn"))
|
||||
{
|
||||
return "sr-Latn-CS";
|
||||
}
|
||||
else if (cultureString.Equals("sr-SP-Cyrl"))
|
||||
{
|
||||
return "sr-Cyrl-CS";
|
||||
}
|
||||
}
|
||||
|
||||
return cultureString;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region Web Form Designer generated code
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
if (needsTranslation)
|
||||
{
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
if (cultureString.Equals("sr-SP-Latn"))
|
||||
{
|
||||
return "sr-Latn-CS";
|
||||
}
|
||||
else if (cultureString.Equals("sr-SP-Cyrl"))
|
||||
{
|
||||
return "sr-Cyrl-CS";
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
return cultureString;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
// this is to demonstrate DI on master pages
|
||||
private string copyrightText;
|
||||
public string CopyrightText
|
||||
{
|
||||
get { return copyrightText; }
|
||||
set { copyrightText = value; }
|
||||
}
|
||||
|
||||
private void SetLanguage(object sender, CommandEventArgs e)
|
||||
{
|
||||
string cultureString = e.CommandArgument as string;
|
||||
if (cultureString != null)
|
||||
{
|
||||
this.english.Command += new CommandEventHandler(this.SetLanguage);
|
||||
this.serbianLatin.Command += new CommandEventHandler(this.SetLanguage);
|
||||
this.serbianCyrillic.Command += new CommandEventHandler(this.SetLanguage);
|
||||
UserCulture = new CultureInfo(TranslateCultureIfNecessary(cultureString));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Web Form Designer generated code
|
||||
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
InitializeComponent();
|
||||
base.OnInit(e);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.english.Command += new CommandEventHandler(this.SetLanguage);
|
||||
this.serbianLatin.Command += new CommandEventHandler(this.SetLanguage);
|
||||
this.serbianCyrillic.Command += new CommandEventHandler(this.SetLanguage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -7,6 +7,16 @@
|
||||
|
||||
<object type="Home.aspx" parent="standardPage"/>
|
||||
|
||||
<object type="StandardTemplate.master">
|
||||
<property name="CopyrightText">
|
||||
<value><![CDATA[© Copyright 2005-2006, <a href="http://www.springframework.net/" title="Spring.NET Framework">
|
||||
Spring.NET</a>, under the terms of the Apache 2.0 software license
|
||||
license.
|
||||
]]>
|
||||
</value>
|
||||
</property>
|
||||
</object>
|
||||
|
||||
</objects>
|
||||
</spring>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user