Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
//
// System.Web.UI.WebControls.AccessDataSource.cs
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.IO;
using System.ComponentModel;
using System.Data.Common;
using System.Drawing;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DesignerAttribute ("System.Web.UI.Design.WebControls.AccessDataSourceDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[ToolboxBitmap ("")]
public class AccessDataSource : SqlDataSource
{
const string PROVIDER_NAME = "System.Data.OleDb";
const string PROVIDER_STRING = "Microsoft.Jet.OLEDB.4.0";
//string dataFile;
string connectionString;
public AccessDataSource () : base ()
{
base.ProviderName = PROVIDER_NAME;
}
public AccessDataSource (string dataFile, string selectCommand) :
base (String.Empty, selectCommand)
{
//this.dataFile = dataFile;
this.ProviderName = PROVIDER_NAME;
}
protected override SqlDataSourceView CreateDataSourceView (string viewName)
{
AccessDataSourceView view = new AccessDataSourceView (this, viewName, this.Context);
if (IsTrackingViewState)
((IStateManager) view).TrackViewState ();
return view;
}
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Browsable (false)]
[MonoTODO("AccessDataSource does not support SQL Cache Dependencies")]
public override string SqlCacheDependency {
get { throw new NotSupportedException ("AccessDataSource does not supports SQL Cache Dependencies."); }
set { throw new NotSupportedException ("AccessDataSource does not supports SQL Cache Dependencies."); }
}
[MonoTODO ("why override? maybe it doesn't call DbProviderFactories.GetFactory?")]
protected override DbProviderFactory GetDbProviderFactory ()
{
return DbProviderFactories.GetFactory (PROVIDER_NAME);
}
string GetPhysicalDataFilePath ()
{
if (String.IsNullOrEmpty (DataFile))
return String.Empty;
// more here? how do we handle |DataDirectory|?
return HttpContext.Current.Request.MapPath (DataFile);
}
[BrowsableAttribute (false),
DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public override string ConnectionString {
get {
if (connectionString == null) {
connectionString = String.Concat ("Provider=", PROVIDER_STRING, "; Data Source=", GetPhysicalDataFilePath ());
}
return connectionString;
}
set {
throw new InvalidOperationException
("The ConnectionString is automatically generated for AccessDataSource and hence cannot be set.");
}
}
[UrlPropertyAttribute]
[DefaultValueAttribute ("")]
[WebCategoryAttribute ("Data")]
[WebSysDescriptionAttribute ("MS Office Access database file name")]
[EditorAttribute ("System.Web.UI.Design.MdbDataFileEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
public string DataFile {
get { return ViewState.GetString ("DataFile", String.Empty); }
set {
ViewState ["DataFile"] = value;
connectionString = null;
}
}
[BrowsableAttribute (false),
DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public override string ProviderName {
get { return base.ProviderName; }
set { throw new InvalidOperationException
("Setting ProviderName on an AccessDataSource is not allowed");
}
}
}
}

View File

@@ -0,0 +1,84 @@
//
// System.Web.UI.WebControls.AccessDataSourceView
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// (C) Novell, Inc. (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Collections.Specialized;
using System.Text;
using System.Data;
using System.ComponentModel;
using System.Data.OleDb;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AccessDataSourceView : SqlDataSourceView
{
OleDbConnection oleConnection;
OleDbCommand oleCommand;
AccessDataSource dataSource;
public AccessDataSourceView (AccessDataSource owner, string name, HttpContext context)
: base (owner, name, context)
{
dataSource = owner;
oleConnection = new OleDbConnection (owner.ConnectionString);
}
[MonoTODO ("Handle arguments")]
protected internal override IEnumerable ExecuteSelect (
DataSourceSelectArguments arguments)
{
oleCommand = new OleDbCommand (this.SelectCommand, oleConnection);
SqlDataSourceSelectingEventArgs cmdEventArgs = new SqlDataSourceSelectingEventArgs (oleCommand, arguments);
OnSelecting (cmdEventArgs);
IEnumerable enums = null;
Exception exception = null;
OleDbDataReader reader = null;
try {
System.IO.File.OpenRead (dataSource.DataFile).Close ();
oleConnection.Open ();
reader = (OleDbDataReader)oleCommand.ExecuteReader ();
//enums = reader.GetEnumerator ();
throw new NotImplementedException("OleDbDataReader doesnt implements GetEnumerator method yet");
} catch (Exception e) {
exception = e;
}
SqlDataSourceStatusEventArgs statusEventArgs =
new SqlDataSourceStatusEventArgs (oleCommand, reader.RecordsAffected, exception);
OnSelected (statusEventArgs);
if (exception !=null)
throw exception;
return enums;
}
}
}

View File

@@ -0,0 +1,77 @@
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//
// System.Web.UI.WebControls.AdCreatedEventArgs.cs
//
// Author:
// Jackson Harper (jackson@ximian.com)
//
using System.Collections;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AdCreatedEventArgs : EventArgs
{
IDictionary properties;
string alt_text;
string img_url;
string nav_url;
public AdCreatedEventArgs (IDictionary adProperties)
{
properties = adProperties;
if (properties != null) {
alt_text = (string) properties ["AlternateText"];
img_url = (string) properties ["ImageUrl"];
nav_url = (string) properties ["NavigateUrl"];
}
}
public IDictionary AdProperties {
get { return properties; }
}
public string AlternateText {
get { return alt_text; }
set { alt_text = value; }
}
public string ImageUrl {
get { return img_url; }
set { img_url = value; }
}
public string NavigateUrl {
get { return nav_url; }
set { nav_url = value; }
}
}
}

View File

@@ -0,0 +1,31 @@
//
// System.Web.UI.WebControls.AdCreatedEventHandler
//
// Author:
// Ben Maurer <bmaurer@novell.com>
//
// (c) 2005 Novell
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls {
public delegate void AdCreatedEventHandler (object sender, AdCreatedEventArgs e);
}

View File

@@ -0,0 +1,310 @@
//
// System.Web.UI.WebControls.AdRotator
//
// Author:
// Ben Maurer <bmaurer@novell.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Xml;
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web.Util;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent("AdCreated")]
[DefaultProperty("AdvertisementFile")]
[Designer("System.Web.UI.Design.WebControls.AdRotatorDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[ToolboxData("<{0}:AdRotator runat=\"server\"></{0}:AdRotator>")]
public class AdRotator : DataBoundControl
{
AdCreatedEventArgs createdargs;
ArrayList ads = new ArrayList ();
string ad_file = String.Empty;
protected internal override void OnInit (EventArgs e)
{
base.OnInit(e);
}
protected internal override void OnPreRender (EventArgs eee)
{
Hashtable ht = null;
if (!String.IsNullOrEmpty (ad_file)) {
ReadAdsFromFile (GetPhysicalFilePath (ad_file));
ht = ChooseAd ();
}
AdCreatedEventArgs e = new AdCreatedEventArgs (ht);
OnAdCreated (e);
createdargs = e;
}
[MonoTODO ("Not implemented")]
protected internal override void PerformDataBinding (IEnumerable data)
{
throw new NotImplementedException ();
}
[MonoTODO ("Not implemented")]
protected override void PerformSelect ()
{
throw new NotImplementedException ();
}
protected internal override void Render (HtmlTextWriter w)
{
AdCreatedEventArgs e = createdargs;
base.AddAttributesToRender (w);
if (e.NavigateUrl != null && e.NavigateUrl.Length > 0)
w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveAdUrl (e.NavigateUrl));
if (Target != null && Target.Length > 0)
w.AddAttribute (HtmlTextWriterAttribute.Target, Target);
w.RenderBeginTag (HtmlTextWriterTag.A);
if (e.ImageUrl != null && e.ImageUrl.Length > 0)
w.AddAttribute (HtmlTextWriterAttribute.Src, ResolveAdUrl (e.ImageUrl));
w.AddAttribute (HtmlTextWriterAttribute.Alt, e.AlternateText == null ? String.Empty : e.AlternateText);
w.AddAttribute (HtmlTextWriterAttribute.Border, "0", false);
w.RenderBeginTag (HtmlTextWriterTag.Img);
w.RenderEndTag (); // img
w.RenderEndTag (); // a
}
string ResolveAdUrl (string url)
{
string path = url;
if (AdvertisementFile != null && AdvertisementFile.Length > 0 && path [0] != '/' && path [0] != '~')
try {
new Uri (path);
}
catch {
return UrlUtils.Combine (UrlUtils.GetDirectory (ResolveUrl (AdvertisementFile)), path);
}
return ResolveUrl (path);
}
//
// We take all the ads in the ad file and add up their
// impression weight. We then take a random number [0,
// TotalImpressions). We then choose the ad that is
// that number or less impressions for the beginning
// of the file. This lets us respect the weights
// given.
//
Hashtable ChooseAd ()
{
// cache for performance
string KeywordFilter = this.KeywordFilter;
int total_imp = 0;
int cur_imp = 0;
bool keywordFilterEmpty = KeywordFilter.Length == 0;
foreach (Hashtable a in ads) {
if (keywordFilterEmpty || KeywordFilter == (string) a ["Keyword"])
total_imp += a ["Impressions"] != null ? int.Parse ((string) a ["Impressions"]) : 1;
}
int r = new Random ().Next (total_imp);
foreach (Hashtable a in ads) {
if (!keywordFilterEmpty && KeywordFilter != (string) a ["Keyword"])
continue;
cur_imp += a ["Impressions"] != null ? int.Parse ((string) a ["Impressions"]) : 1;
if (cur_imp > r)
return a;
}
if (total_imp != 0)
throw new Exception ("I should only get here if no ads matched");
return null;
}
void ReadAdsFromFile (string s)
{
XmlDocument d = new XmlDocument ();
try {
d.Load (s);
} catch (Exception e) {
throw new HttpException ("AdRotator could not parse the xml file", e);
}
ads.Clear ();
foreach (XmlNode n in d.DocumentElement.ChildNodes) {
Hashtable ad = new Hashtable ();
foreach (XmlNode nn in n.ChildNodes)
ad.Add (nn.Name, nn.InnerText);
ads.Add (ad);
}
}
[UrlProperty]
[Bindable(true)]
[DefaultValue("")]
[Editor("System.Web.UI.Design.XmlUrlEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
[WebSysDescription("")]
[WebCategory("Behavior")]
public string AdvertisementFile {
get {
return ad_file;
}
set {
ad_file = value;
}
}
[DefaultValue ("AlternateText")]
[WebSysDescriptionAttribute ("")]
[WebCategoryAttribute ("Behavior")]
[MonoTODO ("Not implemented")]
public string AlternateTextField
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override FontInfo Font {
get {
return base.Font;
}
}
[DefaultValue ("ImageUrl")]
[MonoTODO ("Not implemented")]
[WebSysDescriptionAttribute ("")]
[WebCategoryAttribute ("Behavior")]
public string ImageUrlField
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
[Bindable(true)]
[DefaultValue("")]
[WebSysDescription("")]
[WebCategory("Behavior")]
public string KeywordFilter {
get {
return ViewState.GetString ("KeywordFilter", String.Empty);
}
set {
ViewState ["KeywordFilter"] = value;
}
}
[DefaultValue ("NavigateUrl")]
[MonoTODO ("Not implemented")]
[WebSysDescriptionAttribute ("")]
[WebCategoryAttribute ("Behavior")]
public string NavigateUrlField
{
get {
throw new NotImplementedException ();
}
set {
throw new NotImplementedException ();
}
}
[Bindable(true)]
[DefaultValue("_top")]
[TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))]
[WebSysDescription("")]
[WebCategory("Behavior")]
public string Target {
get {
return ViewState.GetString ("Target", "_top");
}
set {
ViewState ["Target"] = value;
}
}
/* all these are listed in corcompare */
public override string UniqueID
{
get {
return base.UniqueID;
}
}
protected override HtmlTextWriterTag TagKey
{
get {
return base.TagKey;
}
}
protected virtual void OnAdCreated (AdCreatedEventArgs e)
{
AdCreatedEventHandler h = (AdCreatedEventHandler) Events [AdCreatedEvent];
if (h != null)
h (this, e);
}
static readonly object AdCreatedEvent = new object ();
[WebSysDescription("")]
[WebCategory("Action")]
public event AdCreatedEventHandler AdCreated {
add { Events.AddHandler (AdCreatedEvent, value); }
remove { Events.RemoveHandler (AdCreatedEvent, value); }
}
}
}

View File

@@ -0,0 +1,49 @@
//
// System.Web.UI.WebControls.AssociatedControlConverter.cs
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Web.UI.WebControls
{
public class AssociatedControlConverter : ControlIDConverter
{
public AssociatedControlConverter () : base ()
{ }
protected override bool FilterControl (Control control)
{
if (control is WebControl)
return true;
return false;
}
}
}

View File

@@ -0,0 +1,52 @@
//
// System.Web.UI.WebControls.AuthenticateEventArgs.cs
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls
{
public class AuthenticateEventArgs : EventArgs
{
bool authenticated;
public AuthenticateEventArgs (): this (false)
{
}
public AuthenticateEventArgs (bool authenticated)
{
this.authenticated = authenticated;
}
public bool Authenticated {
get { return authenticated; }
set { authenticated = value; }
}
}
}

View File

@@ -0,0 +1,34 @@
//
// System.Web.UI.WebControls.AuthenticateEventHandler.cs
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls
{
public delegate void AuthenticateEventHandler (object sender, AuthenticateEventArgs e);
}

View File

@@ -0,0 +1,69 @@
//
// System.Web.UI.WebControls.AutoCompleteType.cs
//
// Authors:
// Sanjay Gupta (gsanjay@novell.com)
//
// Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls
{
public enum AutoCompleteType
{
None = 0,
Disabled = 1,
Cellular = 2,
Company = 3,
Department = 4,
DisplayName = 5,
Email = 6,
FirstName = 7,
Gender = 8,
HomeCity = 9,
HomeCountryRegion = 10,
HomeFax = 11,
HomePhone = 12,
HomeState = 13,
HomeStreetAddress = 14,
HomeZipCode = 15,
Homepage = 16,
JobTitle = 17,
LastName = 18,
MiddleName = 19,
Notes = 20,
Office = 21,
Pager = 22,
BusinessCity = 23,
BusinessCountryRegion = 24,
BusinessFax = 25,
BusinessPhone = 26,
BusinessState = 27,
BusinessStreetAddress = 28,
BusinessUrl = 29,
BusinessZipCode = 30,
Search = 31,
}
}

View File

@@ -0,0 +1,156 @@
//
// System.Web.UI.WebControls.AutoGeneratedField.cs
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
[EditorBrowsableAttribute (EditorBrowsableState.Never)]
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class AutoGeneratedField : BoundField
{
Type dataType = typeof(string);
internal AutoGeneratedField ()
{
}
public AutoGeneratedField (string dataField)
{
DataField = dataField;
}
internal AutoGeneratedField (AutoGeneratedFieldProperties fieldProperties)
{
DataField = fieldProperties.DataField;
DataType = fieldProperties.Type;
SortExpression = fieldProperties.Name;
HeaderText = fieldProperties.Name;
ReadOnly = fieldProperties.IsReadOnly;
}
public Type DataType {
get { return dataType; }
set { dataType = value; }
}
public override bool ConvertEmptyStringToNull {
get { return true; }
set { throw new NotSupportedException (); }
}
public override string DataFormatString {
get { return string.Empty; }
set { throw new NotSupportedException (); }
}
public override bool InsertVisible {
get { return true; }
set { throw new NotSupportedException (); }
}
[MonoTODO ("Support other data types")]
public override void ExtractValuesFromCell (IOrderedDictionary dictionary,
DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
if (dataType == typeof(bool)) {
bool editable = IsEditable (rowState);
if (editable || includeReadOnly) {
CheckBox box = (CheckBox) cell.Controls [0];
dictionary [DataField] = box.Checked;
}
} else
base.ExtractValuesFromCell (dictionary, cell, rowState, includeReadOnly);
}
[MonoTODO ("Support other data types")]
protected override void InitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState)
{
if (dataType == typeof(bool)) {
bool editable = IsEditable (rowState);
CheckBox box = new CheckBox ();
box.Enabled = editable;
box.ToolTip = HeaderText;
cell.Controls.Add (box);
} else
base.InitializeDataCell (cell, rowState);
}
[MonoTODO ("Support other data types")]
protected override void OnDataBindField (object sender, EventArgs e)
{
DataControlFieldCell cell = (DataControlFieldCell) sender;
if (dataType == typeof(bool)) {
CheckBox box = (CheckBox) cell.Controls [0];
object val = GetValue (cell.BindingContainer);
if (val != null && val != DBNull.Value)
box.Checked = (bool)val;
else
if (string.IsNullOrEmpty (DataField)) {
box.Visible = false;
return;
}
if (!box.Visible)
box.Visible = true;
}
else
base.OnDataBindField (sender, e);
}
public override void ValidateSupportsCallback ()
{
}
protected override DataControlField CreateField ()
{
return new AutoGeneratedField ();
}
protected override void CopyProperties (DataControlField newField)
{
base.CopyProperties (newField);
AutoGeneratedField field = (AutoGeneratedField) newField;
field.DataType = DataType;
}
protected override object GetDesignTimeValue()
{
return base.GetDesignTimeValue ();
}
}
}

View File

@@ -0,0 +1,88 @@
//
// System.Web.UI.WebControls.AutoGeneratedFieldProperties.cs
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Web.UI;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class AutoGeneratedFieldProperties: IStateManager
{
StateBag ViewState = new StateBag ();
public string DataField {
get { return ViewState.GetString ("DataField", String.Empty); }
set { ViewState ["DataField"] = value; }
}
public bool IsReadOnly {
get { return ViewState.GetBool ("IsReadOnly", false); }
set { ViewState ["IsReadOnly"] = value; }
}
public string Name {
get { return ViewState.GetString ("Name", String.Empty); }
set { ViewState ["Name"] = value; }
}
public Type Type {
get {
object ob = ViewState ["Type"];
if (ob != null) return (Type) ob;
return null;
}
set {
ViewState ["Type"] = value;
}
}
void IStateManager.LoadViewState (object state)
{
ViewState.LoadViewState (state);
}
object IStateManager.SaveViewState ()
{
return ViewState.SaveViewState ();
}
void IStateManager.TrackViewState ()
{
ViewState.TrackViewState ();
}
bool IStateManager.IsTrackingViewState {
get { return ViewState.IsTrackingViewState; }
}
}
}

View File

@@ -0,0 +1,272 @@
//
// System.Web.UI.WebControls.BaseCompareValidator
//
// Authors:
// Chris Toshok (toshok@novell.com)
//
// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Text;
using System.Threading;
using System.Globalization;
using System.ComponentModel;
using System.Security.Permissions;
using System.Web.Util;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public abstract class BaseCompareValidator : BaseValidator
{
protected BaseCompareValidator ()
{
}
protected override void AddAttributesToRender (HtmlTextWriter w)
{
if (RenderUplevel) {
if (Page != null) {
RegisterExpandoAttribute (ClientID, "type", Type.ToString ());
switch (Type) {
case ValidationDataType.Date:
DateTimeFormatInfo dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;
string pattern = dateTimeFormat.ShortDatePattern;
string dateorder = (pattern.StartsWith ("y", true, Helpers.InvariantCulture) ? "ymd" : (pattern.StartsWith ("m", true, Helpers.InvariantCulture) ? "mdy" : "dmy"));
RegisterExpandoAttribute (ClientID, "dateorder", dateorder);
RegisterExpandoAttribute (ClientID, "cutoffyear", dateTimeFormat.Calendar.TwoDigitYearMax.ToString ());
break;
case ValidationDataType.Currency:
NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
RegisterExpandoAttribute (ClientID, "decimalchar", numberFormat.CurrencyDecimalSeparator, true);
RegisterExpandoAttribute (ClientID, "groupchar", numberFormat.CurrencyGroupSeparator, true);
RegisterExpandoAttribute (ClientID, "digits", numberFormat.CurrencyDecimalDigits.ToString());
RegisterExpandoAttribute (ClientID, "groupsize", numberFormat.CurrencyGroupSizes [0].ToString ());
break;
}
}
}
base.AddAttributesToRender (w);
}
public static bool CanConvert (string text,
ValidationDataType type)
{
object value;
return Convert (text, type, out value);
}
protected static bool Convert (string text,
ValidationDataType type,
out object value)
{
return BaseCompareValidator.Convert(text, type, false, out value);
}
protected static bool Compare (string left, string right, ValidationCompareOperator op, ValidationDataType type)
{
return BaseCompareValidator.Compare(left, false, right, false, op, type);
}
protected override bool DetermineRenderUplevel ()
{
/* presumably the CompareValidator client side
* code makes use of newer dom/js stuff than
* the rest of the validators. but ours
* doesn't for the moment, so let's just use
* our present implementation
*/
return base.DetermineRenderUplevel();
}
protected static string GetDateElementOrder ()
{
// I hope there's a better way to implement this...
string pattern = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
StringBuilder order = new StringBuilder();
bool seen_date = false;
bool seen_year = false;
bool seen_month = false;
pattern = pattern.ToLower (Helpers.InvariantCulture);
for (int i = 0; i < pattern.Length; i ++) {
char c = pattern[ i ];
if (c != 'm' && c != 'd' && c != 'y')
continue;
if (c == 'm') {
if (!seen_month) order.Append ("m");
seen_month = true;
} else if (c == 'y') {
if (!seen_year) order.Append ("y");
seen_year = true;
} else /* (c == 'd') */ {
if (!seen_date) order.Append ("d");
seen_date = true;
}
}
return order.ToString ();
}
protected static int GetFullYear (int two_digit_year)
{
/* This is an implementation that matches the
* docs on msdn, but MS doesn't seem to go by
* their docs (at least in 1.0). */
int cutoff = CutoffYear;
int twodigitcutoff = cutoff % 100;
if (two_digit_year <= twodigitcutoff)
return cutoff - twodigitcutoff + two_digit_year;
else
return cutoff - twodigitcutoff - 100 + two_digit_year;
}
[DefaultValue (false)]
[Themeable (false)]
public bool CultureInvariantValues {
get { return ViewState.GetBool ("CultureInvariantValues", false); }
set { ViewState ["CultureInvariantValues"] = value; }
}
protected static int CutoffYear {
get { return CultureInfo.CurrentCulture.Calendar.TwoDigitYearMax; }
}
[DefaultValue(ValidationDataType.String)]
[Themeable (false)]
[WebSysDescription("")]
[WebCategory("Behavior")]
public ValidationDataType Type {
get { return ViewState ["Type"] == null ? ValidationDataType.String : (ValidationDataType) ViewState ["Type"]; }
set { ViewState ["Type"] = value; }
}
public static bool CanConvert (string text, ValidationDataType type, bool cultureInvariant)
{
object value;
return Convert(text, type, cultureInvariant, out value);
}
protected static bool Compare (string left,
bool cultureInvariantLeftText,
string right,
bool cultureInvariantRightText,
ValidationCompareOperator op,
ValidationDataType type)
{
object lo, ro;
if (!Convert(left, type, cultureInvariantLeftText, out lo))
return false;
/* DataTypeCheck is a unary operator that only
* depends on the lhs */
if (op == ValidationCompareOperator.DataTypeCheck)
return true;
/* pretty crackladen, but if we're unable to
* convert the rhs to @type, the comparison
* succeeds */
if (!Convert(right, type, cultureInvariantRightText, out ro))
return true;
int comp = ((IComparable)lo).CompareTo((IComparable)ro);
switch (op) {
case ValidationCompareOperator.Equal:
return comp == 0;
case ValidationCompareOperator.NotEqual:
return comp != 0;
case ValidationCompareOperator.LessThan:
return comp < 0;
case ValidationCompareOperator.LessThanEqual:
return comp <= 0;
case ValidationCompareOperator.GreaterThan:
return comp > 0;
case ValidationCompareOperator.GreaterThanEqual:
return comp >= 0;
default:
return false;
}
}
protected static bool Convert (string text, ValidationDataType type, bool cultureInvariant,out object value)
{
try {
switch (type) {
case ValidationDataType.String:
value = text;
return value != null;
case ValidationDataType.Integer:
IFormatProvider intFormatProvider = (cultureInvariant) ? NumberFormatInfo.InvariantInfo :
NumberFormatInfo.CurrentInfo;
value = Int32.Parse(text, intFormatProvider);
return true;
case ValidationDataType.Double:
IFormatProvider doubleFormatProvider = (cultureInvariant) ? NumberFormatInfo.InvariantInfo :
NumberFormatInfo.CurrentInfo;
value = Double.Parse(text, doubleFormatProvider);
return true;
case ValidationDataType.Date:
IFormatProvider dateFormatProvider = (cultureInvariant) ? DateTimeFormatInfo.InvariantInfo :
DateTimeFormatInfo.CurrentInfo;
value = DateTime.Parse(text, dateFormatProvider);
return true;
case ValidationDataType.Currency:
IFormatProvider currencyFormatProvider = (cultureInvariant) ? NumberFormatInfo.InvariantInfo :
NumberFormatInfo.CurrentInfo;
value = Decimal.Parse(text, NumberStyles.Currency, currencyFormatProvider);
return true;
default:
value = null;
return false;
}
} catch {
value = null;
return false;
}
}
}
}

View File

@@ -0,0 +1,205 @@
//
// System.Web.UI.WebControls.BaseDataBoundControl.cs
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// Copyright (C) 2004-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultProperty ("DataSourceID")]
[DesignerAttribute ("System.Web.UI.Design.WebControls.BaseDataBoundControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
public abstract class BaseDataBoundControl: WebControl
{
static readonly object dataBoundEvent = new object ();
EventHandlerList events = new EventHandlerList ();
object dataSource;
bool initialized;
bool preRendered;
bool requiresDataBinding;
public event EventHandler DataBound {
add { events.AddHandler (dataBoundEvent, value); }
remove { events.RemoveHandler (dataBoundEvent, value); }
}
protected BaseDataBoundControl ()
{
}
/* Used for controls that used to inherit from
* WebControl, so the tag can propagate upwards
*/
internal BaseDataBoundControl (HtmlTextWriterTag tag) : base (tag)
{
}
[BindableAttribute (true)]
[ThemeableAttribute (false)]
[DefaultValueAttribute (null)]
[DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility.Hidden)]
public virtual object DataSource {
get { return dataSource; }
set {
if(value!=null)
ValidateDataSource (value);
dataSource = value;
OnDataPropertyChanged ();
}
}
[DefaultValueAttribute ("")]
[ThemeableAttribute (false)]
public virtual string DataSourceID {
get { return ViewState.GetString ("DataSourceID", String.Empty); }
set {
ViewState["DataSourceID"] = value;
OnDataPropertyChanged ();
}
}
protected bool Initialized {
get { return initialized; }
}
protected bool IsBoundUsingDataSourceID {
get { return DataSourceID.Length > 0; }
}
protected bool RequiresDataBinding {
get { return requiresDataBinding; }
set {
// MSDN: If you set the RequiresDataBinding
// property to true when the data-bound control
// has already begun to render its output to the
// page, the current HTTP request is not a
// callback, and you are using the DataSourceID
// property to identify the data source control
// to bind to, the DataBind method is called
// immediately. In this case, the
// RequiresDataBinding property is _not_ actually
// set to true.
//
// LAMESPEC, the docs quoted above mention that
// DataBind is called in the described
// case. This is wrong since that way we don't
// break recursion when the property is set from
// within the OnSelect handler in user's
// code. EnsureDataBound makes sure that no
// recursive binding is performed. Also the
// property DOES get set in this case (according
// to tests)
if (value && preRendered && IsBoundUsingDataSourceID && Page != null && !Page.IsCallback) {
requiresDataBinding = true;
EnsureDataBound ();
} else
requiresDataBinding = value;
}
}
#if NET_4_0
public override bool SupportsDisabledAttribute {
get { return RenderingCompatibilityLessThan40; }
}
#endif
protected void ConfirmInitState ()
{
initialized = true;
}
public override void DataBind ()
{
PerformSelect ();
}
protected virtual void EnsureDataBound ()
{
if (RequiresDataBinding && IsBoundUsingDataSourceID)
DataBind ();
}
protected virtual void OnDataBound (EventArgs e)
{
EventHandler eh = events [dataBoundEvent] as EventHandler;
if (eh != null)
eh (this, e);
}
protected virtual void OnDataPropertyChanged ()
{
if (Initialized)
RequiresDataBinding = true;
}
protected internal override void OnInit (EventArgs e)
{
base.OnInit (e);
Page.PreLoad += new EventHandler (OnPagePreLoad);
if (!IsViewStateEnabled && Page != null && Page.IsPostBack)
RequiresDataBinding = true;
}
protected virtual void OnPagePreLoad (object sender, EventArgs e)
{
ConfirmInitState ();
}
protected internal override void OnPreRender (EventArgs e)
{
preRendered = true;
EnsureDataBound ();
base.OnPreRender (e);
}
internal Control FindDataSource ()
{
Control ctrl;
Control namingContainer = NamingContainer;
string dataSourceID = DataSourceID;
while (namingContainer != null) {
ctrl = namingContainer.FindControl (dataSourceID);
if (ctrl != null)
return ctrl;
namingContainer = namingContainer.NamingContainer;
}
return null;
}
protected abstract void PerformSelect ();
protected abstract void ValidateDataSource (object dataSource);
}
}

View File

@@ -0,0 +1,489 @@
//
// System.Web.UI.WebControls.BaseDataList.cs
//
// Author:
// Sebastien Pouliot <sebastien@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultEvent ("SelectedIndexChanged")]
[DefaultProperty ("DataSource")]
[Designer ("System.Web.UI.Design.WebControls.BaseDataListDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
public abstract class BaseDataList : WebControl
{
static readonly object selectedIndexChangedEvent = new object ();
DataKeyCollection keycoll;
object source;
//string dataSourceId;
IDataSource boundDataSource = null;
bool initialized;
bool requiresDataBinding;
DataSourceSelectArguments selectArguments;
IEnumerable data;
protected BaseDataList ()
{
}
[DefaultValue ("")]
[Localizable (true)]
[WebSysDescription ("")]
[WebCategory ("Accessibility")]
public virtual string Caption {
get { return ViewState.GetString ("Caption", String.Empty); }
set {
if (value == null)
ViewState.Remove ("Caption");
else
ViewState ["Caption"] = value;
}
}
[DefaultValue (TableCaptionAlign.NotSet)]
public virtual TableCaptionAlign CaptionAlign {
get { return (TableCaptionAlign) ViewState.GetInt ("CaptionAlign", (int)TableCaptionAlign.NotSet); }
set {
if ((value < TableCaptionAlign.NotSet) || (value > TableCaptionAlign.Right))
throw new ArgumentOutOfRangeException (Locale.GetText ("Invalid TableCaptionAlign value."));
ViewState ["CaptionAlign"] = value;
}
}
[DefaultValue (-1)]
[WebSysDescription("")]
[WebCategory("Layout")]
public virtual int CellPadding {
get {
if (!ControlStyleCreated)
return -1; // default value
return TableStyle.CellPadding;
}
set { TableStyle.CellPadding = value; }
}
[DefaultValue (0)]
[WebSysDescription("")]
[WebCategory("Layout")]
public virtual int CellSpacing {
get {
if (!ControlStyleCreated)
return 0; // default value
return TableStyle.CellSpacing;
}
set { TableStyle.CellSpacing = value; }
}
public override ControlCollection Controls {
get {
EnsureChildControls ();
return base.Controls;
}
}
[DefaultValue ("")]
[Themeable (false)]
[MonoTODO ("incomplete")]
[WebSysDescription("")]
[WebCategory("Data")]
public virtual string DataKeyField {
get { return ViewState.GetString ("DataKeyField", String.Empty); }
set {
if (value == null)
ViewState.Remove ("DataKeyField");
else
ViewState ["DataKeyField"] = value;
}
}
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[WebSysDescription("")]
[WebCategory("Data")]
public DataKeyCollection DataKeys {
get {
if (keycoll == null)
keycoll = new DataKeyCollection (DataKeysArray);
return keycoll;
}
}
protected ArrayList DataKeysArray {
get {
ArrayList keys = (ArrayList) ViewState ["DataKeys"];
if (keys == null) {
keys = new ArrayList ();
ViewState ["DataKeys"] = keys;
}
return keys;
}
}
[DefaultValue ("")]
[Themeable (false)]
[WebSysDescription("")]
[WebCategory("Data")]
public string DataMember {
get { return ViewState.GetString ("DataMember", String.Empty); }
set {
if (value == null)
ViewState.Remove ("DataMember");
else
ViewState ["DataMember"] = value;
OnDataPropertyChanged ();
}
}
[Bindable (true)]
[DefaultValue (null)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
[Themeable (false)]
[WebSysDescription("")]
[WebCategory("Data")]
public virtual object DataSource {
get { return source; }
set {
if ((value == null) || (value is IEnumerable) || (value is IListSource)) {
// FIXME - can't duplicate in a test case ? LAMESPEC ?
// can't duplicate in a test case
// if ((dataSourceId != null) && (dataSourceId.Length != 0))
// throw new HttpException (Locale.GetText ("DataSourceID is already set."));
source = value;
OnDataPropertyChanged ();
} else {
string msg = Locale.GetText ("Invalid data source. This requires an object implementing {0} or {1}.",
"IEnumerable", "IListSource");
throw new ArgumentException (msg);
}
}
}
[DefaultValue (GridLines.Both)]
[WebSysDescription("")]
[WebCategory("Appearance")]
public virtual GridLines GridLines {
get {
if (!ControlStyleCreated)
return GridLines.Both; // default value
return TableStyle.GridLines;
}
set { TableStyle.GridLines = value; }
}
[Category ("Layout")]
[DefaultValue (HorizontalAlign.NotSet)]
[WebSysDescription("")]
public virtual HorizontalAlign HorizontalAlign {
get {
if (!ControlStyleCreated)
return HorizontalAlign.NotSet; // default value
return TableStyle.HorizontalAlign;
}
set { TableStyle.HorizontalAlign = value; }
}
[DefaultValue (false)]
public virtual bool UseAccessibleHeader {
get { return ViewState.GetBool ("UseAccessibleHeader", false); }
set { ViewState ["UseAccessibleHeader"] = value; }
}
[DefaultValue ("")]
[IDReferenceProperty (typeof (DataSourceControl))]
[Themeable (false)]
public virtual string DataSourceID {
get { return ViewState.GetString ("DataSourceID", String.Empty); }
set {
// LAMESPEC ? this is documented as an HttpException in beta2
if (source != null)
throw new InvalidOperationException (Locale.GetText ("DataSource is already set."));
ViewState ["DataSourceID"] = value;
OnDataPropertyChanged ();
}
}
protected bool Initialized {
get { return initialized; }
}
// as documented in BaseDataBoundControl
protected bool IsBoundUsingDataSourceID {
get { return (DataSourceID.Length != 0); }
}
// doc says ?automatically? called by ASP.NET
protected bool RequiresDataBinding {
get { return requiresDataBinding; }
set { requiresDataBinding = value; }
}
protected DataSourceSelectArguments SelectArguments {
get {
if (selectArguments == null)
selectArguments = CreateDataSourceSelectArguments ();
return selectArguments;
}
}
#if NET_4_0
public override bool SupportsDisabledAttribute {
get { return RenderingCompatibilityLessThan40; }
}
#endif
TableStyle TableStyle {
// this will throw an InvalidCasException just like we need
get { return (TableStyle) ControlStyle; }
}
protected override void AddParsedSubObject (object obj)
{
// don't accept controls
}
// see Kothari, page 435
protected internal override void CreateChildControls ()
{
// We are recreating the children from viewstate
if (HasControls ())
base.Controls.Clear();
if (IsDataBound)
CreateControlHierarchy (false);
else if (RequiresDataBinding)
EnsureDataBound ();
}
protected abstract void CreateControlHierarchy (bool useDataSource);
// see Kothari, page 434
// see also: Control.DataBind on Fx 2.0 beta2 documentation
public override void DataBind ()
{
// unlike most samples we don't call base.OnDataBinding
// because we override it in this class
OnDataBinding (EventArgs.Empty);
// Clear, if required, then recreate the control hierarchy
if (HasControls ())
Controls.Clear ();
if (HasChildViewState)
ClearChildViewState ();
if (!IsTrackingViewState)
TrackViewState ();
CreateControlHierarchy (true);
// Indicate that child controls have been created, preventing
// CreateChildControls from getting called.
ChildControlsCreated = true;
RequiresDataBinding = false;
IsDataBound = true;
}
protected virtual DataSourceSelectArguments CreateDataSourceSelectArguments ()
{
return DataSourceSelectArguments.Empty;
}
// best documentation is (again) in BaseDataBoundControl
protected void EnsureDataBound ()
{
if (IsBoundUsingDataSourceID && RequiresDataBinding)
DataBind ();
}
void SelectCallback (IEnumerable data)
{
this.data = data;
}
protected virtual IEnumerable GetData ()
{
if (DataSourceID.Length == 0)
return null;
if (boundDataSource == null)
ConnectToDataSource ();
DataSourceView dsv = boundDataSource.GetView (String.Empty);
dsv.Select (SelectArguments, new DataSourceViewSelectCallback (SelectCallback));
return data;
}
bool IsDataBound {
get {
return ViewState.GetBool ("_DataBound", false);
}
set {
ViewState ["_DataBound"] = value;
}
}
protected override void OnDataBinding (EventArgs e)
{
base.OnDataBinding (e);
}
protected virtual void OnDataPropertyChanged ()
{
if (Initialized)
RequiresDataBinding = true;
}
protected virtual void OnDataSourceViewChanged (object sender, EventArgs e)
{
RequiresDataBinding = true;
}
protected internal override void OnInit (EventArgs e)
{
base.OnInit (e);
Page page = Page;
if (page != null) {
page.PreLoad += new EventHandler (OnPagePreLoad);
if (!IsViewStateEnabled && page.IsPostBack)
RequiresDataBinding = true;
}
}
void OnPagePreLoad (object sender, EventArgs e)
{
if (!Initialized)
Initialize ();
}
protected internal override void OnLoad (EventArgs e)
{
if (!Initialized)
Initialize ();
base.OnLoad (e);
}
void Initialize ()
{
Page page = Page;
if (page != null) {
if (!page.IsPostBack || (IsViewStateEnabled && !IsDataBound))
RequiresDataBinding = true;
}
if (IsBoundUsingDataSourceID)
ConnectToDataSource ();
initialized = true;
}
protected internal override void OnPreRender (EventArgs e)
{
EnsureDataBound ();
base.OnPreRender (e);
}
protected virtual void OnSelectedIndexChanged (EventArgs e)
{
EventHandler selectedIndexChanged = (EventHandler) Events [selectedIndexChangedEvent];
if (selectedIndexChanged != null)
selectedIndexChanged (this, e);
}
protected abstract void PrepareControlHierarchy ();
protected internal override void Render (HtmlTextWriter writer)
{
PrepareControlHierarchy ();
// don't call base class or RenderBegin|EndTag
// or we'll get an extra <span></span>
RenderContents (writer);
}
[WebSysDescription("")]
[WebCategory("Action")]
public event EventHandler SelectedIndexChanged {
add { Events.AddHandler (selectedIndexChangedEvent, value); }
remove { Events.RemoveHandler (selectedIndexChangedEvent, value); }
}
static public bool IsBindableType (Type type)
{
// I can't believe how many NRE are possible in System.Web
if (type == null) // Type.GetTypeCode no longer throws when a null is passed.
throw new NullReferenceException ();
switch (Type.GetTypeCode (type)) {
case TypeCode.Boolean:
case TypeCode.Byte:
case TypeCode.SByte:
case TypeCode.Int16:
case TypeCode.UInt16:
case TypeCode.Int32:
case TypeCode.UInt32:
case TypeCode.Int64:
case TypeCode.UInt64:
case TypeCode.Char:
case TypeCode.Double:
case TypeCode.Single:
case TypeCode.DateTime:
case TypeCode.Decimal:
case TypeCode.String:
return true;
default:
return false;
}
}
void ConnectToDataSource ()
{
if (NamingContainer != null)
boundDataSource = (NamingContainer.FindControl (DataSourceID) as IDataSource);
if (boundDataSource == null) {
if (Parent != null)
boundDataSource = (Parent.FindControl (DataSourceID) as IDataSource);
if (boundDataSource == null)
throw new HttpException (Locale.GetText ("Coulnd't find a DataSource named '{0}'.", DataSourceID));
}
DataSourceView dsv = boundDataSource.GetView (String.Empty);
dsv.DataSourceViewChanged += new EventHandler (OnDataSourceViewChanged);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,459 @@
//
// System.Web.UI.WebControls.BaseValidator
//
// Authors:
// Chris Toshok (toshok@novell.com)
//
// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Web.Configuration;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Collections;
using System.Security.Permissions;
namespace System.Web.UI.WebControls
{
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
// attributes
[DefaultProperty("ErrorMessage")]
[Designer("System.Web.UI.Design.WebControls.BaseValidatorDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
public abstract class BaseValidator : Label, IValidator
{
bool render_uplevel;
bool valid;
Color forecolor;
bool pre_render_called = false;
protected BaseValidator ()
{
this.valid = true;
this.ForeColor = Color.Red;
}
// New in NET1.1 sp1
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
public override string AssociatedControlID {
get { return base.AssociatedControlID; }
set { base.AssociatedControlID = value; }
}
[Themeable (false)]
[DefaultValue ("")]
public virtual string ValidationGroup {
get { return ViewState.GetString ("ValidationGroup", String.Empty); }
set { ViewState["ValidationGroup"] = value; }
}
[Themeable (false)]
[DefaultValue (false)]
public bool SetFocusOnError {
get { return ViewState.GetBool ("SetFocusOnError", false); }
set { ViewState["SetFocusOnError"] = value; }
}
/* listed in corcompare */
[MonoTODO("Why override?")]
[PersistenceMode (PersistenceMode.InnerDefaultProperty)]
[DefaultValue ("")]
public override string Text
{
get { return base.Text; }
set { base.Text = value; }
}
[IDReferenceProperty (typeof (Control))]
[Themeable (false)]
[TypeConverter(typeof(System.Web.UI.WebControls.ValidatedControlConverter))]
[DefaultValue("")]
[WebSysDescription ("")]
[WebCategory ("Behavior")]
public string ControlToValidate {
get { return ViewState.GetString ("ControlToValidate", String.Empty); }
set { ViewState ["ControlToValidate"] = value; }
}
[Themeable (false)]
[DefaultValue(ValidatorDisplay.Static)]
[WebSysDescription ("")]
[WebCategory ("Appearance")]
public ValidatorDisplay Display {
get { return (ValidatorDisplay)ViewState.GetInt ("Display", (int)ValidatorDisplay.Static); }
set { ViewState ["Display"] = (int)value; }
}
[Themeable (false)]
[DefaultValue(true)]
[WebSysDescription ("")]
[WebCategory ("Behavior")]
public bool EnableClientScript {
get { return ViewState.GetBool ("EnableClientScript", true); }
set { ViewState ["EnableClientScript"] = value; }
}
public override bool Enabled {
get { return ViewState.GetBool ("BaseValidatorEnabled", true); }
set { ViewState ["BaseValidatorEnabled"] = value; }
}
[Localizable (true)]
[DefaultValue("")]
[WebSysDescription ("")]
[WebCategory ("Appearance")]
public string ErrorMessage {
get { return ViewState.GetString ("ErrorMessage", String.Empty); }
set { ViewState ["ErrorMessage"] = value; }
}
[DefaultValue(typeof (Color), "Red")]
public override Color ForeColor {
get { return forecolor; }
set {
forecolor = value;
base.ForeColor = value;
}
}
[Browsable(false)]
[DefaultValue(true)]
[Themeable (false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[WebSysDescription ("")]
[WebCategory ("Misc")]
public bool IsValid {
get { return valid; }
set { valid = value; }
}
protected bool PropertiesValid {
get {
Control control = NamingContainer.FindControl (ControlToValidate);
if (control == null)
return false;
else
return true;
}
}
protected bool RenderUplevel {
get { return render_uplevel; }
}
internal bool GetRenderUplevel ()
{
return render_uplevel;
}
protected override void AddAttributesToRender (HtmlTextWriter writer)
{
/* if we're rendering uplevel, add our attributes */
if (render_uplevel) {
/* force an ID here if we weren't assigned one */
if (ID == null)
writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
if (ControlToValidate != String.Empty)
RegisterExpandoAttribute (ClientID, "controltovalidate", GetControlRenderID (ControlToValidate));
if (ErrorMessage != String.Empty)
RegisterExpandoAttribute (ClientID, "errormessage", ErrorMessage, true);
if (ValidationGroup != String.Empty)
RegisterExpandoAttribute (ClientID, "validationGroup", ValidationGroup, true);
if (SetFocusOnError)
RegisterExpandoAttribute (ClientID, "focusOnError", "t");
bool enabled = IsEnabled;
if (!enabled)
RegisterExpandoAttribute (ClientID, "enabled", "False");
if (enabled && !IsValid)
RegisterExpandoAttribute (ClientID, "isvalid", "False");
else {
if (Display == ValidatorDisplay.Static)
writer.AddStyleAttribute ("visibility", "hidden");
else
writer.AddStyleAttribute ("display", "none");
}
if (Display != ValidatorDisplay.Static)
RegisterExpandoAttribute (ClientID, "display", Display.ToString ());
}
base.AddAttributesToRender (writer);
}
internal void RegisterExpandoAttribute (string controlId, string attributeName, string attributeValue)
{
RegisterExpandoAttribute (controlId, attributeName, attributeValue, false);
}
internal void RegisterExpandoAttribute (string controlId, string attributeName, string attributeValue, bool encode)
{
Page page = Page;
if (page.ScriptManager != null)
page.ScriptManager.RegisterExpandoAttributeExternal (this, controlId, attributeName, attributeValue, encode);
else
page.ClientScript.RegisterExpandoAttribute (controlId, attributeName, attributeValue, encode);
}
protected void CheckControlValidationProperty (string name, string propertyName)
{
Control control = NamingContainer.FindControl (name);
PropertyDescriptor prop = null;
if (control == null)
throw new HttpException (String.Format ("Unable to find control id '{0}'.", name));
prop = BaseValidator.GetValidationProperty (control);
if (prop == null)
throw new HttpException (String.Format ("Unable to find ValidationProperty attribute '{0}' on control '{1}'", propertyName, name));
}
protected virtual bool ControlPropertiesValid ()
{
if (ControlToValidate.Length == 0) {
throw new HttpException (String.Format ("ControlToValidate property of '{0}' cannot be blank.", ID));
}
CheckControlValidationProperty (ControlToValidate, String.Empty);
return true;
}
protected virtual bool DetermineRenderUplevel ()
{
if (!EnableClientScript)
return false;
#if TARGET_J2EE
if (HttpContext.Current == null)
return false;
return (
/* From someplace on the web: "JavaScript 1.2
* and later (also known as ECMAScript) has
* built-in support for regular
* expressions" */
((Page.Request.Browser.EcmaScriptVersion.Major == 1
&& Page.Request.Browser.EcmaScriptVersion.Minor >= 2)
|| (Page.Request.Browser.EcmaScriptVersion.Major > 1))
/* document.getElementById, .getAttribute,
* etc, are all DOM level 1. I don't think we
* use anything in level 2.. */
&& Page.Request.Browser.W3CDomVersion.Major >= 1);
#else
return UplevelHelper.IsUplevel (
System.Web.Configuration.HttpCapabilitiesBase.GetUserAgentForDetection (HttpContext.Current.Request));
#endif
}
protected abstract bool EvaluateIsValid ();
protected string GetControlRenderID (string name)
{
Control control = NamingContainer.FindControl (name);
if (control == null)
return null;
return control.ClientID;
}
protected string GetControlValidationValue (string name)
{
Control control = NamingContainer.FindControl (name);
if (control == null)
return null;
PropertyDescriptor prop = BaseValidator.GetValidationProperty (control);
if (prop == null)
return null;
object o = prop.GetValue (control);
if (o == null)
return String.Empty;
if (o is ListItem)
return ((ListItem) o).Value;
return o.ToString ();
}
public static PropertyDescriptor GetValidationProperty (object o)
{
PropertyDescriptorCollection props;
System.ComponentModel.AttributeCollection col;
props = TypeDescriptor.GetProperties (o);
col = TypeDescriptor.GetAttributes (o);
foreach (Attribute at in col) {
ValidationPropertyAttribute vpa = at as ValidationPropertyAttribute;
if (vpa != null && vpa.Name != null)
return props[vpa.Name];
}
return null;
}
protected internal override void OnInit (EventArgs e)
{
Page page = Page;
/* according to an msdn article, this is done here */
if (page != null) {
page.Validators.Add (this);
page.GetValidators (ValidationGroup).Add (this);
}
base.OnInit (e);
}
protected internal override void OnPreRender (EventArgs e)
{
base.OnPreRender (e);
pre_render_called = true;
ControlPropertiesValid ();
render_uplevel = DetermineRenderUplevel ();
if (render_uplevel)
RegisterValidatorCommonScript ();
}
protected internal override void OnUnload (EventArgs e)
{
Page page = Page;
/* according to an msdn article, this is done here */
if (page != null) {
page.Validators.Remove (this);
string validationGroup = ValidationGroup;
if (!String.IsNullOrEmpty (validationGroup))
page.GetValidators (ValidationGroup).Remove (this);
}
base.OnUnload (e);
}
protected void RegisterValidatorCommonScript ()
{
Page page = Page;
if (page != null) {
if (page.ScriptManager != null) {
page.ScriptManager.RegisterClientScriptResourceExternal (this, typeof (BaseValidator), "WebUIValidation_2.0.js");
page.ScriptManager.RegisterClientScriptBlockExternal (this, typeof (BaseValidator), "ValidationInitializeScript", page.ValidationInitializeScript, true);
page.ScriptManager.RegisterOnSubmitStatementExternal (this, typeof (BaseValidator), "ValidationOnSubmitStatement", page.ValidationOnSubmitStatement);
page.ScriptManager.RegisterStartupScriptExternal (this, typeof (BaseValidator), "ValidationStartupScript", page.ValidationStartupScript, true);
} else if (!page.ClientScript.IsClientScriptIncludeRegistered (typeof (BaseValidator), "Mono-System.Web-ValidationClientScriptBlock")) {
page.ClientScript.RegisterClientScriptInclude (typeof (BaseValidator), "Mono-System.Web-ValidationClientScriptBlock",
page.ClientScript.GetWebResourceUrl (typeof (BaseValidator), "WebUIValidation_2.0.js"));
page.ClientScript.RegisterClientScriptBlock (typeof (BaseValidator), "Mono-System.Web-ValidationClientScriptBlock.Initialize", page.ValidationInitializeScript, true);
page.ClientScript.RegisterOnSubmitStatement (typeof (BaseValidator), "Mono-System.Web-ValidationOnSubmitStatement", page.ValidationOnSubmitStatement);
page.ClientScript.RegisterStartupScript (typeof (BaseValidator), "Mono-System.Web-ValidationStartupScript", page.ValidationStartupScript, true);
}
}
}
protected virtual void RegisterValidatorDeclaration ()
{
Page page = Page;
if (page != null) {
if (page.ScriptManager != null) {
page.ScriptManager.RegisterArrayDeclarationExternal (this, "Page_Validators", String.Concat ("document.getElementById ('", ClientID, "')"));
page.ScriptManager.RegisterStartupScriptExternal (this, typeof (BaseValidator), ClientID + "DisposeScript",
@"
document.getElementById('" + ClientID + @"').dispose = function() {
Array.remove(Page_Validators, document.getElementById('" + ClientID + @"'));
}
", true);
} else
page.ClientScript.RegisterArrayDeclaration ("Page_Validators", String.Concat ("document.getElementById ('", ClientID, "')"));
}
}
protected internal override void Render (HtmlTextWriter writer)
{
if (!IsEnabled && !EnableClientScript)
return;
if (render_uplevel) {
/* according to an msdn article, this is done here */
RegisterValidatorDeclaration ();
}
bool render_tags = false;
bool render_text = false;
bool render_nbsp = false;
bool v = IsValid;
if (!pre_render_called) {
render_tags = true;
render_text = true;
} else if (render_uplevel) {
render_tags = true;
render_text = Display != ValidatorDisplay.None;
} else {
if (Display != ValidatorDisplay.None) {
render_tags = !v;
render_text = !v;
render_nbsp = v && Display == ValidatorDisplay.Static;
}
}
if (render_tags) {
AddAttributesToRender (writer);
writer.RenderBeginTag (HtmlTextWriterTag.Span);
}
if (render_text || render_nbsp) {
string text;
if (render_text) {
text = Text;
if (String.IsNullOrEmpty (text))
text = ErrorMessage;
} else
text = "&nbsp;";
writer.Write (text);
}
if (render_tags)
writer.RenderEndTag ();
}
/* the docs say "public sealed" here */
public void Validate ()
{
if (IsEnabled && Visible)
IsValid = ControlPropertiesValid () && EvaluateIsValid ();
else
IsValid = true;
}
}
}

View File

@@ -0,0 +1,44 @@
//
// System.Web.UI.WebControls.BorderStyle.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls
{
public enum BorderStyle
{
NotSet,
None,
Dotted,
Dashed,
Solid,
Double,
Groove,
Ridge,
Inset,
Outset
}
}

View File

@@ -0,0 +1,157 @@
//
// System.Web.UI.WebControls.BoundColumn.cs
//
// Author:
// Dick Porter <dick@ximian.com>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.ComponentModel;
using System.Security.Permissions;
namespace System.Web.UI.WebControls {
// CAS
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class BoundColumn : DataGridColumn
{
string data_format_string;
public BoundColumn ()
{
}
public static readonly string thisExpr = "!";
[DefaultValue("")]
[WebSysDescription ("")]
[WebCategory ("Misc")]
public virtual string DataField
{
get {
return ViewState.GetString ("DataField", String.Empty);
}
set {
ViewState ["DataField"] = value;
}
}
[DefaultValue("")]
[WebSysDescription ("")]
[WebCategory ("Misc")]
public virtual string DataFormatString
{
get {
return ViewState.GetString ("DataFormatString", String.Empty);
}
set {
ViewState ["DataFormatString"] = value;
}
}
[DefaultValue(false)]
[WebSysDescription ("")]
[WebCategory ("Misc")]
public virtual bool ReadOnly
{
get {
return ViewState.GetBool ("ReadOnly", false);
}
set {
ViewState ["ReadOnly"] = value;
}
}
public override void Initialize ()
{
data_format_string = DataFormatString;
}
public override void InitializeCell (TableCell cell, int columnIndex,
ListItemType itemType)
{
base.InitializeCell (cell, columnIndex, itemType);
string df = DataField;
switch (itemType) {
case ListItemType.Item:
case ListItemType.SelectedItem:
case ListItemType.AlternatingItem:
if (df != null && df.Length != 0)
cell.DataBinding += new EventHandler (ItemDataBinding);
break;
case ListItemType.EditItem:
if (ReadOnly && df != null && df.Length != 0) {
cell.DataBinding += new EventHandler (ItemDataBinding);
break;
}
TextBox tb = new TextBox ();
if (df != null && df.Length != 0)
tb.DataBinding += new EventHandler (ItemDataBinding);
cell.Controls.Add (tb);
break;
}
}
protected virtual string FormatDataValue (object dataValue)
{
if (dataValue == null)
return "";
if (data_format_string == String.Empty)
return dataValue.ToString ();
return String.Format (data_format_string, dataValue);
}
string GetValueFromItem (DataGridItem item)
{
object val;
if (DataField != thisExpr) {
val = DataBinder.Eval (item.DataItem, DataField);
} else {
val = item.DataItem;
}
string text = FormatDataValue (val);
return (text != "" ? text : "&nbsp;");
}
void ItemDataBinding (object sender, EventArgs e)
{
Control ctrl = (Control) sender;
string text = GetValueFromItem ((DataGridItem) ctrl.NamingContainer);
TableCell cell = sender as TableCell;
if (cell == null) {
TextBox tb = (TextBox) sender;
tb.Text = text;
} else {
cell.Text = text;
}
}
}
}

View File

@@ -0,0 +1,308 @@
//
// System.Web.UI.WebControls.BoundField.cs
//
// Authors:
// Lluis Sanchez Gual (lluis@novell.com)
//
// (C) 2005-2010 Novell, Inc (http://www.novell.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Collections.Specialized;
using System.Web.UI;
using System.ComponentModel;
using System.Security.Permissions;
using System.Reflection;
namespace System.Web.UI.WebControls
{
[AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class BoundField : DataControlField
{
public static readonly string ThisExpression = "!";
//PropertyDescriptor boundProperty;
[DefaultValueAttribute (false)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual bool ApplyFormatInEditMode {
get { return ViewState.GetBool ("ApplyFormatInEditMode", false); }
set { ViewState ["ApplyFormatInEditMode"] = value; }
}
[DefaultValueAttribute (true)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual bool ConvertEmptyStringToNull {
get { return ViewState.GetBool ("ConvertEmptyStringToNull", true); }
set {
ViewState ["ConvertEmptyStringToNull"] = value;
OnFieldChanged ();
}
}
[TypeConverterAttribute ("System.Web.UI.Design.DataSourceViewSchemaConverter, " + Consts.AssemblySystem_Design)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Data")]
[DefaultValueAttribute ("")]
public virtual string DataField {
get { return ViewState.GetString ("DataField", String.Empty); }
set {
ViewState ["DataField"] = value;
OnFieldChanged ();
}
}
[DefaultValueAttribute ("")]
[WebSysDescription ("")]
[WebCategoryAttribute ("Data")]
public virtual string DataFormatString {
get { return ViewState.GetString ("DataFormatString", String.Empty); }
set {
ViewState ["DataFormatString"] = value;
OnFieldChanged ();
}
}
[WebSysDescription ("")]
[WebCategoryAttribute ("Appearance")]
public override string HeaderText {
get { return ViewState.GetString ("HeaderText", String.Empty); }
set {
ViewState["HeaderText"] = value;
OnFieldChanged ();
}
}
[DefaultValueAttribute ("")]
[WebCategoryAttribute ("Behavior")]
public virtual string NullDisplayText {
get { return ViewState.GetString ("NullDisplayText", String.Empty); }
set {
ViewState ["NullDisplayText"] = value;
OnFieldChanged ();
}
}
[DefaultValueAttribute (false)]
[WebSysDescription ("")]
[WebCategoryAttribute ("Behavior")]
public virtual bool ReadOnly {
get { return ViewState.GetBool ("ReadOnly", false); }
set {
ViewState ["ReadOnly"] = value;
OnFieldChanged ();
}
}
[DefaultValueAttribute (true)]
[WebSysDescription ("")]
[WebCategoryAttribute ("HtmlEncode")]
public virtual bool HtmlEncode {
get { return ViewState.GetBool ("HtmlEncode", true); }
set {
ViewState ["HtmlEncode"] = value;
OnFieldChanged ();
}
}
[DefaultValue (true)]
public virtual bool HtmlEncodeFormatString {
get { return ViewState.GetBool ("HtmlEncodeFormatString", true); }
set {
ViewState ["HtmlEncodeFormatString"] = value;
OnFieldChanged ();
}
}
public override void ExtractValuesFromCell (IOrderedDictionary dictionary,
DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
bool editable = IsEditable (rowState);
if (editable) {
if (cell.Controls.Count > 0) {
TextBox box = (TextBox) cell.Controls [0];
dictionary [DataField] = box.Text;
}
} else if (includeReadOnly)
dictionary [DataField] = cell.Text;
}
public override bool Initialize (bool enableSorting, Control control)
{
return base.Initialize (enableSorting, control);
}
public override void InitializeCell (DataControlFieldCell cell,
DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
base.InitializeCell (cell, cellType, rowState, rowIndex);
if (cellType == DataControlCellType.DataCell) {
InitializeDataCell (cell, rowState);
if ((rowState & DataControlRowState.Insert) == 0)
cell.DataBinding += new EventHandler (OnDataBindField);
}
}
protected virtual void InitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState)
{
bool editable = IsEditable (rowState);
if (editable) {
TextBox box = new TextBox ();
cell.Controls.Add (box);
box.ToolTip = HeaderText;
}
}
internal bool IsEditable (DataControlRowState rowState)
{
return ((rowState & DataControlRowState.Edit) != 0 && !ReadOnly) || ((rowState & DataControlRowState.Insert) != 0 && InsertVisible);
}
protected virtual bool SupportsHtmlEncode {
get { return true; }
}
protected virtual string FormatDataValue (object value, bool encode)
{
string res;
bool htmlEncodeFormatString = HtmlEncodeFormatString;
string stringValue = (value != null) ? value.ToString () : String.Empty;
if (value == null || (stringValue.Length == 0 && ConvertEmptyStringToNull)) {
if (NullDisplayText.Length == 0) {
encode = false;
res = "&nbsp;";
} else
res = NullDisplayText;
} else {
string format = DataFormatString;
if (!String.IsNullOrEmpty (format)) {
if (!encode || htmlEncodeFormatString)
res = String.Format (format, value);
else
res = String.Format (format, encode ? HttpUtility.HtmlEncode (stringValue) : stringValue);
} else
res = stringValue;
}
if (encode && htmlEncodeFormatString)
return HttpUtility.HtmlEncode (res);
else
return res;
}
protected virtual object GetValue (Control controlContainer)
{
if (DesignMode)
return GetDesignTimeValue ();
else
return GetBoundValue (controlContainer);
}
protected virtual object GetDesignTimeValue ()
{
return "Databound";
}
object GetBoundValue (Control controlContainer)
{
object dataItem = DataBinder.GetDataItem (controlContainer);
if (dataItem == null)
throw new HttpException ("A data item was not found in the container. The container must either implement IDataItemContainer, or have a property named DataItem.");
if (DataField == ThisExpression)
return dataItem;
else if (DataField == string.Empty)
return null;
return DataBinder.GetPropertyValue (dataItem, DataField);
}
protected override void LoadViewState (object state)
{
// Why override?
base.LoadViewState (state);
}
protected virtual void OnDataBindField (object sender, EventArgs e)
{
Control container = (Control) sender;
Control controlContainer = container.BindingContainer;
if (!(controlContainer is INamingContainer))
throw new HttpException ("A DataControlField must be within an INamingContainer.");
object val = GetValue (controlContainer);
TextBox box = sender as TextBox;
if (box == null) {
var cell = sender as DataControlFieldCell;
if (cell != null) {
ControlCollection controls = cell.Controls;
int ccount = controls != null ? controls.Count : 0;
if (ccount == 1)
box = controls [0] as TextBox;
if (box == null) {
cell.Text = FormatDataValue (val, SupportsHtmlEncode && HtmlEncode);
return;
}
}
}
if (box == null)
throw new HttpException ("Bound field " + DataField + " contains a control that isn't a TextBox. Override OnDataBindField to inherit from BoundField and add different controls.");
if (ApplyFormatInEditMode)
box.Text = FormatDataValue (val, SupportsHtmlEncode && HtmlEncode);
else
box.Text = val != null ? val.ToString() : NullDisplayText;
}
protected override DataControlField CreateField ()
{
return new BoundField ();
}
protected override void CopyProperties (DataControlField newField)
{
base.CopyProperties (newField);
BoundField field = (BoundField) newField;
field.ConvertEmptyStringToNull = ConvertEmptyStringToNull;
field.DataField = DataField;
field.DataFormatString = DataFormatString;
field.NullDisplayText = NullDisplayText;
field.ReadOnly = ReadOnly;
field.HtmlEncode = HtmlEncode;
}
// MSDN: The ValidateSupportsCallback method is a helper method used to determine
// whether the controls contained in a BoundField object support callbacks.
// This method has been implemented as an empty method (a method that does not contain
// any code) to indicate that callbacks are supported.
public override void ValidateSupportsCallback ()
{
}
}
}

View File

@@ -0,0 +1,46 @@
//
// System.Web.UI.WebControls.BulletStyle.cs
//
// Authors:
// Ben Maurer (bmaurer@users.sourceforge.net)
//
// (C) 2003 Ben Maurer
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Web.UI.WebControls
{
public enum BulletStyle
{
NotSet,
Numbered,
LowerAlpha,
UpperAlpha,
LowerRoman,
UpperRoman,
Disc,
Circle,
Square,
CustomImage,
}
}

Some files were not shown because too many files have changed in this diff Show More