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,222 @@
2009-10-02 Marek Habersack <mhabersack@novell.com>
* DynamicValidator.cs: initial implementation
* DynamicDataManager.cs: implemented OnLoad.
Better implementation of RegisterControl
* DynamicDataExtensions.cs: implemented FindDataSourceControl.
2009-09-18 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: implemented Init - calls Init on all the columns
present in this instance.
* MetaModel.cs: constructor initializes FieldTemplateFactory after
it is instantiated.
RegisterContextCore first registers the context type, then creates
tables and finally calls Init on all the tables.
* MetaColumn.cs: added internal Init method - called by MetaModel
after context is registered and all tables are created and
registered.
* MetaChildrenColumn.cs: implemented ChildTable,
ColumnInOtherTable, GetChildrenListPath, GetChildrenPath and added
an internal Init method override. MonoTODO attributes stay until I
write tests for the class.
* FieldTemplateUserControl.cs: implemented ChildrenColumn,
ChildrenPath, Column, ForeignKeyColumn, ForeignKeyPath,
MetadataAttributes, Mode, Row, Table, SetHost
* FieldTemplateFactory.cs: GetFieldTemplateVirtualPath fixes
* DynamicControl.cs: implemented ApplyFormatInEditMode,
ConvertEmptyStringToNull, DataField, DataFormatString, HtmlEncode,
FormattingOptions, NullDisplayText, UIHint, OnInit, Render.
2009-09-15 Marek Habersack <mhabersack@novell.com>
* MetaColumn.cs: DataTypeAttribtue created automatically for
string columns, must be of type MultilineText for long strings.
* FieldTemplateFactory.cs: implemented BuildVirtualPath,
CreateFieldTemplate, GetFieldTemplateVirtualPath, PreprocessMode
and fixed implementation of TemplateFolderVirtualPath.
2009-09-10 Marek Habersack <mhabersack@novell.com>
* DynamicControl.cs: implemented several properties.
Added code for ResolveColumn method, called from OnInit
2009-07-14 Marek Habersack <mhabersack@novell.com>
* FieldTemplateFactory.cs: implemented TemplateFolderVirtualPath
2009-06-27 Marek Habersack <mhabersack@novell.com>
* DynamicDataExtensions.cs: implemented ConvertEditedValue
* MetaModel.cs: implemented DynamicDataFolderVirtualPath
* DynamicDataRouteHandler.cs: implemented SetRequestMetaTable,
GetCustomPageVirtualPath, GetScaffoldPageVirtualPath and
guessed at implementation of CreateHandler.
2009-06-26 Marek Habersack <mhabersack@novell.com>
* MetaModel.cs: RegisterContextCore preserves already registered
tables.
* DynamicDataRouteHandler.cs: GetRequestContext must not retrieve
route data from the routes collection (if the matching route
happened to be an instance of DynamicDataRoute it would initialize
its RouteHandler's Model property, which is not correct, according
to tests). Instead a new RouteData instance is created each time
we don't find any cached context.
* DynamicDataRoute.cs: the associated route handler is set its
Model property when we initialize for the first time.
GetRouteData checks whether route data returned by base class
relates to a table which exists in the current context. If no such
table exists, null is returned.
2009-06-25 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: Fixes to make tests succeed.
* MetaModel.cs: added the GetDataFieldAttributes method for
retrieving attributes associated with data type/field.
Fixes to make tests succeed.
* MetaColumn.cs: refactoring - use
MetaModel.GetDataFieldAttributes instead of the local version.
* DynamicDataRouteHandler.cs: implemented GetRequestContext,
GetRequestMetaTable.
* DynamicDataRoute.cs: when the Action and Table properties are
set before one of GetVirtualPath or GetRouteData methods are
called for the first time, a check is made whether the Defaults
collection exists and whether it contains entries for Action and
Table. Initialization code makes sure those entries are inserted
into the dictionary in those cases.
2009-06-23 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: constructor now takes ContextConfiguration instead
of a boolean and uses the config to determine value of the
ScaffoldAllTables property. Also, if context config is present,
makes sure to register the associated type description provider
(if any) with TypeDescriptor.
* MetaModel.cs: no longer uses local cache for description
providers. Uses TypeDescriptor.{Add,Get}Provider now.
* MetaColumn.cs: fixed Scaffold to match tests - IsGenerated and
IsCustomProperty take precedence over Table.ScaffoldAllTables.
GetDataFieldAttribute doesn't use AttributeCollection indexer, as
the latter would create a default instance of the requested
attribute, which is not what we want here.
2009-06-17 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: fixed Scaffold implementation.
Added internal ScaffoldAllTables property.
* MetaColumn.cs: fixed TypeCode, MaxLength, Scaffold, UIHint
implementations.
Implemented IsLongString, IsBinaryData, IsReadOnly,
NullDisplayText, RequiredErrorMessage
2009-06-16 Marek Habersack <mhabersack@novell.com>
* DynamicDataManager.cs, DynamicDataExtensions.cs: use new
DataBoundControl.DataSourceObject instead of
InternalGetDataSource.
2009-06-15 Marek Habersack <mhabersack@novell.com>
* MetaColumn.cs: implemented ApplyFormatInEditMode, Attributes,
ConvertEmptyStringToNull, DataFormatString, DataTypeAttribute,
DefaultValue, Description, DisplayName, IsRequired,
IsFloatingPoint, IsInteger, IsString, TypeCode
* MetaTable.cs: use MetaModel.GetTypeDescriptor to retrieve
associated entity type attributes.
* MetaModel.cs: implemented registration of type metadata
cache. Metadata is provided by a set of TypeDescriptionProvider
instances (if ContextConfig is present for given model provider)
or by default type description provider (note that this
functionality is not implemented in
System.ComponentModel.TypeDescriptor yet!).
2009-06-12 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: implemented correct detection of foreign key
columns.
Implemented IsReadOnly, SortColumn, SortDescending.
2009-06-10 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: fixed DisplayName implementation.
Implemented GetPrimaryKeyString, GetQuery.
2009-06-09 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: implemented more overloads of GetActionPath.
Implemented GetPrimaryKeyValues, GetActionPathFromRoutes,
Attributes, DisplayColumn, GetDisplayString.
2009-06-01 Marek Habersack <mhabersack@novell.com>
* MetaModel.cs: GetModel throws InvalidOperationException on
missing model.
Implemented GetActionPath and GetTable.
2009-04-29 Marek Habersack <mhabersack@novell.com>
* MetaTable.cs: implemented the DataContextType,
DataContextPropertyName properties and the ToString method.
* MetaColumn.cs: implemented the Scaffold, DisplayName,
SortExpression, UIHint properties and the ToString method.
* DynamicField.cs: implemented
* DynamicDataManager.cs: partially implemented RegisterControl.
Added internal AutoFieldGenerator class, used by RegisterControl
when dealing with GridView.
Implemented some properties.
* DynamicDataExtensions.cs: implemented GetTable and FindMetaTable
* DynamicControl.cs: implemented parts of the class.
2009-04-23 Marek Habersack <mhabersack@novell.com>
* ContextConfiguration.cs: implemented all the methods and added a
parameterless constructor.
2008-10-21 Atsushi Enomoto <atsushi@ximian.com>
* DynamicDataRouteHandler.cs, DynamicDataRoute.cs, MetaTable.cs:
ongoing implementation; resolve to page templates.
2008-10-17 Atsushi Enomoto <atsushi@ximian.com>
* DynamicDataRouteHandler.cs, DynamicDataRoute.cs, MetaTable.cs,
MetaModel.cs : ongoing implementation.
2008-10-16 Atsushi Enomoto <atsushi@ximian.com>
* DynamicDataManager.cs, DynamicDataRoute.cs,
FieldTemplateFactory.cs, MetaChildrenColumn.cs,
MetaColumn.cs, MetaForeignKeyColumn.cs, MetaModel.cs, MetaTable.cs:
ongoing implementation.
2008-10-14 Atsushi Enomoto <atsushi@ximian.com>
*.cs : initial checkin. stubs.

View File

@@ -0,0 +1,57 @@
//
// ContextConfiguration.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.DynamicData.ModelProviders;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class ContextConfiguration
{
public ContextConfiguration ()
{
MetadataProviderFactory = (Type t) => new AssociatedMetadataTypeTypeDescriptionProvider (t);
}
public Func<Type, TypeDescriptionProvider> MetadataProviderFactory { get; set; }
public bool ScaffoldAllTables { get; set; }
}
}

View File

@@ -0,0 +1,313 @@
//
// DynamicControl.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.DynamicData.ModelProviders;
namespace System.Web.DynamicData
{
[ToolboxBitmap (typeof(DynamicControl), "DynamicControl.ico")]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicControl : Control, IAttributeAccessor, IFieldTemplateHost, IFieldFormattingOptions
{
Dictionary <string, string> attributes;
bool? applyFormatInEditMode;
bool? convertEmptyStringToNull;
bool? htmlEncode;
string dataField = String.Empty;
string dataFormatString;
string nullDisplayText;
string uiHint;
public DynamicControl () : this (DataBoundControlMode.ReadOnly)
{
}
public DynamicControl (DataBoundControlMode mode)
{
Mode = mode;
CssClass = String.Empty;
ValidationGroup = String.Empty;
}
[Category ("Behavior")]
[DefaultValue (false)]
public bool ApplyFormatInEditMode {
get {
if (applyFormatInEditMode == null) {
MetaColumn column = Column;
applyFormatInEditMode = column != null ? column.ApplyFormatInEditMode : false;
}
return (bool)applyFormatInEditMode;
}
set { applyFormatInEditMode = value; }
}
[Browsable (false)]
public MetaColumn Column { get; set; }
[Category ("Behavior")]
[DefaultValue (false)]
public bool ConvertEmptyStringToNull {
get {
if (convertEmptyStringToNull == null) {
MetaColumn column = Column;
convertEmptyStringToNull = column != null ? column.ConvertEmptyStringToNull : false;
}
return (bool)convertEmptyStringToNull;
}
set { convertEmptyStringToNull = value; }
}
[MonoTODO]
[Category ("Appearance")]
[DefaultValue ("")]
[CssClassProperty]
public virtual string CssClass { get; set; }
[Category ("Data")]
[DefaultValue ("")]
public string DataField {
get { return dataField; }
set { dataField = value == null ? String.Empty : value; }
}
[Category ("Data")]
[DefaultValue ("")]
public string DataFormatString {
get {
if (dataFormatString == null) {
MetaColumn column = Column;
if (column != null) {
dataFormatString = column.DataFormatString;
if (dataFormatString == null)
dataFormatString = String.Empty;
} else
dataFormatString = String.Empty;
}
return dataFormatString;
}
set { dataFormatString = value == null ? String.Empty : value; }
}
[MonoTODO]
[Browsable (false)]
public Control FieldTemplate { get; private set; }
[Category ("Behavior")]
[DefaultValue (true)]
public bool HtmlEncode {
get {
if (htmlEncode == null) {
MetaColumn column = Column;
htmlEncode = column != null ? column.HtmlEncode : true;
}
return (bool)htmlEncode;
}
set { htmlEncode = value; }
}
IFieldFormattingOptions IFieldTemplateHost.FormattingOptions {
get { return this; }
}
[MonoTODO]
public DataBoundControlMode Mode { get; set; }
[Category ("Behavior")]
[DefaultValue ("")]
public string NullDisplayText {
get {
if (nullDisplayText == null) {
MetaColumn column = Column;
if (column != null) {
nullDisplayText = column.NullDisplayText;
if (nullDisplayText == null)
nullDisplayText = String.Empty;
} else
nullDisplayText = String.Empty;
}
return nullDisplayText;
}
set { nullDisplayText = value == null ? String.Empty : value; }
}
[Browsable (false)]
public virtual MetaTable Table {
get { return this.FindMetaTable (); }
}
[Category ("Behavior")]
[DefaultValue ("")]
public virtual string UIHint {
get {
if (uiHint == null) {
MetaColumn column = Column;
uiHint = column != null ? column.UIHint : String.Empty;
if (uiHint == null)
uiHint = String.Empty;
}
return uiHint;
}
set { uiHint = value != null ? value : String.Empty; }
}
[Themeable (false)]
[Category ("Behavior")]
[DefaultValue ("")]
public virtual string ValidationGroup { get; set; }
void CreateFieldTemplate ()
{
MetaColumn column = Column;
// Safe as ResolveColumn won't return with a null Column
MetaModel model = column.Model;
IFieldTemplateFactory ftf = model != null ? model.FieldTemplateFactory : null;
IFieldTemplate ft;
if (ftf != null) {
ft = ftf.CreateFieldTemplate (column, Mode, UIHint);
if (ft == null)
return;
} else
return;
ft.SetHost (this);
Control ctl = ft as Control;
if (ctl == null)
return;
FieldTemplate = ctl;
Controls.Add (ctl);
}
public string GetAttribute (string key)
{
if (attributes == null)
return String.Empty;
string ret;
if (attributes.TryGetValue (key, out ret))
return ret;
else
// "Compatibility"...
throw new KeyNotFoundException ("NoSuchAttribute");
}
protected override void OnInit (EventArgs e)
{
// It seems _all_ the properties are initialized _only_ here. Further user's
// actions to set the Column property don't affect the other properties
// which derive their values from the associated MetaColumn.
base.OnInit (e);
if (Column == null) {
ResolveColumn ();
Controls.Clear ();
CreateFieldTemplate ();
}
}
protected override void Render (HtmlTextWriter writer)
{
string cssClass = CssClass;
bool haveCssClass = !String.IsNullOrEmpty (cssClass);
if (haveCssClass) {
writer.AddAttribute (HtmlTextWriterAttribute.Class, cssClass);
writer.RenderBeginTag (HtmlTextWriterTag.Span);
writer.Write ("\n\n");
}
base.Render (writer);
if (haveCssClass) {
writer.RenderEndTag ();
}
}
void ResolveColumn ()
{
string dataField = DataField;
if (String.IsNullOrEmpty (dataField))
throw new InvalidOperationException ("The '" + GetType ().Name + "' control '" + ID + "' must have a DataField attribute.");
MetaTable table = Table;
// And, as it is .NET DynamicData's tradition... no null check!!
if (table == null)
throw new NullReferenceException ();
Column = table.GetColumn (dataField);
}
internal void InternalSetAttributes (Dictionary <string, string> attributes)
{
this.attributes = attributes;
}
public void SetAttribute (string key, string value)
{
if (attributes == null)
attributes = new Dictionary <string, string> ();
if (attributes.ContainsKey (key))
attributes [key] = value;
else
attributes.Add (key, value);
}
}
}

View File

@@ -0,0 +1,75 @@
//
// DynamicControlParameter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.DynamicData.ModelProviders;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicControlParameter : Parameter, IWhereParametersProvider
{
[MonoTODO]
public DynamicControlParameter ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public DynamicControlParameter (string controlId)
{
throw new NotImplementedException ();
}
[MonoTODO]
public string ControlId { get; set; }
[MonoTODO]
protected override object Evaluate (HttpContext context, Control control)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IEnumerable<Parameter> GetWhereParameters (IDynamicDataSource dataSource)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,178 @@
//
// DynamicDataExtensions.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.DynamicData.ModelProviders;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public static class DynamicDataExtensions
{
public static object ConvertEditedValue (this IFieldFormattingOptions formattingOptions, string value)
{
// Not a surprise anymore...
if (formattingOptions == null)
throw new NullReferenceException ();
if (String.IsNullOrEmpty (value)) {
if (formattingOptions.ConvertEmptyStringToNull)
return null;
} else {
string nullDisplayText = formattingOptions.NullDisplayText;
if (!String.IsNullOrEmpty (nullDisplayText) && String.Compare (value, nullDisplayText, StringComparison.Ordinal) == 0)
return null;
}
return value;
}
[MonoTODO]
public static void EnablePersistedSelection (this BaseDataBoundControl dataBoundControl)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static void ExpandDynamicWhereParameters (this IDynamicDataSource dataSource)
{
// http://forums.asp.net/p/1396453/3005197.aspx#3005197
}
[MonoTODO]
public static IDynamicDataSource FindDataSourceControl (this Control current)
{
var control = current as BaseDataBoundControl;
if (control == null)
return null;
string dataSourceID = control.DataSourceID;
if (!String.IsNullOrEmpty (dataSourceID))
return control.DataSource as IDynamicDataSource;
Control namingContainer = control.NamingContainer;
IDynamicDataSource dds;
while (namingContainer != null) {
dds = namingContainer.FindControl (dataSourceID) as IDynamicDataSource;
if (dds != null)
return dds;
namingContainer = namingContainer.NamingContainer;
}
return null;
}
[MonoTODO]
public static Control FindFieldTemplate (this Control control, string columnName)
{
throw new NotImplementedException ();
}
public static MetaTable FindMetaTable (this Control current)
{
// .NET doesn't perform the check, we will
if (current == null)
throw new NullReferenceException ();
while (current != null) {
DataBoundControl dbc = current as DataBoundControl;
if (dbc != null) {
IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
if (dds != null)
return dds.GetTable ();
}
current = current.NamingContainer;
}
return null;
}
[MonoTODO]
public static string FormatEditValue (this IFieldFormattingOptions formattingOptions, object fieldValue)
{
throw new NotImplementedException ();
}
[MonoTODO]
public static string FormatValue (this IFieldFormattingOptions formattingOptions, object fieldValue)
{
throw new NotImplementedException ();
}
static string GetDataSourceId (IDynamicDataSource dataSource)
{
Control c = dataSource as Control;
if (c == null)
return String.Empty;
return c.ID;
}
public static MetaTable GetTable (this IDynamicDataSource dataSource)
{
if (dataSource == null)
return null;
string entitySetName = dataSource.EntitySetName;
if (String.IsNullOrEmpty (entitySetName)) {
// LAMESPEC: MSDN says we should throw in this case, but .NET calls
// DynamicDataRouteHandler.GetRequestMetaTable(HttpContext
// httpContext) instead (eventually)
MetaTable ret = DynamicDataRouteHandler.GetRequestMetaTable (HttpContext.Current);
if (ret == null)
throw new InvalidOperationException ("The control '" + GetDataSourceId (dataSource) +
"' does not have a TableName property and a table name cannot be inferred from the URL.");
}
Type contextType = dataSource.ContextType;
if (contextType == null)
throw new InvalidOperationException ("The ContextType property of control '" + GetDataSourceId (dataSource) + "' must specify a data context");
return MetaModel.GetModel (contextType).GetTable (entitySetName);
}
[MonoTODO]
public static void LoadWithForeignKeys (this LinqDataSource dataSource, Type rowType)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,207 @@
//
// DynamicDataManager.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.DynamicData.ModelProviders;
namespace System.Web.DynamicData
{
[ToolboxBitmap (typeof(DynamicDataManager), "DynamicDataManager.ico")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[NonVisualControl]
[ParseChildren (true)]
[PersistChildren (false)]
public class DynamicDataManager : Control
{
private class AutoFieldGenerator : IAutoFieldGenerator
{
MetaTable table;
public AutoFieldGenerator (MetaTable table)
{
this.table = table;
}
public ICollection GenerateFields (Control ctl)
{
var ret = new List <DynamicField> ();
foreach (MetaColumn column in table.Columns) {
if (!column.Scaffold)
continue;
var field = new DynamicField ();
field.DataField = column.Name;
ret.Add (field);
}
return ret;
}
}
Dictionary <IDynamicDataSource, bool> knownDataSources;
public DynamicDataManager ()
{
}
public bool AutoLoadForeignKeys {
get;
set;
}
[Browsable (false)]
public override bool Visible {
get { return true; }
// NOTE: it is supposed to throw the exception
set { throw new NotImplementedException (); }
}
protected override void OnLoad (EventArgs e)
{
base.OnLoad (e);
// http://forums.asp.net/p/1257004/2339034.aspx
// http://forums.asp.net/t/1297860.aspx
// http://forums.asp.net/p/1396453/3005197.aspx#3005197
if (knownDataSources != null) {
foreach (var de in knownDataSources) {
IDynamicDataSource dds = de.Key;
if (dds == null)
continue;
dds.ExpandDynamicWhereParameters ();
}
}
}
public void RegisterControl (Control control)
{
RegisterControl (control, false);
}
public void RegisterControl (Control control, bool setSelectionFromUrl)
{
// .NET doesn't check for null here, but since I don't like such code, we
// will do the check and throw the same exception as .NET
if (control == null)
throw new NullReferenceException ();
if (!ControlIsValid (control))
throw new Exception ("Controls of type " + control.GetType () + " are not supported.");
// http://forums.asp.net/p/1257004/2339034.aspx
// http://forums.asp.net/p/1383908/2936065.aspx
DataBoundControl dbc = control as DataBoundControl;
if (dbc != null) {
IDynamicDataSource dds = dbc.DataSourceObject as IDynamicDataSource;
if (dds == null)
return;
RegisterDataSource (dds);
MetaTable table = dds.GetTable ();
if (table == null)
return;
if (String.IsNullOrEmpty (dds.Where))
dds.AutoGenerateWhereClause = true;
else
dds.AutoGenerateWhereClause = false;
Type contextType = dds.ContextType;
if (contextType == null)
dds.ContextType = table.DataContextType;
string entityName = dds.EntitySetName;
if (String.IsNullOrEmpty (entityName))
dds.EntitySetName = table.DataContextPropertyName;
if (AutoLoadForeignKeys) {
var ldds = dds as LinqDataSource;
if (ldds != null)
ldds.LoadWithForeignKeys (table.EntityType);
}
var gv = control as GridView;
if (gv != null) {
gv.ColumnsGenerator = new AutoFieldGenerator (table);
return;
}
var dv = control as DetailsView;
if (dv != null) {
dv.RowsGenerator = new AutoFieldGenerator (table);
return;
}
}
}
void RegisterDataSource (IDynamicDataSource dds)
{
if (knownDataSources == null) {
knownDataSources = new Dictionary <IDynamicDataSource, bool> ();
knownDataSources.Add (dds, true);
return;
}
if (knownDataSources.ContainsKey (dds))
return;
knownDataSources.Add (dds, true);
}
bool ControlIsValid (Control control)
{
if (control is Repeater) {
if (control.NamingContainer == null)
throw new HttpException ("The Repeater control '" + control.ID + "' does not have a naming container.");
return true;
}
DataBoundControl dbc = control as DataBoundControl;
if (dbc == null)
return false;
return true;
}
}
}

View File

@@ -0,0 +1,156 @@
//
// DynamicDataRoute.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.Routing;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicDataRoute : Route
{
static readonly object initLock = new object ();
bool initDone;
public DynamicDataRoute (string url)
: base (url, null)
{
Model = MetaModel.Default;
RouteHandler = new DynamicDataRouteHandler ();
}
public string Action { get; set; }
public MetaModel Model { get; set; }
public new DynamicDataRouteHandler RouteHandler {
get { return base.RouteHandler as DynamicDataRouteHandler; }
set { base.RouteHandler = value; }
}
public string Table { get; set; }
public string ViewName { get; set; }
void EnsureInitialized ()
{
if (initDone)
return;
// We need to lock since we might be stored in the RouteTable.Routes
// collection which might be accessed from many concurrent requests.
lock (initLock) {
if (initDone)
return;
initDone = true;
DynamicDataRouteHandler rh = RouteHandler;
if (rh != null)
rh.Model = Model;
string action = Action, table = Table;
if (action == null && table == null)
return;
RouteValueDictionary defaults = Defaults;
if (defaults == null)
Defaults = defaults = new RouteValueDictionary ();
if (table != null) {
// Force check for table existence
MetaModel model = Model ?? MetaModel.Default;
if (model != null)
Model.GetTable (table);
if (defaults.ContainsKey ("Table"))
defaults ["Table"] = table;
else
defaults.Add ("Table", table);
}
if (action != null) {
if (defaults.ContainsKey ("Action"))
defaults ["Action"] = action;
else
defaults.Add ("Action", action);
}
}
}
public string GetActionFromRouteData (RouteData routeData)
{
if (routeData == null)
throw new ArgumentNullException ("routeData");
return routeData.GetRequiredString ("Action");
}
public override RouteData GetRouteData (HttpContextBase httpContext)
{
EnsureInitialized ();
RouteData rd = base.GetRouteData (httpContext);
if (rd == null)
return null;
MetaModel model = Model ?? MetaModel.Default;
MetaTable table;
if (model == null || !model.TryGetTable (rd.GetRequiredString ("Table"), out table))
return null;
return rd;
}
public MetaTable GetTableFromRouteData (RouteData routeData)
{
if (routeData == null)
throw new ArgumentNullException ("routeData");
var t = routeData.GetRequiredString ("Table");
if (Model == null)
throw new InvalidOperationException ("MetaModel must be set to the DynamicDataRoute before retrieving MetaTable");
return Model.GetTable (t);
}
public override VirtualPathData GetVirtualPath (RequestContext requestContext, RouteValueDictionary values)
{
EnsureInitialized ();
return base.GetVirtualPath (requestContext, values);
}
}
}

View File

@@ -0,0 +1,271 @@
//
// DynamicDataRouteHandler.cs
//
// Authors:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.Linq.Mapping;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
using System.Web.Caching;
using System.Web.Compilation;
using System.Web.Hosting;
using System.Web.Routing;
using System.Web.UI;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicDataRouteHandler : IRouteHandler
{
static ReaderWriterLockSlim contextsLock = new ReaderWriterLockSlim ();
static Dictionary <HttpContext, RouteContext> contexts = new Dictionary <HttpContext, RouteContext> ();
Dictionary <RouteContext, IHttpHandler> handlers;
Dictionary <RouteContext, IHttpHandler> Handlers {
get {
if (handlers == null)
handlers = new Dictionary <RouteContext, IHttpHandler> ();
return handlers;
}
}
static RouteContext GetOrCreateRouteContext (HttpContext httpContext)
{
RouteContext rc = null;
bool locked = false;
try {
contextsLock.EnterReadLock ();
locked = true;
if (contexts.TryGetValue (httpContext, out rc) && rc != null)
return rc;
} finally {
if (locked)
contextsLock.ExitReadLock ();
}
locked = false;
try {
contextsLock.EnterWriteLock ();
locked = true;
rc = MakeRouteContext (new RequestContext (new HttpContextWrapper (httpContext), new RouteData ()), null, null, null);
contexts.Add (httpContext, rc);
} finally {
if (locked)
contextsLock.ExitWriteLock ();
}
return rc;
}
public static RequestContext GetRequestContext (HttpContext httpContext)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
return GetOrCreateRouteContext (httpContext).Context;
}
public static MetaTable GetRequestMetaTable (HttpContext httpContext)
{
if (httpContext == null)
throw new ArgumentNullException ("httpContext");
RouteContext rc;
bool locked = false;
try {
contextsLock.EnterReadLock ();
locked = true;
if (contexts.TryGetValue (httpContext, out rc) && rc != null)
return rc.Table;
} finally {
if (locked)
contextsLock.ExitReadLock ();
}
return null;
}
public static void SetRequestMetaTable (HttpContext httpContext, MetaTable table)
{
// And tradiationally... some .NET emulation code
if (httpContext == null)
throw new NullReferenceException ();
GetOrCreateRouteContext (httpContext).Table = table;
}
public DynamicDataRouteHandler ()
{
}
public MetaModel Model { get; internal set; }
[MonoTODO ("Needs a working test")]
public virtual IHttpHandler CreateHandler (DynamicDataRoute route, MetaTable table, string action)
{
// .NET bug emulation mode
if (route == null || table == null || action == null)
throw new NullReferenceException ();
// NOTE: all code below is a result of guessing as no tests succeed for this
// call so far!
IHttpHandler ret = null;
// Give custom pages a chance
string viewName = String.IsNullOrEmpty (action) ? route.ViewName : action;
string path = GetCustomPageVirtualPath (table, viewName);
// Pages might be in app resources, need to use a VPP
VirtualPathProvider vpp = HostingEnvironment.VirtualPathProvider;
if (vpp != null && vpp.FileExists (path))
ret = BuildManager.CreateInstanceFromVirtualPath (path, typeof (Page)) as IHttpHandler;
if (ret != null)
return ret;
path = GetScaffoldPageVirtualPath (table, viewName);
if (vpp != null && vpp.FileExists (path))
ret = BuildManager.CreateInstanceFromVirtualPath (path, typeof (Page)) as IHttpHandler;
return ret;
}
protected virtual string GetCustomPageVirtualPath (MetaTable table, string viewName)
{
// No such checks are made in .NET, we won't follow the pattern...
MetaModel model = Model;
if (table == null || model == null)
throw new NullReferenceException (); // yuck
// Believe it or not, this is what .NET does - pass a null/empty viewName
// and you get /.aspx at the end...
return model.DynamicDataFolderVirtualPath + "CustomPages/" + table.Name + "/" + viewName + ".aspx";
}
protected virtual string GetScaffoldPageVirtualPath (MetaTable table, string viewName)
{
// No such checks are made in .NET, we won't follow the pattern...
MetaModel model = Model;
if (table == null || model == null)
throw new NullReferenceException (); // yuck
// Believe it or not, this is what .NET does - pass a null/empty viewName
// and you get /.aspx at the end...
return model.DynamicDataFolderVirtualPath + "PageTemplates/" + viewName + ".aspx";
}
IHttpHandler IRouteHandler.GetHttpHandler (RequestContext requestContext)
{
if (requestContext == null)
throw new ArgumentNullException ("requestContext");
RouteData rd = requestContext.RouteData;
var dr = rd.Route as DynamicDataRoute;
if (dr == null)
throw new ArgumentException ("The argument RequestContext does not have DynamicDataRoute in its RouteData");
string action = dr.GetActionFromRouteData (rd);
MetaTable mt = dr.GetTableFromRouteData (rd);
RouteContext rc = MakeRouteContext (requestContext, dr, action, mt);
IHttpHandler h;
Dictionary <RouteContext, IHttpHandler> handlers = Handlers;
if (handlers.TryGetValue (rc, out h))
return h;
h = CreateHandler (dr, mt, action);
handlers.Add (rc, h);
return h;
}
static RouteContext MakeRouteContext (RequestContext context, DynamicDataRoute route, string action, MetaTable table)
{
RouteData rd = null;
if (route == null) {
rd = context.RouteData;
route = rd.Route as DynamicDataRoute;
}
if (route != null) {
if (action == null) {
if (rd == null)
rd = context.RouteData;
action = route.GetActionFromRouteData (rd);
}
if (table == null) {
if (rd == null)
rd = context.RouteData;
table = route.GetTableFromRouteData (rd);
}
}
return new RouteContext () {
Route = route,
Action = action,
Table = table,
Context = context};
}
sealed class RouteContext
{
public DynamicDataRoute Route;
public string Action;
public MetaTable Table;
public RequestContext Context;
public RouteContext ()
{
}
public override bool Equals (object obj)
{
RouteContext other = obj as RouteContext;
return other.Route == Route & other.Action == Action && other.Table == Table && other.Context == Context;
}
public override int GetHashCode ()
{
return (Route != null ? Route.GetHashCode () << 27 : 0) +
(Action != null ? Action.GetHashCode () << 19 : 0) +
(Table != null ? Table.GetHashCode () << 9 : 0) +
(Context != null ? Context.GetHashCode () : 0);
}
}
}
}

View File

@@ -0,0 +1,212 @@
//
// DynamicField.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicField : DataControlField, IAttributeAccessor, IFieldFormattingOptions
{
MetaColumn myColumn;
Dictionary <string, string> attributes;
public DynamicField ()
{
DataFormatString = String.Empty;
HtmlEncode = true;
NullDisplayText = String.Empty;
}
public bool ApplyFormatInEditMode {
get; set;
}
public bool ConvertEmptyStringToNull {
get; set;
}
public virtual string DataField {
get {
return (string) ViewState ["_DataField"] ?? String.Empty;
}
set {
ViewState ["_DataField"] = value;
OnFieldChanged ();
}
}
public string DataFormatString {
get; set;
}
public override string HeaderText {
get {
string s = (string) ViewState ["headerText"];
if (s != null)
return s;
MetaColumn column = MyColumn;
if (column != null)
return column.DisplayName;
return DataField;
}
set { base.HeaderText = value; }
}
public bool HtmlEncode {
get; set;
}
MetaColumn MyColumn {
get {
if (myColumn != null)
return myColumn;
Control owner = Control;
if (owner == null)
return null;
MetaTable table = owner.FindMetaTable ();
if (table == null)
return null;
myColumn = table.GetColumn (DataField);
return myColumn;
}
}
public string NullDisplayText {
get; set;
}
public override string SortExpression {
get {
string s = (string) ViewState ["sortExpression"];
if (s != null)
return s;
MetaColumn column = MyColumn;
if (column != null)
return column.SortExpression;
return String.Empty;
}
set { base.SortExpression = value; }
}
public virtual string UIHint {
get {
return (string) ViewState ["uiHint"] ?? String.Empty;
}
set {
ViewState ["uiHint"] = value;
OnFieldChanged ();
}
}
[MonoTODO]
protected override void CopyProperties (DataControlField newField)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override DataControlField CreateField ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public override void ExtractValuesFromCell (IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, bool includeReadOnly)
{
throw new NotImplementedException ();
}
public string GetAttribute (string key)
{
if (attributes == null)
return null;
string ret;
if (attributes.TryGetValue (key, out ret))
return ret;
return null;
}
public override void InitializeCell (DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
{
if (cellType == DataControlCellType.Header || cellType == DataControlCellType.Footer) {
base.InitializeCell (cell, cellType, rowState, rowIndex);
return;
}
DynamicControl dc = new DynamicControl ();
dc.ApplyFormatInEditMode = ApplyFormatInEditMode;
dc.ConvertEmptyStringToNull = ConvertEmptyStringToNull;
dc.Column = MyColumn;
dc.DataField = DataField;
dc.DataFormatString = DataFormatString;
dc.HtmlEncode = HtmlEncode;
dc.Mode = (rowState & DataControlRowState.Edit) != 0 ? DataBoundControlMode.Edit :
(rowState & DataControlRowState.Insert) != 0 ? DataBoundControlMode.Insert : DataBoundControlMode.ReadOnly;
dc.NullDisplayText = NullDisplayText;
dc.UIHint = UIHint;
dc.InternalSetAttributes (attributes);
cell.Controls.Add (dc);
}
public void SetAttribute (string key, string value)
{
if (attributes == null)
attributes = new Dictionary <string, string> ();
if (attributes.ContainsKey (key))
attributes [key] = value;
else
attributes.Add (key, value);
}
}
}

View File

@@ -0,0 +1,59 @@
//
// DynamicQueryStringParameter.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicQueryStringParameter : Parameter, IWhereParametersProvider
{
[MonoTODO]
protected override object Evaluate (HttpContext context, Control control)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IEnumerable<Parameter> GetWhereParameters (IDynamicDataSource dataSource)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,129 @@
//
// DynamicValidator.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[ToolboxBitmap (typeof(DynamicValidator), "DynamicValidator.ico")]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DynamicValidator : BaseValidator
{
IDynamicDataSource dynamicDataSource;
IDynamicDataSource DynamicDataSource {
get {
if (dynamicDataSource == null)
dynamicDataSource = this.FindDataSourceControl ();
return dynamicDataSource;
}
}
[Themeable (false)]
[Browsable (false)]
public MetaColumn Column { get; set; }
[Themeable (false)]
[Browsable (false)]
public string ColumnName {
get {
// LAMESPEC: returns Column.Name if Column is not null, String.Empty
// otherwise
MetaColumn column = Column;
return column != null ? column.Name : String.Empty;
}
}
protected virtual Exception ValidationException { get; set; }
protected override bool ControlPropertiesValid ()
{
return base.ControlPropertiesValid () && DynamicDataSource != null;
}
[MonoTODO]
protected override bool EvaluateIsValid ()
{
Exception ex = ValidationException;
if (ex != null) {
ErrorMessage = HttpUtility.HtmlEncode (ex.Message);
return false;
}
string controlToValidate = ControlToValidate;
if (String.IsNullOrEmpty (controlToValidate))
return true;
GetControlValidationValue (controlToValidate);
return true;
}
void HandleException (object sender, DynamicValidatorEventArgs args)
{
if (args == null)
return;
ValidateException (args.Exception);
}
protected override void OnInit (EventArgs e)
{
IDynamicDataSource dds = DynamicDataSource;
if (dds != null)
dds.Exception += HandleException;
base.OnInit (e);
}
[MonoTODO]
protected virtual void ValidateException (Exception exception)
{
// http://forums.asp.net/p/1287649/2478409.aspx#2478409
//
// The above suggests that IDynamicValidatorException.InnerExceptions is
// indexed on column name
//
}
}
}

View File

@@ -0,0 +1,290 @@
//
// FieldTemplateFactory.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.IO;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.Compilation;
using System.Web.Hosting;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class FieldTemplateFactory : IFieldTemplateFactory
{
const string DEFAULT_TEMPLATE_FOLDER_VIRTUAL_PATH = "FieldTemplates/";
static readonly Dictionary <Type, Type> typeFallbacks = new Dictionary <Type, Type> () {
{typeof (float), typeof (decimal)},
{typeof (double), typeof (decimal)},
{typeof (short), typeof (int)},
{typeof (long), typeof (int)},
{typeof (byte), typeof (int)},
{typeof (char), typeof (string)},
{typeof (int), typeof (string)},
{typeof (decimal), typeof (string)},
{typeof (Guid), typeof (string)},
{typeof (DateTime), typeof (string)},
{typeof (DateTimeOffset), typeof (string)},
{typeof (TimeSpan), typeof (string)}
};
string templateFolderVirtualPath;
string userTemplateVirtualPath;
public MetaModel Model { get; private set; }
public string TemplateFolderVirtualPath {
get {
if (templateFolderVirtualPath == null) {
MetaModel m = Model;
string virtualPath = userTemplateVirtualPath == null ? DEFAULT_TEMPLATE_FOLDER_VIRTUAL_PATH : userTemplateVirtualPath;
if (m != null)
templateFolderVirtualPath = VirtualPathUtility.Combine (m.DynamicDataFolderVirtualPath, virtualPath);
else
templateFolderVirtualPath = virtualPath;
templateFolderVirtualPath = VirtualPathUtility.AppendTrailingSlash (templateFolderVirtualPath);
}
return templateFolderVirtualPath;
}
set {
userTemplateVirtualPath = value;
templateFolderVirtualPath = null;
}
}
public virtual string BuildVirtualPath (string templateName, MetaColumn column, DataBoundControlMode mode)
{
// Tests show the 'column' parameter is not used here
if (String.IsNullOrEmpty (templateName))
throw new ArgumentNullException ("templateName");
string basePath = TemplateFolderVirtualPath;
string suffix;
switch (mode) {
default:
case DataBoundControlMode.ReadOnly:
suffix = String.Empty;
break;
case DataBoundControlMode.Edit:
suffix = "_Edit";
break;
case DataBoundControlMode.Insert:
suffix = "_Insert";
break;
}
return basePath + templateName + suffix + ".ascx";
}
public virtual IFieldTemplate CreateFieldTemplate (MetaColumn column, DataBoundControlMode mode, string uiHint)
{
// NO checks are made on parameters in .NET, but well "handle" the NREX
// throws in the other methods
string virtualPath = GetFieldTemplateVirtualPath (column, mode, uiHint);
if (String.IsNullOrEmpty (virtualPath))
return null;
return BuildManager.CreateInstanceFromVirtualPath (virtualPath, typeof (IFieldTemplate)) as IFieldTemplate;
}
public virtual string GetFieldTemplateVirtualPath (MetaColumn column, DataBoundControlMode mode, string uiHint)
{
// NO checks are made on parameters in .NET, but well "handle" the NREX
// throws in the other methods
DataBoundControlMode newMode = PreprocessMode (column, mode);
// The algorithm is as follows:
//
// 1. If column has a DataTypeAttribute on it, get the data type
// - if it's Custom data type, uiHint is used unconditionally
// - if it's not a custom type, ignore uiHint and choose template based
// on type
//
// 2. If #1 is false and uiHint is not empty, use uiHint if the template
// exists
//
// 3. If #2 is false, look up type according to the following algorithm:
//
// 1. lookup column type's full name
// 2. if #1 fails, look up short type name
// 3. if #2 fails, map type to special type name (Int -> Integer, String
// -> Text etc)
// 4. if #3 fails, try to find a fallback type
// 5. if #4 fails, check if it's a foreign key or child column
// 6. if #5 fails, return null
//
// From: http://msdn.microsoft.com/en-us/library/cc488523.aspx (augmented)
//
DataTypeAttribute attr = column.DataTypeAttribute;
bool uiHintPresent = !String.IsNullOrEmpty (uiHint);
string templatePath = null;
int step = uiHintPresent ? 0 : 1;
Type columnType = column.ColumnType;
if (!uiHintPresent && attr == null) {
if (column is MetaChildrenColumn)
templatePath = GetExistingTemplateVirtualPath ("Children", column, newMode);
else if (column is MetaForeignKeyColumn)
templatePath = GetExistingTemplateVirtualPath ("ForeignKey", column, newMode);
}
while (step < 6 && templatePath == null) {
switch (step) {
case 0:
templatePath = GetExistingTemplateVirtualPath (uiHint, column, newMode);
break;
case 1:
if (attr != null)
templatePath = GetTemplateForDataType (attr.DataType, attr.GetDataTypeName (), uiHint, column, newMode);
break;
case 2:
templatePath = GetExistingTemplateVirtualPath (columnType.FullName, column, newMode);
break;
case 3:
templatePath = GetExistingTemplateVirtualPath (columnType.Name, column, newMode);
break;
case 4:
templatePath = ColumnTypeToSpecialName (columnType, column, newMode);
break;
case 5:
columnType = GetFallbackType (columnType, column, newMode);
if (columnType == null)
step = 5;
else
step = uiHintPresent ? 0 : 1;
break;
}
step++;
}
return templatePath;
}
Type GetFallbackType (Type columnType, MetaColumn column, DataBoundControlMode mode)
{
Type ret;
if (typeFallbacks.TryGetValue (columnType, out ret))
return ret;
return null;
}
string ColumnTypeToSpecialName (Type columnType, MetaColumn column, DataBoundControlMode mode)
{
if (columnType == typeof (int))
return GetExistingTemplateVirtualPath ("Integer", column, mode);
if (columnType == typeof (string))
return GetExistingTemplateVirtualPath ("Text", column, mode);
return null;
}
string GetExistingTemplateVirtualPath (string baseName, MetaColumn column, DataBoundControlMode mode)
{
string templatePath = BuildVirtualPath (baseName, column, mode);
if (String.IsNullOrEmpty (templatePath))
return null;
// TODO: cache positive hits (and watch for removal events on those)
string physicalPath = HostingEnvironment.MapPath (templatePath);
if (File.Exists (physicalPath))
return templatePath;
return null;
}
string GetTemplateForDataType (DataType dataType, string customDataType, string uiHint, MetaColumn column, DataBoundControlMode mode)
{
switch (dataType) {
case DataType.Custom:
return GetExistingTemplateVirtualPath (customDataType, column, mode);
case DataType.DateTime:
return GetExistingTemplateVirtualPath ("DateTime", column, mode);
case DataType.MultilineText:
return GetExistingTemplateVirtualPath ("MultilineText", column, mode);
default:
return GetExistingTemplateVirtualPath ("Text", column, mode);
}
}
public virtual void Initialize (MetaModel model)
{
Model = model;
}
public virtual DataBoundControlMode PreprocessMode (MetaColumn column, DataBoundControlMode mode)
{
// In good tradition of .NET's DynamicData, let's not check the
// parameters...
if (column == null)
throw new NullReferenceException ();
if (column.IsGenerated)
return DataBoundControlMode.ReadOnly;
if (column.IsPrimaryKey) {
if (mode == DataBoundControlMode.Edit)
return DataBoundControlMode.ReadOnly;
}
return mode;
}
}
}

View File

@@ -0,0 +1,227 @@
//
// FieldTemplateUserControl.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
// Marek Habersack <mhabersack@novell.com>
//
// Copyright (C) 2008-2009 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class FieldTemplateUserControl : UserControl, IBindableControl, IFieldTemplate
{
public MetaChildrenColumn ChildrenColumn {
get {
MetaColumn column = Column;
var ret = column as MetaChildrenColumn;
if (ret == null) {
string name = column == null ? null : column.Name;
throw new Exception ("'" + name + "' is not a children column and cannot be used here.");
}
return ret;
}
}
[MonoTODO]
protected string ChildrenPath {
get { return ChildrenColumn.GetChildrenListPath (Row); }
}
public MetaColumn Column {
get {
IFieldTemplateHost host = Host;
if (host != null)
return host.Column;
return null;
}
}
[MonoTODO]
public virtual Control DataControl { get; private set; }
[MonoTODO]
public virtual object FieldValue { get; set; }
[MonoTODO]
public virtual string FieldValueEditString { get; private set; }
[MonoTODO]
public virtual string FieldValueString { get; private set; }
[MonoTODO]
public MetaForeignKeyColumn ForeignKeyColumn {
get {
MetaColumn column = Column;
var ret = column as MetaForeignKeyColumn;
if (ret == null) {
string name = column == null ? null : column.Name;
throw new Exception ("'" + name + "' is not a foreign key column and cannot be used here.");
}
return ret;
}
}
[MonoTODO]
protected string ForeignKeyPath {
get { return ForeignKeyColumn.GetForeignKeyDetailsPath (Row); }
}
[MonoTODO]
public IFieldFormattingOptions FormattingOptions { get; private set; }
public IFieldTemplateHost Host { get; private set; }
[MonoTODO]
public System.ComponentModel.AttributeCollection MetadataAttributes {
get {
MetaColumn column = Column;
if (column == null)
return null;
return column.Attributes;
}
}
[MonoTODO]
public DataBoundControlMode Mode {
get {
IFieldTemplateHost host = Host;
return host == null ? DataBoundControlMode.ReadOnly : host.Mode;
}
}
[MonoTODO]
public virtual object Row {
get {
Page page = Page;
return page == null ? null : page.GetDataItem ();
}
}
[MonoTODO]
public MetaTable Table {
get {
MetaColumn column = Column;
return column == null ? null : column.Table;
}
}
[MonoTODO]
protected string BuildChildrenPath (string path)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected string BuildForeignKeyPath (string path)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual object ConvertEditedValue (string value)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void ExtractForeignKey (IDictionary dictionary, string selectedValue)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void ExtractValues (IOrderedDictionary dictionary)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected FieldTemplateUserControl FindOtherFieldTemplate (string columnName)
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual string FormatFieldValue (object fieldValue)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual object GetColumnValue (MetaColumn column)
{
throw new NotImplementedException ();
}
[MonoTODO]
void IBindableControl.ExtractValues (IOrderedDictionary dictionary)
{
ExtractValues (dictionary);
}
void IFieldTemplate.SetHost (IFieldTemplateHost host)
{
Host = host;
}
[MonoTODO]
protected void IgnoreModelValidationAttribute (Type attributeType)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected void PopulateListControl (ListControl listControl)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void SetUpValidator (BaseValidator validator)
{
}
[MonoTODO]
protected virtual void SetUpValidator (BaseValidator validator, MetaColumn column)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,111 @@
//
// FilterRepeater.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[ParseChildren (true)]
// [ToolboxItem]
public class FilterRepeater : Repeater, IWhereParametersProvider
{
[MonoTODO]
[Themeable (false)]
[Category ("Data")]
[DefaultValue (null)]
public string ContextTypeName { get; set; }
[MonoTODO]
[Themeable (false)]
[Category ("Behavior")]
[DefaultValue ("DynamicFilter")]
[IDReferenceProperty (typeof (FilterUserControlBase))]
public string DynamicFilterContainerId { get; set; }
[MonoTODO]
public MetaTable Table { get; private set; }
[MonoTODO]
[Themeable (false)]
[Category ("Data")]
[DefaultValue (null)]
public string TableName { get; set; }
[MonoTODO]
public override bool Visible { get; set; }
[MonoTODO]
public override void DataBind ()
{
throw new NotImplementedException ();
}
[MonoTODO]
protected internal virtual IEnumerable<MetaColumn> GetFilteredColumns ()
{
throw new NotImplementedException ();
}
[MonoTODO]
public virtual IEnumerable<Parameter> GetWhereParameters (IDynamicDataSource dataSource)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected virtual void OnFilterItemCreated (RepeaterItem item)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override void OnInit (EventArgs e)
{
throw new NotImplementedException ();
}
[MonoTODO]
protected override void OnItemCreated (RepeaterItemEventArgs e)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,90 @@
//
// FilterUserControlBase.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class FilterUserControlBase : UserControl, IControlParameterTarget
{
[MonoTODO]
public MetaColumn Column { get; private set; }
[MonoTODO]
public string ContextTypeName { get; set; }
[MonoTODO]
public string DataField { get; set; }
[MonoTODO]
MetaColumn IControlParameterTarget.FilteredColumn {
get { throw new NotImplementedException (); }
}
[MonoTODO]
MetaTable IControlParameterTarget.Table {
get { throw new NotImplementedException (); }
}
[MonoTODO]
public string InitialValue { get; private set; }
[MonoTODO]
public virtual DataKey SelectedDataKey { get; private set; }
[MonoTODO]
public virtual string SelectedValue { get; private set; }
[MonoTODO]
public string TableName { get; set; }
[MonoTODO]
string IControlParameterTarget.GetPropertyNameExpression (string columnName)
{
throw new NotImplementedException ();
}
[MonoTODO]
public void PopulateListControl (ListControl listControl)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,49 @@
//
// IControlParameterTarget.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IControlParameterTarget
{
MetaColumn FilteredColumn { get; }
MetaTable Table { get; }
string GetPropertyNameExpression (string columnName);
}
}

View File

@@ -0,0 +1,51 @@
//
// IFieldFormattingOptions.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IFieldFormattingOptions
{
bool ApplyFormatInEditMode { get; }
bool ConvertEmptyStringToNull { get; }
string DataFormatString { get; }
bool HtmlEncode { get; }
string NullDisplayText { get; }
}
}

View File

@@ -0,0 +1,47 @@
//
// IFieldTemplate.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IFieldTemplate
{
void SetHost (IFieldTemplateHost host);
}
}

View File

@@ -0,0 +1,49 @@
//
// IFieldTemplateFactory.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IFieldTemplateFactory
{
IFieldTemplate CreateFieldTemplate (MetaColumn column, DataBoundControlMode mode, string uiHint);
void Initialize (MetaModel model);
}
}

View File

@@ -0,0 +1,51 @@
//
// IFieldTemplateHost.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2008 Novell Inc. http://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;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Globalization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Web.Caching;
using System.Web.UI.WebControls;
namespace System.Web.DynamicData
{
[AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public interface IFieldTemplateHost
{
MetaColumn Column { get; }
IFieldFormattingOptions FormattingOptions { get; }
DataBoundControlMode Mode { get; }
string ValidationGroup { get; }
}
}

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