Ejemplo n.º 1
0
        internal static void EnableDynamicData(INamingContainer control, string entityTypeName)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            if (s_enableDynamicDataMethod == null)
            {
                Type dataControlExtensionsType = Assembly.Load(AssemblyRef.SystemWebDynamicData).GetType("System.Web.UI.DataControlExtensions");
                s_enableDynamicDataMethod = dataControlExtensionsType.GetMethod("EnableDynamicData",
                                                                                BindingFlags.Public | BindingFlags.Static,
                                                                                binder: null,
                                                                                types: new Type[] { typeof(INamingContainer), typeof(Type) },
                                                                                modifiers: null);
            }
            Debug.Assert(s_enableDynamicDataMethod != null);

            Type entityType = BuildManager.GetType(entityTypeName, throwOnError: false);

            if (entityType != null)
            {
                s_enableDynamicDataMethod.Invoke(obj: null,
                                                 parameters: new object[] { control, entityType });
            }
        }
Ejemplo n.º 2
0
        public static void EnableDynamicData(this INamingContainer control, Type entityType, object defaults)
        {
            MetaTable table = GetTableFromCache(entityType);

            control.SetMetaTable(table, defaults);
            DynamicDataExtensions.ApplyFieldGenerator(control, table);
        }
Ejemplo n.º 3
0
 public static void SetMetaTable(this INamingContainer control, MetaTable table, object defaultValues)
 {
     if (defaultValues == null)
     {
         throw new ArgumentNullException("defaultValues");
     }
     SetMetaTableInternal(control, table, Misc.ConvertObjectToDictionary(defaultValues), new HttpContextWrapper(HttpContext.Current));
 }
Ejemplo n.º 4
0
        public string GetUniqueName(INamingContainer container, IDesignableControl newChild)
        {
            var    type          = newChild.GetType();
            string namePart      = type.Name;
            int    existingCount = (from c in container.Children where c.GetType() == type select c).Count();

            return(namePart + existingCount);
        }
Ejemplo n.º 5
0
        internal static bool TryGetMetaTable(INamingContainer control, HttpContextBase context, out MetaTable table)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }

            table = MetaTableHelper.GetTableFromMapping(context, control);
            return(table != null);
        }
Ejemplo n.º 6
0
        internal static MetaTable GetMetaTable(INamingContainer control, HttpContextBase context)
        {
            MetaTable table;

            if (!TryGetMetaTable(control, context, out table))
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, DynamicDataResources.MetaTable_CannotGetTableFromControl));
            }
            return(table);
        }
Ejemplo n.º 7
0
        internal static void ApplyFieldGenerator(INamingContainer control, MetaTable table)
        {
            GridView gridView = control as GridView;

            if (gridView != null && gridView.AutoGenerateColumns && gridView.ColumnsGenerator == null)
            {
                gridView.ColumnsGenerator = new DefaultAutoFieldGenerator(table);
            }
            else
            {
                DetailsView detailsView = control as DetailsView;
                if (detailsView != null && detailsView.AutoGenerateRows && detailsView.RowsGenerator == null)
                {
                    detailsView.RowsGenerator = new DefaultAutoFieldGenerator(table);
                }
            }
        }
Ejemplo n.º 8
0
        internal static void SetMetaTableInternal(INamingContainer control, MetaTable table, IDictionary <string, object> defaultValues, HttpContextBase context)
        {
            if (control == null)
            {
                throw new ArgumentNullException("control");
            }
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }
            IDataBoundControl dataBoundControl = control as IDataBoundControl;
            IDataSource       dataSource       = null;

            if (dataBoundControl != null)
            {
                dataSource = dataBoundControl.DataSourceObject;
            }
            MetaTableHelper.SetTableInMapping(context, control, table, defaultValues);
            if (dataSource != null)
            {
                // If the control being mapped is a databound control then register its datasource
                MetaTableHelper.SetTableInMapping(context, dataSource, table, defaultValues);
            }
        }
Ejemplo n.º 9
0
 public static bool TryGetMetaTable(this INamingContainer control, out MetaTable table)
 {
     return(TryGetMetaTable(control, new HttpContextWrapper(HttpContext.Current), out table));
 }
Ejemplo n.º 10
0
 public static MetaTable GetMetaTable(this INamingContainer control)
 {
     return(GetMetaTable(control, new HttpContextWrapper(HttpContext.Current)));
 }
Ejemplo n.º 11
0
 public static IDictionary <string, object> GetDefaultValues(this INamingContainer control)
 {
     return(GetDefaultValues(control, new HttpContextWrapper(HttpContext.Current)));
 }
Ejemplo n.º 12
0
 public static void SetMetaTable(this INamingContainer control, MetaTable table)
 {
     SetMetaTableInternal(control, table, null /* defaultValues*/, new HttpContextWrapper(HttpContext.Current));
 }
        internal static void EnableDynamicData(INamingContainer control, string entityTypeName) {
            if (control == null) {
                throw new ArgumentNullException("control");
            }

            if (s_enableDynamicDataMethod == null) {
                Type dataControlExtensionsType = Assembly.Load(AssemblyRef.SystemWebDynamicData).GetType("System.Web.UI.DataControlExtensions");
                s_enableDynamicDataMethod = dataControlExtensionsType.GetMethod("EnableDynamicData",
                                                                              BindingFlags.Public | BindingFlags.Static,
                                                                              binder: null,
                                                                              types: new Type[] { typeof(INamingContainer), typeof(Type) },
                                                                              modifiers: null);
            }
            Debug.Assert(s_enableDynamicDataMethod != null);

            Type entityType = BuildManager.GetType(entityTypeName, throwOnError: false);
            if (entityType != null) {
                s_enableDynamicDataMethod.Invoke(obj: null,
                                               parameters: new object[] { control, entityType });
            }
        }