Initial import!

This commit is contained in:
markpollack
2008-05-30 22:55:02 +00:00
commit c478a783c0
2978 changed files with 510966 additions and 0 deletions

View File

@@ -0,0 +1,143 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "D:\...\Spring.WebQuickStart.2005\", "src\Spring.WebQuickStart.2005\", "{B4F56253-6425-4065-8A93-EF88F8730E57}"
ProjectSection(WebsiteProperties) = preProject
ProjectReferences = "{BA4789EB-281A-48EA-8763-28B9F0596A18}|Spring.Web.dll;"
Debug.AspNetCompiler.VirtualPath = "/Spring.WebQuickStart.2005"
Debug.AspNetCompiler.PhysicalPath = "Spring.WebQuickStart.2005\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\Spring.WebQuickStart.2005\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/Spring.WebQuickStart.2005"
Release.AspNetCompiler.PhysicalPath = "Spring.WebQuickStart.2005\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\Spring.WebQuickStart.2005\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "4112"
DefaultWebSiteLanguage = "Visual C#"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.2005", "..\..\..\src\Spring\Spring.Web\Spring.Web.2005.csproj", "{BA4789EB-281A-48EA-8763-28B9F0596A18}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.2005", "..\..\..\src\Spring\Spring.Core\Spring.Core.2005.csproj", "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Core.Tests.2005", "..\..\..\test\Spring\Spring.Core.Tests\Spring.Core.Tests.2005.csproj", "{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "D:\...\Spring.WebQuickStart.Providers\", "src\Spring.WebQuickStart.Providers\", "{F42A333D-D305-4649-8B5A-6F5862F0F62A}"
ProjectSection(WebsiteProperties) = preProject
ProjectReferences = "{710961A3-0DF4-49E4-A26E-F5B9C044AC84}|Spring.Core.dll;{BA4789EB-281A-48EA-8763-28B9F0596A18}|Spring.Web.dll;"
Debug.AspNetCompiler.VirtualPath = "/Spring.WebQuickStart.Providers"
Debug.AspNetCompiler.PhysicalPath = "src\Spring.WebQuickStart.Providers\"
Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\Spring.WebQuickStart.Providers\"
Debug.AspNetCompiler.Updateable = "true"
Debug.AspNetCompiler.ForceOverwrite = "true"
Debug.AspNetCompiler.FixedNames = "false"
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.VirtualPath = "/Spring.WebQuickStart.Providers"
Release.AspNetCompiler.PhysicalPath = "src\Spring.WebQuickStart.Providers\"
Release.AspNetCompiler.TargetPath = "PrecompiledWeb\Spring.WebQuickStart.Providers\"
Release.AspNetCompiler.Updateable = "true"
Release.AspNetCompiler.ForceOverwrite = "true"
Release.AspNetCompiler.FixedNames = "false"
Release.AspNetCompiler.Debug = "False"
VWDPort = "4828"
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spring.Web.Tests.2005", "..\..\..\test\Spring\Spring.Web.Tests\Spring.Web.Tests.2005.csproj", "{C67E47AA-1ACD-41B4-A465-4D336A2319CA}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.Debug = "True"
Release.AspNetCompiler.Debug = "False"
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|.NET = Debug|.NET
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Release|.NET = Release|.NET
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B4F56253-6425-4065-8A93-EF88F8730E57}.Debug|.NET.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Debug|.NET.Build.0 = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Debug|Any CPU.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Debug|Mixed Platforms.Build.0 = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Release|.NET.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Release|.NET.Build.0 = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Release|Any CPU.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Release|Mixed Platforms.ActiveCfg = Debug|.NET
{B4F56253-6425-4065-8A93-EF88F8730E57}.Release|Mixed Platforms.Build.0 = Debug|.NET
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Debug|.NET.ActiveCfg = Debug|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Release|.NET.ActiveCfg = Release|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Release|Any CPU.Build.0 = Release|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{BA4789EB-281A-48EA-8763-28B9F0596A18}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|.NET.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Any CPU.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|.NET.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Any CPU.Build.0 = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{710961A3-0DF4-49E4-A26E-F5B9C044AC84}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|.NET.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|.NET.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Any CPU.Build.0 = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{44B16BAA-6DF8-447C-9D7F-3AD3D854D904}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Debug|.NET.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Debug|.NET.Build.0 = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Debug|Any CPU.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Debug|Mixed Platforms.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Debug|Mixed Platforms.Build.0 = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Release|.NET.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Release|.NET.Build.0 = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Release|Any CPU.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Release|Mixed Platforms.ActiveCfg = Debug|.NET
{F42A333D-D305-4649-8B5A-6F5862F0F62A}.Release|Mixed Platforms.Build.0 = Debug|.NET
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Debug|.NET.ActiveCfg = Debug|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Release|.NET.ActiveCfg = Release|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Release|Any CPU.Build.0 = Release|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C67E47AA-1ACD-41B4-A465-4D336A2319CA}.Release|Mixed Platforms.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,167 @@
using System;
using System.Collections;
/// <summary>
/// EmployeeInfo domain class
/// </summary>
public class EmployeeInfo
{
private int id;
private string firstName;
private string lastName;
private DateTime dateOfBirth;
private Gender gender = Gender.Male;
private AddressInfo mailingAddress = new AddressInfo();
private double salary;
private ArrayList _hobbies = new ArrayList();
private ArrayList _favoriteFood = new ArrayList();
public EmployeeInfo()
{}
public int Id
{
get { return id; }
set { id = value; }
}
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public DateTime DateOfBirth
{
get { return dateOfBirth; }
set { dateOfBirth = value; }
}
public Gender Gender
{
get { return gender; }
set { gender = value; }
}
public AddressInfo MailingAddress
{
get { return mailingAddress; }
set { mailingAddress = value; }
}
public double Salary
{
get { return salary; }
set { salary = value; }
}
public IList Hobbies
{
get { return this._hobbies; }
set { this._hobbies = (value != null) ? new ArrayList(value) : null; }
}
public IList FavoriteFood
{
get { return this._favoriteFood; }
set { this._favoriteFood = (value != null) ? new ArrayList(value) : null; }
}
}
public enum Gender
{
Male,
Female
}
public class AddressInfo
{
private AddressType addressType;
private string street1;
private string street2;
private string city;
private string state;
private string postalCode;
private string country;
public AddressType AddressType
{
get { return addressType; }
set { addressType = value; }
}
public string Street1
{
get { return street1; }
set { street1 = value; }
}
public string Street2
{
get { return street2; }
set { street2 = value; }
}
public string City
{
get { return city; }
set { city = value; }
}
public string State
{
get { return state; }
set { state = value; }
}
public string PostalCode
{
get { return postalCode; }
set { postalCode = value; }
}
public string Country
{
get { return country; }
set { country = value; }
}
}
public enum AddressType
{
Home,
Office
}
public class Hobby
{
private string _uniqueKey;
private string _title;
public Hobby(string uniqueKey, string title)
{
this._uniqueKey = uniqueKey;
this._title = title;
}
public string UniqueKey
{
get { return this._uniqueKey; }
}
public string Title
{
get { return this._title; }
}
public override string ToString()
{
return this._uniqueKey;
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Web;
/// <summary>
/// Summary description for CustomModule
/// </summary>
public class HtmlCommentAppenderModule : IHttpModule
{
private string appendText;
public HtmlCommentAppenderModule()
{
}
public string AppendText
{
get { return this.appendText; }
set { this.appendText = value; }
}
public void Init(HttpApplication application)
{
application.PostRequestHandlerExecute += new System.EventHandler(application_PostRequestHandlerExecute);
}
void application_PostRequestHandlerExecute(object sender, System.EventArgs e)
{
((HttpApplication)sender).Context.Response.Write( string.Format( "{0}<!-- {1} -->", Environment.NewLine, appendText ) );
}
public void Dispose()
{
}
}

View File

@@ -0,0 +1,37 @@
/// <summary>
/// Summary description for ProductInfo
/// </summary>
public class ProductInfo
{
private string sku;
private string name;
private int quantity;
private double price;
public ProductInfo()
{}
public string Sku
{
get { return sku; }
set { sku = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public int Quantity
{
get { return quantity; }
set { quantity = value; }
}
public double Price
{
get { return price; }
set { price = value; }
}
}

View File

@@ -0,0 +1,22 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DI_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Spring.NET Web Framework Quick Start Guide - Dependency Injection</title>
</head>
<body>
<h2><a href="../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<div>
<h2>Dependency Injection</h2>
<p>
Samples in this section demonstrate, how dependency injection is done in web projects.
</p>
<h3><a href="HelloWorld/Default.aspx">Hello World!</a></h3>
<p>The inevitable "Hello World!" example demonstrates DI for pages, usercontrols and webcontrols</p>
<h3><a href="NestedContexts/Default.aspx">Nested Contexts</a></h3>
<p>This sample shows, how contexts are nested in webapplications</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,18 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DI_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,19 @@
<%@ Control Language="C#" EnableViewState="false" AutoEventWireup="false" CodeFile="CustomControl.ascx.cs" Inherits="DI_HelloWorld_CustomControl" %>
<p>
The message you can see below has been injected by &lt;object type="CustomControl.ascx"&gt; object definition:
</p>
<p>
'<%=AnotherMessage%>'
</p>
<p>
The TextBox below has been filled in by typename using the &lt;object name="System.Web.UI.WebControls.TextBox"&gt; object definition:
</p>
<p><asp:TextBox runat="server" id="myTextBox"/></p>
<p>
Use a spring:Panel to selectively enable/disable automatic dependency injection:
</p>
<spring:Panel runat="server" ID="diContainer" suppressDependencyInjection="true" renderContainerTag="false">
<asp:TextBox runat="server" id="TextBox2"/>
</spring:Panel>

View File

@@ -0,0 +1,29 @@
using System;
/// <summary>
/// Notice that you don't need to extend Spring.Web.UI.UserControl for DI features!
/// </summary>
public partial class DI_HelloWorld_CustomControl : System.Web.UI.UserControl
{
private string anotherMessage;
public string AnotherMessage
{
get { return this.anotherMessage; }
set { this.anotherMessage = value; }
}
/// <summary>
/// Values are injected right before OnInit() is called.
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
if (this.AnotherMessage == null)
{
throw new ArgumentNullException("AnotherMessage");
}
base.OnInit(e);
}
}

View File

@@ -0,0 +1,30 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DI_HelloWorld_Default" %>
<%@ Register TagPrefix="ctl" TagName="CustomControl" src="CustomControl.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title><%=Title%></title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Dependency Injection</a></h2>
<div>
<h2>Hello World example</h2>
<form id="form1" runat="server">
<p>
This very simple web form demonstrates dependency injection on pages and controls.
</p>
<p>
The message you can see below has been injected by &lt;object type="Default.aspx"&gt; object definition:
</p>
<p>
'<%=Message%>'
</p>
<p>
<ctl:CustomControl runat="server" ID="myCustomControl" />
</p>
</form>
</div>
</body>
</html>

View File

@@ -0,0 +1,30 @@
using System;
using System.Web.UI;
/// <summary>
/// Notice that you don't need to extend Spring.Web.UI.Page for DI features!
/// </summary>
public partial class DI_HelloWorld_Default : System.Web.UI.Page
{
private string message;
public string Message
{
get { return this.message; }
set { this.message = value; }
}
/// <summary>
/// Values are injected right before OnInit() is called.
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
if(this.Message == null)
{
throw new ArgumentNullException("Message");
}
base.OnInit(e);
}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- use the filename of your Page for the 'type' attribute to configure DI for a Page -->
<object type="Default.aspx">
<property name="Title" value="Dependency Injection - Hello World Sample"/>
<property name="Message">
<value>This very simple page demonstrates how to inject dependencies into a Page.</value>
</property>
</object>
<!-- use the filename of your UserControl for the 'type' attribute to configure DI for a UserControl -->
<object type="CustomControl.ascx">
<property name="AnotherMessage" value="This very simple control demonstrates how to inject dependencies into a UserControl."/>
</object>
<!-- use the typename as name to configure DI for any non-UserControl (Note: this will configure *all* TextBoxes!) -->
<object name="System.Web.UI.WebControls.TextBox" abstract="true">
<property name="Text" value="initial text" />
</object>
</objects>
</spring>
<system.web>
</system.web>
</configuration>

View File

@@ -0,0 +1,3 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="DI_NestedContexts_ContextA_CustomControl" %>
<p><i><%=Message%></i></p>

View File

@@ -0,0 +1,12 @@
using System;
public partial class DI_NestedContexts_ContextA_CustomControl : System.Web.UI.UserControl
{
private string _message;
public string Message
{
get { return this._message; }
set { this._message = value; }
}
}

View File

@@ -0,0 +1,3 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="DI_NestedContexts_ContextB_CustomControlB" %>
<p><i><%=Message%></i></p>

View File

@@ -0,0 +1,11 @@
public partial class DI_NestedContexts_ContextB_CustomControlB : System.Web.UI.UserControl
{
private string _message;
public string Message
{
get { return this._message; }
set { this._message = value; }
}
}

View File

@@ -0,0 +1,22 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DI_NestedContexts_ContextB_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Object definition inheritance example</title>
</head>
<body>
<form id="form1" runat="server">
<p>
<i><%=Message%></i>
</p>
<p>
Below you can see the message from the definition 'GlobalMessage' that is inherited within this child context:
</p>
<p>
<i><%=GlobalMessage%></i>
</p>
</form>
</body>
</html>

View File

@@ -0,0 +1,18 @@
public partial class DI_NestedContexts_ContextB_Default : System.Web.UI.Page
{
private string _message;
private string _globalMessage;
public string Message
{
get { return this._message; }
set { this._message = value; }
}
public string GlobalMessage
{
get { return this._globalMessage; }
set { this._globalMessage = value; }
}
}

View File

@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- "local" object definition of a control - overrides definition from the page's context! -->
<object type="CustomControl.ascx">
<property name="Message" value="This is the overridden message from ControlB"/>
</object>
<!--
Note that the definition below does *not* hide "Default.aspx" from the parent context because
internally page definitions are stored by their virtual path
-->
<object type="Default.aspx">
<property name="Message" value="This is ContextB's page message!" />
<property name="GlobalMessage" ref="GlobalMessage" /> <!-- 'GlobalMessage' is inherited from the parent context -->
</object>
</objects>
</spring>
</configuration>

View File

@@ -0,0 +1,36 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DI_NestedContexts_Default" %>
<%@ Register TagPrefix="ctl" TagName="ControlA" src="ContextA/CustomControl.ascx" %>
<%@ Register TagPrefix="ctl" TagName="ControlB" src="ContextB/CustomControl.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dependency Injection - Nested Contexts example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Dependency Injection</a></h2>
<div>
<h2>Nested Contexts example</h2>
<form id="form1" runat="server">
<p>
This sample illustrates nesting of contexts.
</p>
<p>
Control "A" below demonstrates configuring a control within the page's context:
</p>
<p>
<ctl:ControlA runat="server" />
</p>
<p>
Control "B" below demonstrates configuring a control within the page's context,
but overriding the definition in the control's context.
</p>
<p>
<ctl:ControlB runat="server" />
</p>
</form>
</div>
</body>
</html>

View File

@@ -0,0 +1,18 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DI_NestedContexts_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object id="GlobalMessage" type="string">
<constructor-arg index="0" value="The GlobalMessage's content" />
</object>
<!-- Define control "A" in the page's context (the context that is effectively used to configure the .aspx) -->
<object type="ContextA/CustomControl.ascx">
<property name="Message" value="This is the original message from ControlA"/>
</object>
<!--
Note that the effective definition for ControlB is *not* defined here
because it is overridden in the web.config next to the control!
-->
<object type="ContextB/CustomControl.ascx">
<property name="Message" value="This is the original message from ControlB"/>
</object>
</objects>
</spring>
</configuration>

View File

@@ -0,0 +1,69 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_Collections_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - HttpRequestListBindingContainer example</title>
<script>
function addRow() {
var src = document.getElementById('itemTemplate');
var dst = document.getElementById('products');
dst.innerHTML += '<div>' + src.innerHTML + '</div>';
}
</script>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>HttpRequestListBindingContainer example</h2>
<p>
This form demonstrates unbinding data from HttpRequest.Form collection into a list model using HttpRequestListBindingContainer.
</p>
<p>
HttpRequestListBindingContainer extracts posted values from the request and populates the specified IList by creating objects
of the type specified and populating each of these objects according to the requestBindings collection.
</p>
<pre>
HttpRequestListBindingContainer requestBindings =
new HttpRequestListBindingContainer("sku,name,quantity,price", "Products", typeof(ProductInfo));
requestBindings.AddBinding("sku", "Sku");
requestBindings.AddBinding("name", "Name");
requestBindings.AddBinding("quantity", "Quantity", quantityFormatter);
requestBindings.AddBinding("price", "Price", priceFormatter);
</pre>
Edit List: <br />
<div id="products">
<table>
<tr><td>Firstname</td><td>Lastname</td><td>Quantity</td><td>Price/Item</td></tr>
<%
foreach (ProductInfo p in Products)
{
%>
<tr>
<td><input name="sku" type="text" value="<%= p.Sku %>" style="width: 50px;" /></td>
<td><input name="name" type="text" value="<%= p.Name %>" style="width: 150px;" /></td>
<td><input name="quantity" type="text" value="<%= QuantityFormatter.Format(p.Quantity) %>" style="width: 30px;" /></td>
<td><input name="price" type="text" value="<%= PriceFormatter.Format(p.Price) %>" style="width: 50px;" /></td>
</tr>
<%
}
%>
</table>
</div>
<asp:Button ID="btnAdd" Text="Add" runat="server" OnClick="btnAdd_Click" />
<asp:Button ID="btnSave" Text="Save" runat="server" OnClick="btnSave_Click" />
<button onclick="addRow();">Add row using javascript</button>
</div>
</form>
<div id="itemTemplate" style="display: none">
<input name="sku" type="text" value="" style="width: 50px;" />
<input name="name" type="text" value="" style="width: 150px;" />
<input name="quantity" type="text" value="0" style="width: 30px;" />
<input name="price" type="text" value="<%= PriceFormatter.Format(0) %>" style="width: 50px;" />
<br />
</div>
</body>
</html>

View File

@@ -0,0 +1,85 @@
using System;
using System.Collections;
using Spring.DataBinding;
using Spring.Globalization.Formatters;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_Collections_Default : Spring.Web.UI.Page
{
#region Fields
private IList products;
private readonly IntegerFormatter quantityFormatter = new IntegerFormatter();
private readonly CurrencyFormatter priceFormatter = new CurrencyFormatter();
#endregion
#region Properties
public IList Products
{
get { return products; }
}
public IntegerFormatter QuantityFormatter
{
get { return quantityFormatter; }
}
public CurrencyFormatter PriceFormatter
{
get { return priceFormatter; }
}
#endregion
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
// HttpRequestListBindingContainer unbinds specified values from Request -> Productlist
HttpRequestListBindingContainer requestBindings =
new HttpRequestListBindingContainer("sku,name,quantity,price", "Products", typeof(ProductInfo));
requestBindings.AddBinding("sku", "Sku");
requestBindings.AddBinding("name", "Name");
requestBindings.AddBinding("quantity", "Quantity", quantityFormatter);
requestBindings.AddBinding("price", "Price", priceFormatter);
BindingManager.AddBinding(requestBindings);
}
#region Model Management
protected override void InitializeModel()
{
products = new ArrayList();
}
protected override void LoadModel(object savedModel)
{
products = (IList) savedModel;
}
protected override object SaveModel()
{
return products;
}
#endregion
protected void btnAdd_Click(object sender, EventArgs e)
{
products.Add(new ProductInfo());
}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with products...
}
}

View File

@@ -0,0 +1,48 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Spring.NET Web Framework Quick Start Guide - Bi-directional DataBinding</title>
</head>
<body>
<h2><a href="../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<div>
<h2>Bi-directional DataBinding</h2>
<p>
Samples in this section demonstrate Spring.NET's capabilities of bi-directional
binding data between your model and form.
</p>
<h3><a href="HelloWorld/Default.aspx">Hello World</a></h3>
<p>
This very simple web form demonstrates basic bi-directional data binding.
</p>
<h3><a href="EventHandling/Default.aspx">Event Handling</a></h3>
<p>
This example builds on the previous one by adding postback event handler
that will convert the name to uppercase.
</p>
<h3><a href="Collections/Default.aspx">HttpRequestListBindingContainer</a></h3>
<p>
This example demonstrates unbinding data from request into a list using a HttpRequestListBindingContainer.
</p>
<h3><a href="EmployeeInfo/Default.aspx">Employee Info</a></h3>
<p>
Shows basics of bi-directional databinding with simple webcontrols (TextBox etc.)
</p>
<h3><a href="RobustEmployeeInfo/Default.aspx">Robust Employee Info</a></h3>
<p>
Demonstrates basic model validation capabilities
</p>
<h3><a href="Lists/Default.aspx">Lists</a></h3>
<p>
Demonstrates bi-directional binding of multi-selection listboxes
</p>
<h3><a href="EasyEmployeeInfo/Default.aspx">Easy Employee Info</a></h3>
<p>
Finally shows, how easy life can be when using a DataBindingPanel
</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,18 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class DataBinding_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,130 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_EasyEmployeeInfo_Default" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Easy Employee Info example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Easy Employee Info example</h2>
<p>
Now that you have an idea of how databinding works, here's the easy way using a DataBindingPanel.
</p>
<p>
By placing your controls within a DataBindingPanel, you can use additional attributes
to specify binding information on your server controls.
</p>
<spring:ValidationSummary ID="ctlErrorList" Provider="errors.summary" runat="server" />
<spring:DataBindingPanel ID="ctlDataBindingPanel" runat="server">
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Employee ID:</td>
<td>
<asp:TextBox ID="txtId" runat="server" BindingTarget="Employee.Id" MessageId="ID has to be an integer" ErrorProviders="id.errors,errors.summary" />
<spring:ValidationError ID="ctlIdErrors" Provider="id.errors" runat="server" />
</td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFirstName" runat="server" BindingTarget="Employee.FirstName" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox ID="txtLastName" runat="server" BindingTarget="Employee.LastName" /></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td>
<asp:TextBox ID="txtDOB" runat="server" BindingTarget="Employee.DateOfBirth" MessageId="Invalid date value" ErrorProviders="errors.summary,dob.errors"/>
<spring:ValidationError ID="ctlDOBErrors" Provider="dob.errors" runat="server" />
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<!--
RadioButtonGroup control exposes Value property which is set
to the value of the ID property of the selected radio button
-->
<spring:RadioButtonGroup ID="rbgGender" runat="server" BindingTarget="Employee.Gender">
<asp:RadioButton ID="Male" Text="Male" runat="server" />
<asp:RadioButton ID="Female" Text="Female" runat="server" />
</spring:RadioButtonGroup>
</td>
</tr>
<tr>
<td>Salary:</td>
<td>
<asp:TextBox ID="txtSalary" runat="server" BindingTarget="Employee.Salary" BindingFormatter="theCurrencyFormatter" MessageId="Salary must be a valid currency value." ErrorProviders="errors.summary,salary.errors" />
<spring:ValidationError ID="ctlSalaryErrors" Provider="salary.errors" runat="server" />
</td>
</tr>
<tr>
<td>Address Type:</td>
<td>
<!--
Another way to select one of the predefined values, which is
how enum values should always be entered
-->
<asp:DropDownList ID="ddlAddressType" runat="server" BindingTarget="Employee.MailingAddress.AddressType">
<asp:ListItem Value="Home" Text="Home" Selected="True" />
<asp:ListItem Value="Office" Text="Office" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Street 1:</td>
<td><asp:TextBox ID="txtStreet1" runat="server" BindingTarget="Employee.MailingAddress.Street1" /></td>
</tr>
<tr>
<td>Street 2:</td>
<td><asp:TextBox ID="txtStreet2" runat="server" BindingTarget="Employee.MailingAddress.Street2" /></td>
</tr>
<tr>
<td>City:</td>
<td><asp:TextBox ID="txtCity" runat="server" BindingTarget="Employee.MailingAddress.City" /></td>
</tr>
<tr>
<td>State:</td>
<td><asp:TextBox ID="txtState" runat="server" BindingTarget="Employee.MailingAddress.State" /></td>
</tr>
<tr>
<td>Postal Code/ZIP:</td>
<td><asp:TextBox ID="txtPostalCode" runat="server" BindingTarget="Employee.MailingAddress.PostalCode" /></td>
</tr>
<tr>
<td>Country:</td>
<td><asp:TextBox ID="txtCountry" runat="server" BindingTarget="Employee.MailingAddress.Country" /></td>
</tr>
<tr>
<td>Hobbies:</td>
<td><asp:ListBox id="lstHobbies" runat="server" SelectionMode="Multiple" BindingTarget="Employee.Hobbies" /></td>
</tr>
<tr>
<td>Favorite Food:</td>
<td>
<spring:CheckBoxList id="lstFavoriteFood" runat="server" BindingTarget="Employee.FavoriteFood">
<asp:ListItem value="0">Cheese</asp:ListItem>
<asp:ListItem value="1">Noodles</asp:ListItem>
<asp:ListItem value="2">Fruits</asp:ListItem>
<asp:ListItem value="3">Vegetables</asp:ListItem>
</spring:CheckBoxList>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
</tr>
</table>
</spring:DataBindingPanel>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,56 @@
using System;
using System.Diagnostics;
using System.Web.UI.WebControls;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_EasyEmployeeInfo_Default : Spring.Web.UI.Page
{
private EmployeeInfo employee = new EmployeeInfo();
public EmployeeInfo Employee
{
get { return employee; }
}
protected override void OnInitializeControls(EventArgs e)
{
base.OnInitializeControls(e);
InitializeHobbiesList();
}
private void InitializeHobbiesList()
{
// fill lstHobbies with 'Hobby' items
Hobby[] hobbies = {
new Hobby("1", "Tennis"),
new Hobby("2", "Climbing"),
new Hobby("3", "Sailing"),
new Hobby("4", "Reading")
};
this.lstHobbies.SelectionMode = ListSelectionMode.Multiple;
// assign the list in any case - this is required for DataSourceItemFormatter to be able
// to access Hobby objects
this.lstHobbies.DataSource = hobbies;
this.lstHobbies.DataTextField = "Title";
this.lstHobbies.DataValueField = "UniqueKey";
if (!IsPostBack)
{
this.lstHobbies.DataBind();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with employee such as:
// employeeDao.Save(Employee);
Debug.Write(Employee);
}
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<configuration>
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- define the currencyFormatter used for formatting the salary -->
<object name="theCurrencyFormatter" type="Spring.Globalization.Formatters.CurrencyFormatter" />
</objects>
</spring>
</configuration>

View File

@@ -0,0 +1,113 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_EmployeeInfo_Default" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Employee Info example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Employee Info example</h2>
<p>
Now we are getting into more interesting stuff :-).
</p>
<p>
This form allows you to enter employee information and it updates properties
of the Employee property based on the entered values. You should put a breakpoint
on the Debug.Write(Employee) statement in the event handler for the Save button,
so you can see how Employee object was populated by the framework.
</p>
<p>
You should note that there a number of type conversions are performed quietly
behind the scenes, such as string to int, double, DateTime, and even enum values.
Please also keep in mind that this form is very fragile and it will throw
an exception if you enter a value that cannot be converted using standard type
conversion mechanism, so make sure that you enter valid values for the ID, Date of Birth,
and Salary fields. In the next example we will show you how to make it more robust
using formatters and built-in data type validation.
</p>
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Employee ID:</td>
<td><asp:TextBox ID="txtId" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFirstName" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox ID="txtLastName" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td><asp:TextBox ID="txtDOB" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<!--
RadioButtonGroup control exposes Value property which is set
to the value of the ID property of the selected radio button
-->
<spring:RadioButtonGroup ID="rbgGender" runat="server" EnableViewState="false">
<asp:RadioButton ID="Male" Text="Male" runat="server" EnableViewState="false" />
<asp:RadioButton ID="Female" Text="Female" runat="server" EnableViewState="false" />
</spring:RadioButtonGroup>
</td>
</tr>
<tr>
<td>Salary:</td>
<td><asp:TextBox ID="txtSalary" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Address Type:</td>
<td>
<!--
Another way to select one of the predefined values, which is
how enum values should always be entered
-->
<asp:DropDownList ID="ddlAddressType" runat="server" EnableViewState="false">
<asp:ListItem Value="Home" Text="Home" Selected="True" />
<asp:ListItem Value="Office" Text="Office" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Street 1:</td>
<td><asp:TextBox ID="txtStreet1" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Street 2:</td>
<td><asp:TextBox ID="txtStreet2" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>City:</td>
<td><asp:TextBox ID="txtCity" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>State:</td>
<td><asp:TextBox ID="txtState" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Postal Code/ZIP:</td>
<td><asp:TextBox ID="txtPostalCode" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Country:</td>
<td><asp:TextBox ID="txtCountry" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,51 @@
using System;
using System.Diagnostics;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_EmployeeInfo_Default : Spring.Web.UI.Page
{
private EmployeeInfo employee = new EmployeeInfo();
public EmployeeInfo Employee
{
get { return employee; }
}
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
BindingManager.AddBinding("txtId.Text", "Employee.Id");
BindingManager.AddBinding("txtFirstName.Text", "Employee.FirstName");
BindingManager.AddBinding("txtLastName.Text", "Employee.LastName");
BindingManager.AddBinding("txtDOB.Text", "Employee.DateOfBirth");
BindingManager.AddBinding("txtSalary.Text", "Employee.Salary");
BindingManager.AddBinding("rbgGender.Value", "Employee.Gender");
BindingManager.AddBinding("ddlAddressType.SelectedValue", "Employee.MailingAddress.AddressType");
BindingManager.AddBinding("txtStreet1.Text", "Employee.MailingAddress.Street1");
BindingManager.AddBinding("txtStreet2.Text", "Employee.MailingAddress.Street2");
BindingManager.AddBinding("txtCity.Text", "Employee.MailingAddress.City");
BindingManager.AddBinding("txtState.Text", "Employee.MailingAddress.State");
BindingManager.AddBinding("txtPostalCode.Text", "Employee.MailingAddress.PostalCode");
BindingManager.AddBinding("txtCountry.Text", "Employee.MailingAddress.Country");
}
protected void Page_Load(object sender, EventArgs e)
{}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with employee such as:
// employeeDao.Save(Employee);
Debug.Write(Employee);
}
}

View File

@@ -0,0 +1,42 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_EventHandling_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Event Handling example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Event Handling example</h2>
<p>
This example builds on the previous one by adding postback event handler
that will convert the name to uppercase.
</p>
<p>
This particular example shows the main reason data binding framework was developed
in a first place. The idea is that developer should almost never have to access
controls directly within postback event handlers. Instead, controls should
automatically populate data model on postback and they should be refreshed
from the data model just before the page is rendered again.
</p>
<p>
As you can see, developer can modify data model directly within postback event handler
and all the changes will be reflected on the controls when the page is rendered. In
this particular example we use properties within the Page class to hold data model,
but there are other alternatives as well, that we'll show you in the later examples.
</p>
<p>
Enter Your Name: <asp:TextBox ID="txtName" runat="server" AutoPostBack="false" Width="150" EnableViewState="False" />
<asp:Button ID="btnCapitalize" text="Capitalize" runat="server" OnClick="btnCapitalize_Click" />
</p>
<div id="divGreeting" runat="server">
<b>Hello, <asp:Label ID="lblName" runat="server" /></b>
</div>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,42 @@
using System;
using Spring.DataBinding;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_EventHandling_Default : Spring.Web.UI.Page
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
BindingManager.AddBinding("txtName.Text", "Name");
BindingManager.AddBinding("lblName.Text", "Name", BindingDirection.TargetToSource);
}
protected void Page_Load(object sender, EventArgs e)
{
divGreeting.Visible = !string.IsNullOrEmpty(Name);
}
/// <summary>
/// Event handler simply manipulates data model directly and
/// changes are immediately reflected on the page.
/// </summary>
protected void btnCapitalize_Click(object sender, EventArgs e)
{
Name = Name.ToUpper();
}
}

View File

@@ -0,0 +1,38 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_HelloWorld_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Hello World example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Hello World example</h2>
<p>
This very simple web form demonstrates basic bi-directional data binding.
</p>
<p>
Once you enter your name into the text box and submit the form (by hitting Enter),
Spring.NET will evaluate data binding rules configured in the code-behind file and
set the Name property of the page to the value of txtName.Text property.
</p>
<p>
After that, page will be rendered again and Name property will be bound both
to the text box, so you can change the value, and to the label below the text
box, in order to show you how you can use one-way bindings to set non-writable
properties.
</p>
<p>
Enter Your Name: <asp:TextBox ID="txtName" runat="server" Width="150" EnableViewState="False"/>
</p>
<div id="divGreeting" runat="server">
<b>Hello, <asp:Label ID="lblName" runat="server" /></b>
</div>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,33 @@
using System;
using Spring.DataBinding;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_HelloWorld_Default : Spring.Web.UI.Page
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
BindingManager.AddBinding("txtName.Text", "Name");
BindingManager.AddBinding("lblName.Text", "Name", BindingDirection.TargetToSource);
}
protected void Page_Load(object sender, EventArgs e)
{
divGreeting.Visible = !string.IsNullOrEmpty(Name);
}
}

View File

@@ -0,0 +1,57 @@
<%@ Page Language="C#" EnableViewState="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_Lists_Default" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Multi-Selection Lists Example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Multi-Selection Lists example</h2>
<p>
Life is not 1-dimensional ;-). This sample demonstrates binding of multiple selection lists.
</p>
<p>
This form allows you to enter employee information and it updates properties
of the Employee property based on the entered values. You should put a breakpoint
on the Debug.Write(Employee) statement in the event handler for the Save button,
so you can see how Employee object was populated by the framework.
</p>
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Employee ID:</td>
<td><asp:TextBox ID="txtId" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFirstName" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Hobbies:</td>
<td><asp:ListBox id="lstHobbies" runat="server" SelectionMode="Multiple" EnableViewState="false" /></td>
</tr>
<tr>
<td>Favorite Food:</td>
<td>
<asp:CheckBoxList id="lstFavoriteFood" runat="server" EnableViewState="false">
<asp:ListItem value="0">Cheese</asp:ListItem>
<asp:ListItem value="1">Noodles</asp:ListItem>
<asp:ListItem value="2">Fruits</asp:ListItem>
<asp:ListItem value="3">Vegetables</asp:ListItem>
</asp:CheckBoxList>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,85 @@
using System;
using System.Diagnostics;
using System.Web.UI.WebControls;
using Spring.DataBinding;
using Spring.Globalization;
using Spring.Globalization.Formatters;
using Spring.Web.UI;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_Lists_Default : Page
{
private EmployeeInfo employee = new EmployeeInfo();
public EmployeeInfo Employee
{
get { return employee; }
}
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
BindingManager.AddBinding("txtId.Text", "Employee.Id");
BindingManager.AddBinding("txtFirstName.Text", "Employee.FirstName");
// this is rather verbose to show how it works
// the formatter must convert between ListControl values and domain objects identified by these values (e.g. a key)
IFormatter dsFormatter = new DataSourceItemFormatter("DataSource", "DataValueField");
// bind the lstHobbies control to Employee.Hobbies IList
MultipleSelectionListControlBinding listBinding = new MultipleSelectionListControlBinding("lstHobbies", "Employee.Hobbies", BindingDirection.Bidirectional, dsFormatter);
BindingManager.AddBinding(listBinding);
// use simple name=value binding
BindingManager.AddBinding(new MultipleSelectionListControlBinding("lstFavoriteFood", "Employee.FavoriteFood", BindingDirection.Bidirectional, new NullFormatter()));
}
protected override void OnInitializeControls(EventArgs e)
{
base.OnInitializeControls(e);
InitializeHobbiesList();
}
private void InitializeHobbiesList()
{
Hobby[] hobbies = {
new Hobby("1", "Tennis"),
new Hobby("2", "Climbing"),
new Hobby("3", "Sailing"),
new Hobby("4", "Reading")
};
this.lstHobbies.SelectionMode = ListSelectionMode.Multiple;
// assign the list in any case - this is required for DataSourceItemFormatter to be able
// to access Hobby objects
this.lstHobbies.DataSource = hobbies;
this.lstHobbies.DataTextField = "Title";
this.lstHobbies.DataValueField = "UniqueKey";
if (!IsPostBack)
{
this.lstHobbies.DataBind();
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with employee such as:
// employeeDao.Save(Employee);
Debug.Write(Employee);
}
}

View File

@@ -0,0 +1,124 @@
<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="DataBinding_RobustEmployeeInfo_Default" %>
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Data Binding - Robust Employee Info example</title>
</head>
<body>
<h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
<h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
<h2>Robust Employee Info example</h2>
<p>
Now that we have basic data binding rules configured, let's make it more robust.
</p>
<p>
In general, you should specify data-type conversion error handlers for every
data binding that converts values from one type to another. Optionally, you can
also specify a formatter if you need to format and/or parse the value during data
binding process, which is exactly what we did for the Salary field. Now you can
enter its value using currency symbol and thousands separator, but entering plain
number will still work (and it will be properly formatted after the postback).
</p>
<p>
Control definitions below are almost the same as in the previous example. The only
difference is that we added controls that will be used to display validation errors.
</p>
<p>
Just like in the previous example, you should put a breakpoint
on the Debug.Write(Employee) statement in the event handler for the Save button,
so you can see how Employee object was populated by the framework.
</p>
<table cellpadding="3" cellspacing="3" border="0">
<tr>
<td>Employee ID:</td>
<td>
<asp:TextBox ID="txtId" runat="server" EnableViewState="false" />
<spring:ValidationError ID="errId" Provider="id.errors" runat="server" />
</td>
</tr>
<tr>
<td>First Name:</td>
<td><asp:TextBox ID="txtFirstName" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><asp:TextBox ID="txtLastName" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Date of Birth:</td>
<td>
<asp:TextBox ID="txtDOB" runat="server" EnableViewState="false" />
<spring:ValidationError ID="errDOB" Provider="dob.errors" runat="server" />
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<!--
RadioButtonGroup control exposes Value property which is set
to the value of the ID property of the selected radio button
-->
<spring:RadioButtonGroup ID="rbgGender" runat="server" EnableViewState="false">
<asp:RadioButton ID="Male" Text="Male" runat="server" EnableViewState="false" />
<asp:RadioButton ID="Female" Text="Female" runat="server" EnableViewState="false" />
</spring:RadioButtonGroup>
</td>
</tr>
<tr>
<td>Salary:</td>
<td>
<asp:TextBox ID="txtSalary" runat="server" EnableViewState="false" />
<spring:ValidationError ID="errSalary" Provider="salary.errors" runat="server" />
</td>
</tr>
<tr>
<td>Address Type:</td>
<td>
<!--
Another way to select one of the predefined values, which is
how enum values should always be entered
-->
<asp:DropDownList ID="ddlAddressType" runat="server" EnableViewState="false">
<asp:ListItem Value="Home" Text="Home" Selected="True" />
<asp:ListItem Value="Office" Text="Office" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Street 1:</td>
<td><asp:TextBox ID="txtStreet1" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Street 2:</td>
<td><asp:TextBox ID="txtStreet2" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>City:</td>
<td><asp:TextBox ID="txtCity" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>State:</td>
<td><asp:TextBox ID="txtState" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Postal Code/ZIP:</td>
<td><asp:TextBox ID="txtPostalCode" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>Country:</td>
<td><asp:TextBox ID="txtCountry" runat="server" EnableViewState="false" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /></td>
</tr>
</table>
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,55 @@
using System;
using System.Diagnostics;
using Spring.Globalization.Formatters;
/// <summary>
/// Notice that your web page has to extend Spring.Web.UI.Page class
/// in order to enable data binding and many other features.
/// </summary>
public partial class DataBinding_RobustEmployeeInfo_Default : Spring.Web.UI.Page
{
private EmployeeInfo employee = new EmployeeInfo();
public EmployeeInfo Employee
{
get { return employee; }
}
/// <summary>
/// In order to declare data bindings, all you need to do is
/// override InitializeDataBindings method and add all necessary
/// data bindings to the BindingManager.
/// </summary>
protected override void InitializeDataBindings()
{
BindingManager.AddBinding("txtId.Text", "Employee.Id")
.SetErrorMessage("ID has to be an integer", "id.errors");
BindingManager.AddBinding("txtFirstName.Text", "Employee.FirstName");
BindingManager.AddBinding("txtLastName.Text", "Employee.LastName");
BindingManager.AddBinding("txtDOB.Text", "Employee.DateOfBirth")
.SetErrorMessage("Invalid date value", "dob.errors");
BindingManager.AddBinding("txtSalary.Text", "Employee.Salary", new CurrencyFormatter())
.SetErrorMessage("Salary must be a valid currency value.", "salary.errors");
BindingManager.AddBinding("rbgGender.Value", "Employee.Gender");
BindingManager.AddBinding("ddlAddressType.SelectedValue", "Employee.MailingAddress.AddressType");
BindingManager.AddBinding("txtStreet1.Text", "Employee.MailingAddress.Street1");
BindingManager.AddBinding("txtStreet2.Text", "Employee.MailingAddress.Street2");
BindingManager.AddBinding("txtCity.Text", "Employee.MailingAddress.City");
BindingManager.AddBinding("txtState.Text", "Employee.MailingAddress.State");
BindingManager.AddBinding("txtPostalCode.Text", "Employee.MailingAddress.PostalCode");
BindingManager.AddBinding("txtCountry.Text", "Employee.MailingAddress.Country");
}
protected void Page_Load(object sender, EventArgs e)
{}
protected void btnSave_Click(object sender, EventArgs e)
{
// do something with employee such as:
// employeeDao.Save(Employee);
Debug.Write(Employee);
}
}

View File

@@ -0,0 +1,73 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Spring.NET Web Framework Quick Start Guide</title>
</head>
<body>
<h2>Welcome to Spring.NET Web Framework Quick Start Guide</h2>
<div>
<p>
This sample application provides a number of small Quick Starts
that demonstrate various features of the Spring.NET Web Framework.
</p>
<p>
Spring.NET Web Framework is an extension to ASP.NET that adds many
powerful features, such as Dependency Injection for web pages and
controls, bi-directional data binding, localization support, etc.
</p>
<p>
It also integrates extremely well with Spring.NET Data Validation Framework
and allows you to declaratively configure very complex and sophisticated
data validation rules.
</p>
<p>
Once you become acquainted with all the individual features of Spring.NET
Web Framework by studying this application, you should take a look at SpringAir
sample application for a more integrated view, in order to see how many of these
features are combined into an application.
</p>
<h2>Feature Categories</h2>
<p>
Following sections provide a brief overview of different Spring.NET Web Framework
feature catagories. Within each category you will find small examples that clearly
demonstrate various features within that category, which will be very beneficial
to everyone who prefers to learn by example.
</p>
<h3><a href="DI/Default.aspx">Dependency Injection</a></h3>
<p>
Samples in this category show you how to inject dependencies into your web pages
and controls using Spring.NET DI Container. You will learn about different
configuration options, basic steps you need to take in order to enable DI in your
pages, and then move on to more complex examples that will show you how to separate
your application into components using hierarchical web contexts.
</p>
<h3><a href="DataBinding/Default.aspx">Bi-directional Data Binding</a></h3>
<p>
By studying samples in this category, you will learn how to declaratively define
data binding rules that will save you a ton of time and many lines of code when
developing Spring.NET-powered web applications. We will start with basic examples
and then move on to using more advanced features, such as type conversion, formatting,
automatic validation and binding to complex iterative structures.
</p>
<h3>Localization</h3>
<p>
In this section you will learn how to properly localize your web applications. We will
start with very simple automatic localization, and then move on to demonstrate different
user culture management strategies, explicit localization options, and localization of
images within your application.
</p>
<h3>Data Validation</h3>
<p>
Spring.NET includes a very powerful, generic Data Validation Framework. This framework is
very tightly integrated with Spring.NET Web Framework, and it allows you to configure
sophisticated validation rules and execute them as necessary. In this section we will
start with a Hello World! validation example and then move on to show you how you can
compose advanced validation rules that leverage validation groups, conditional validation,
validator composition, as well as how to create and use your custom validators.
</p>
</div>
</body>
</html>

View File

@@ -0,0 +1,17 @@
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,63 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
</configSections>
<!-- to see logging output in the attached debugger -->
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="Level" value="ALL"/>
</factoryAdapter>
</logging>
</common>
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<pages>
<controls>
<add tagPrefix="spring" namespace="Spring.Web.UI.Controls" assembly="Spring.Web"/>
</controls>
</pages>
<!--
The following needs to be configured in order to enable Spring.NET Web Framework features
-->
<httpModules>
<add name="SpringModule" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
<add name="HtmlCommentAppender" type="HtmlCommentAppenderModule"/>
<!-- this custom module is only for DI demonstration purposes -->
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
</httpHandlers>
</system.web>
<!-- demonstrates how to configure IHttpModule instances -->
<spring>
<context>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<!-- configure our custom HttpModule -->
<object name="HttpApplicationConfigurer" type="Spring.Context.Support.HttpApplicationConfigurer, Spring.Web">
<property name="ModuleTemplates">
<dictionary>
<entry key="HtmlCommentAppender">
<!-- this name must match the module name -->
<object>
<!-- select "view source" in your browser on any page to see the appended html comment -->
<property name="AppendText" value="My configured comment!"/>
</object>
</entry>
</dictionary>
</property>
</object>
</objects>
</spring>
</configuration>

View File

@@ -0,0 +1,99 @@
using System;
using System.Web.Management;
using System.Configuration.Provider;
using System.Collections.Specialized;
using System.Web.Hosting;
using System.IO;
using System.Security.Permissions;
using System.Web;
public class TextFileWebEventProvider : WebEventProvider
{
private string _LogFileName;
public override void Initialize(string name,
NameValueCollection config)
{
// Verify that config isn't null
if (config == null)
throw new ArgumentNullException("config");
// Assign the provider a default name if it doesn't have one
if (String.IsNullOrEmpty(name))
name = "TextFileWebEventProvider";
// Add a default "description" attribute to config if the
// attribute doesn't exist or is empty
if (string.IsNullOrEmpty(config["description"]))
{
config.Remove("description");
config.Add("description", "Text file Web event provider");
}
// Call the base class's Initialize method
base.Initialize(name, config);
// Initialize _LogFileName and make sure the path
// is app-relative
string path = config["logFileName"];
if (String.IsNullOrEmpty(path))
throw new ProviderException
("Missing logFileName attribute");
if (!VirtualPathUtility.IsAppRelative(path))
throw new ArgumentException
("logFileName must be app-relative");
string fullyQualifiedPath = VirtualPathUtility.Combine
(VirtualPathUtility.AppendTrailingSlash
(HttpRuntime.AppDomainAppVirtualPath), path);
_LogFileName = HostingEnvironment.MapPath(fullyQualifiedPath);
config.Remove("logFileName");
// Make sure we have permission to write to the log file
// throw an exception if we don't
FileIOPermission permission =
new FileIOPermission(FileIOPermissionAccess.Write |
FileIOPermissionAccess.Append, _LogFileName);
permission.Demand();
// Throw an exception if unrecognized attributes remain
if (config.Count > 0)
{
string attr = config.GetKey(0);
if (!String.IsNullOrEmpty(attr))
throw new ProviderException
("Unrecognized attribute: " + attr);
}
}
public override void ProcessEvent(WebBaseEvent raisedEvent)
{
// Write an entry to the log file
LogEntry(FormatEntry(raisedEvent));
}
public override void Flush()
{
}
public override void Shutdown()
{
}
// Helper methods
private string FormatEntry(WebBaseEvent e)
{
return String.Format("{0}\t{1}\t{2} (Event Code: {3})",
e.EventTime, e.GetType().ToString(), e.Message,
e.EventCode);
}
private void LogEntry(string entry)
{
StreamWriter writer = null;
try
{
writer = new StreamWriter(_LogFileName, true);
writer.WriteLine(entry);
}
finally
{
if (writer != null)
writer.Close();
}
}
}

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id="mySqlMembershipProvider" type="Spring.Web.Providers.ConfigurableSqlMembershipProvider">
<property name="connectionStringName" value="MyLocalSQLServer" />
<property name="parameters">
<name-values>
<add key="description" value="membershipprovider description" />
</name-values>
</property>
</object>
<object id="mySqlRoleProvider" type="Spring.Web.Providers.ConfigurableSqlRoleProvider">
<property name="connectionStringName" value="MyLocalSQLServer" />
<property name="parameters">
<name-values>
<add key="description" value="roleprovider description" />
</name-values>
</property>
</object>
<object id="mySqlProfileProvider" type="Spring.Web.Providers.ConfigurableSqlProfileProvider">
<property name="connectionStringName" value="MyLocalSQLServer" />
<property name="parameters">
<name-values>
<add key="description" value="profileprovider description" />
</name-values>
</property>
</object>
<object id="myXmlSiteMapProvider" type="Spring.Web.Providers.ConfigurableXmlSiteMapProvider">
<property name="siteMapFile" value="Web.sitemap" />
<property name="parameters">
<name-values>
<add key="description" value="profileprovider description" />
</name-values>
</property>
</object>
</objects>

View File

@@ -0,0 +1,24 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1><asp:Label ID="LblTest" runat="server" Text="Welcome to Provider Test"></asp:Label></h1>
<a id="SitemapTestLink" href="SitemapTest.aspx"> test sitemap provider</a>
<br />
<a id="MembershipTestLink" href="TestProviders/MembershipTest.aspx"> test membership provider </a>
<br />
<a id="ProfileTestLink" href="TestProviders/ProfileTest.aspx"> test profile provider </a>
<br />
<a id="RoleProviderLink" href="TestProviders/RolesTest.aspx"> test role provider<br /></a>
<br />
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,18 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}

View File

@@ -0,0 +1,35 @@
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>

View File

@@ -0,0 +1,38 @@
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Profile Provider Test</title>
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
SiteMapProvider defaultProvider = SiteMap.Provider;
this.TxtDescription.Text = defaultProvider.Description;
this.TxtName.Text = defaultProvider.Name;
this.TxtType.Text = defaultProvider.GetType().ToString();
this.LstAllNodes.Items.Add(SiteMap.RootNode.Url);
foreach (SiteMapNode sitemapnode in SiteMap.RootNode.ChildNodes)
{
this.LstAllNodes.Items.Add(sitemapnode.Url);
}
}
</SCRIPT>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="LblName" runat="server" Text="Provider Name:"></asp:Label>
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblDescription" runat="server" Text="Provider Description:"></asp:Label>
<asp:TextBox ID="TxtDescription" runat="server"></asp:TextBox><br />
<br />
<asp:Label ID="Label1" runat="server" Text="Provider Type:"></asp:Label>
<asp:TextBox ID="TxtType" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblAllNodes" runat="server" Text="All members:"></asp:Label><br />
<asp:ListBox ID="LstAllNodes" runat="server" Height="149px" Width="219px"></asp:ListBox>
</form>
</body>
</html>

View File

@@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Test1 : Spring.Web.UI.Page
{
}

View File

@@ -0,0 +1,38 @@
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Profile Provider Test</title>
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
MembershipProvider defaultProvider = Membership.Provider;
this.TxtDescription.Text = defaultProvider.Description;
this.TxtName.Text = defaultProvider.Name;
this.TxtType.Text = defaultProvider.GetType().ToString();
LstAllMembers.Items.Clear();
foreach (MembershipUser user in Membership.GetAllUsers())
{
LstAllMembers.Items.Add(user.UserName);
}
}
</SCRIPT>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="LblName" runat="server" Text="Provider Name:"></asp:Label>
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblDescription" runat="server" Text="Provider Description:"></asp:Label>
<asp:TextBox ID="TxtDescription" runat="server"></asp:TextBox><br />
<br />
<asp:Label ID="Label1" runat="server" Text="Provider Type:"></asp:Label>
<asp:TextBox ID="TxtType" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblAllMembers" runat="server" Text="All members:"></asp:Label><br />
<asp:ListBox ID="LstAllMembers" runat="server" Height="149px" Width="219px"></asp:ListBox>
</form>
</body>
</html>

View File

@@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MembershipTest : Spring.Web.UI.Page
{
}

View File

@@ -0,0 +1,27 @@
<%@ Page Language="C#" EnableViewState="true" %>
<%@ Import namespace="System.Web.Profile"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Profile Provider Test</title>
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
this.TxtGreeting.Text = Profile.Greeting;
this.TxtUsername.Text = Profile.UserName;
}
</SCRIPT>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="LblUsername" runat="server" Text="Logged Username:"></asp:Label>
<asp:TextBox ID="TxtUsername" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Lblgreeting" runat="server" Text="User's Greeting:"></asp:Label>
<asp:TextBox ID="TxtGreeting" runat="server"></asp:TextBox><br />
</form>
</body>
</html>

View File

@@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ProfileTest : Spring.Web.UI.Page
{
}

View File

@@ -0,0 +1,39 @@
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Profile Provider Test</title>
<SCRIPT runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
RoleProvider defaultProvider = Roles.Provider;
this.TxtDescription.Text = defaultProvider.Description;
this.TxtName.Text = defaultProvider.Name;
this.TxtType.Text = defaultProvider.GetType().ToString();
foreach (string role in Roles.GetAllRoles())
{
LstAllRoles.Items.Add(role);
}
}
</SCRIPT>
</head>
<body>
<form id="form1" runat="server">
<asp:Label ID="LblName" runat="server" Text="Provider Name:"></asp:Label>
<asp:TextBox ID="TxtName" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblDescription" runat="server" Text="Provider Description:"></asp:Label>
<asp:TextBox ID="TxtDescription" runat="server"></asp:TextBox><br />
<br />
<asp:Label ID="Label1" runat="server" Text="Provider Type:"></asp:Label>
<asp:TextBox ID="TxtType" runat="server"></asp:TextBox>
<br />
<asp:Label ID="LblAllRoles" runat="server" Text="All roles:"></asp:Label><br />
<asp:ListBox ID="LstAllRoles" runat="server" Height="149px" Width="219px"></asp:ListBox>
</form>
</body>
</html>

View File

@@ -0,0 +1,15 @@
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class RolesTest : Spring.Web.UI.Page
{
}

View File

@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<configuration>
<location>
<system.web>
<authorization>
<deny users="?" />
<allow users="Damjan" />
</authorization>
</system.web>
</location>
</configuration>

View File

@@ -0,0 +1,33 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UserLogin.aspx.cs" Inherits="Admin_Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>login</title>
</head>
<body>
<form id="LoginForm" runat="server">
<div align="center">
Please enter your login information:<br />
<br />
<table width="450px" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" >Username:</td>
<td align="left">
<asp:TextBox ID="UsernameText" runat="server" />
</td>
</tr>
<tr>
<td align="left">Password:</td>
<td align="left">
<asp:TextBox ID="PasswordText" runat="server" TextMode="Password" />
</td>
</tr>
</table>
<br />
<asp:Button ID="LoginAction" runat="server" OnClick="LoginAction_Click" Text="Login" /><br />
<asp:Label ID="LegendStatus" runat="server" EnableViewState="false" Text="" />
</div>
</form>
</body>
</html>

View File

@@ -0,0 +1,25 @@
using System;
using System.Web.Security;
using Spring.Web.UI;
public partial class Admin_Login : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LoginAction_Click(object sender, EventArgs e)
{
string user = UsernameText.Text;
string pass = PasswordText.Text;
if (Membership.ValidateUser(user, pass))
{
FormsAuthentication.RedirectFromLoginPage(user, false);
}
else
{
LegendStatus.Text = "Error!";
}
}
}

View File

@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging"/>
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<common>
<logging>
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="level" value="ALL"/>
</factoryAdapter>
</logging>
</common>
<spring>
<context>
<resource uri="~/Config/Web.xml"/>
<resource uri="config://spring/objects"/>
</context>
<objects xmlns="http://www.springframework.net">
<object type="~/UserLogin.aspx" />
</objects>
</spring>
<appSettings>
<add key="Name" value="SpringNetProvidersTest"/>
</appSettings>
<connectionStrings>
<add name="MyLocalSQLServer"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|ASPNETDB.MDF;Integrated Security=SSPI;User Instance=True"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
<system.web>
<httpModules>
<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>
</httpModules>
<httpHandlers>
<add verb="*" path="*.aspx" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>
<add verb="*" path="ContextMonitor.ashx" type="Spring.Web.Support.ContextMonitor, Spring.Web"/>
</httpHandlers>
<compilation debug="true">
<assemblies>
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name="Login" loginUrl="UserLogin.aspx" timeout="20" protection="All"/>
</authentication>
<membership defaultProvider="mySqlMembershipProvider">
<providers>
<clear/>
<add connectionStringName="" name="mySqlMembershipProvider" type="Spring.Web.Providers.MembershipProviderAdapter, Spring.Web"/>
</providers>
</membership>
<roleManager enabled="true" defaultProvider="mySqlRoleProvider">
<providers>
<clear/>
<add connectionStringName="" name="mySqlRoleProvider" type="Spring.Web.Providers.RoleProviderAdapter, Spring.Web"/>
</providers>
</roleManager>
<profile defaultProvider="mySqlProfileProvider">
<providers>
<clear/>
<add name="mySqlProfileProvider" type="Spring.Web.Providers.ProfileProviderAdapter, Spring.Web" connectionStringName=""/>
</providers>
<properties>
<add name="Greeting" type="String"/>
</properties>
</profile>
<siteMap defaultProvider="myXmlSiteMapProvider">
<providers>
<clear/>
<add name="myXmlSiteMapProvider" type="Spring.Web.Providers.SiteMapProviderAdapter, Spring.Web" siteMapFile=""/>
</providers>
</siteMap>
<!---->
<!--
<healthMonitoring enabled="true">
<providers>
<add name="AspNetTextFileWebEventProvider" type="TextFileWebEventProvider" logFileName="~/App_Data/MyTest.txt"/>
</providers>
<rules>
<add name="TestWS Application Lifetime Events" eventName="All Events" provider="AspNetTextFileWebEventProvider" minInterval="00:00:01" minInstances="1" maxLimit="Infinite"/>
</rules>
</healthMonitoring>
-->
</system.web>
</configuration>

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<siteMapNode url="~/Default.aspx" title="Home" roles="*">
<siteMapNode url="~/SitemapTest.aspx" title="Site Map" />
<siteMapNode url="~/TestProviders/MembershipTest.aspx" title="Site Map" />
<siteMapNode url="~/TestProviders/ProfileTest.aspx" title="Site Map" />
</siteMapNode>
</siteMap>