2 // DynamicDataExtensions.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2008 Novell Inc. http://novell.com
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Collections.Specialized;
34 using System.Globalization;
35 using System.Security.Permissions;
36 using System.Security.Principal;
37 using System.Web.Caching;
39 using System.Web.UI.WebControls;
40 using System.Web.DynamicData.ModelProviders;
42 namespace System.Web.DynamicData
44 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
45 public static class DynamicDataExtensions
48 public static object ConvertEditedValue (this IFieldFormattingOptions formattingOptions, string value)
50 throw new NotImplementedException ();
54 public static void EnablePersistedSelection (this BaseDataBoundControl dataBoundControl)
56 throw new NotImplementedException ();
60 public static void ExpandDynamicWhereParameters (this IDynamicDataSource dataSource)
62 throw new NotImplementedException ();
66 public static IDynamicDataSource FindDataSourceControl (this Control current)
68 throw new NotImplementedException ();
72 public static Control FindFieldTemplate (this Control control, string columnName)
74 throw new NotImplementedException ();
77 public static MetaTable FindMetaTable (this Control current)
79 // .NET doesn't perform the check, we will
81 throw new NullReferenceException ();
83 while (current != null) {
84 DataBoundControl dbc = current as DataBoundControl;
86 IDynamicDataSource dds = dbc.InternalGetDataSource () as IDynamicDataSource;
88 return dds.GetTable ();
91 current = current.NamingContainer;
98 public static string FormatEditValue (this IFieldFormattingOptions formattingOptions, object fieldValue)
100 throw new NotImplementedException ();
104 public static string FormatValue (this IFieldFormattingOptions formattingOptions, object fieldValue)
106 throw new NotImplementedException ();
109 static string GetDataSourceId (IDynamicDataSource dataSource)
111 Control c = dataSource as Control;
118 public static MetaTable GetTable (this IDynamicDataSource dataSource)
120 if (dataSource == null)
123 string entitySetName = dataSource.EntitySetName;
124 if (String.IsNullOrEmpty (entitySetName)) {
125 // LAMESPEC: MSDN says we should throw in this case, but .NET calls
126 // DynamicDataRouteHandler.GetRequestMetaTable(HttpContext
127 // httpContext) instead (eventually)
128 MetaTable ret = DynamicDataRouteHandler.GetRequestMetaTable (HttpContext.Current);
130 throw new InvalidOperationException ("The control '" + GetDataSourceId (dataSource) +
131 "' does not have a TableName property and a table name cannot be inferred from the URL.");
134 Type contextType = dataSource.ContextType;
135 if (contextType == null)
136 throw new InvalidOperationException ("The ContextType property of control '" + GetDataSourceId (dataSource) + "' must specify a data context");
138 return MetaModel.GetModel (contextType).GetTable (entitySetName);
142 public static void LoadWithForeignKeys (this LinqDataSource dataSource, Type rowType)
144 throw new NotImplementedException ();