コード例 #1
0
        private string GetVirtualPath(IServiceProvider provider)
        {
            IDesignerHost        host         = (IDesignerHost)provider.GetService(typeof(IDesignerHost));
            WebFormsRootDesigner rootDesigner = host.GetDesigner(host.RootComponent) as WebFormsRootDesigner;

            return(System.IO.Path.GetFileName(rootDesigner.DocumentUrl));
        }
コード例 #2
0
        private bool CheckDynamicDataAllowed()
        {
            IDesignerHost        service  = (IDesignerHost)base.Component.Site.GetService(typeof(IDesignerHost));
            WebFormsRootDesigner designer = service.GetDesigner(service.RootComponent) as WebFormsRootDesigner;

            return((designer != null) && (designer.ReferenceManager.GetType("asp", "DynamicControl") != null));
        }
コード例 #3
0
 internal static string MapPath(IServiceProvider serviceProvider, string path)
 {
     if (path.Length != 0)
     {
         if (IsAbsolutePhysicalPath(path))
         {
             return(path);
         }
         WebFormsRootDesigner designer = null;
         if (serviceProvider != null)
         {
             IDesignerHost service = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
             if ((service != null) && (service.RootComponent != null))
             {
                 designer = service.GetDesigner(service.RootComponent) as WebFormsRootDesigner;
                 if (designer != null)
                 {
                     string          appRelativeUrl = designer.ResolveUrl(path);
                     IWebApplication application    = (IWebApplication)serviceProvider.GetService(typeof(IWebApplication));
                     if (application != null)
                     {
                         IProjectItem projectItemFromUrl = application.GetProjectItemFromUrl(appRelativeUrl);
                         if (projectItemFromUrl != null)
                         {
                             return(projectItemFromUrl.PhysicalPath);
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
コード例 #4
0
            /// <summary>
            /// RAS Modified to read values from configiuration section
            /// </summary>
            /// <returns></returns>
            private string GetFullPagePath()
            {
                //// read the virtual base path - Configuration object reads from
                //// custom web.config section in the designer
                //string BasePath = DbResourceConfiguration.Current.DesignTimeVirtualPath;
                //if (BasePath == null)
                //    BasePath = "";

                //if (BasePath.EndsWith("/"))
                //    BasePath.TrimEnd('/');

                IDesignerHost        host         = (IDesignerHost)_serviceProvider.GetService(typeof(IDesignerHost));
                WebFormsRootDesigner rootDesigner = host.GetDesigner(host.RootComponent) as WebFormsRootDesigner;

                return(rootDesigner.DocumentUrl.TrimStart('~', '/')); // Replace("~", "");
            }
コード例 #5
0
 public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     string[] values = null;
     if (context != null)
     {
         WebFormsRootDesigner designer = null;
         IDesignerHost        service  = (IDesignerHost)context.GetService(typeof(IDesignerHost));
         if (service != null)
         {
             IComponent rootComponent = service.RootComponent;
             if (rootComponent != null)
             {
                 designer = service.GetDesigner(rootComponent) as WebFormsRootDesigner;
             }
         }
         if ((designer != null) && !designer.IsDesignerViewLocked)
         {
             IComponent instance = context.Instance as IComponent;
             if (instance == null)
             {
                 DesignerActionList list = context.Instance as DesignerActionList;
                 if (list != null)
                 {
                     instance = list.Component;
                 }
             }
             IList <IComponent> allComponents = ControlHelper.GetAllComponents(instance, new ControlHelper.IsValidComponentDelegate(this.IsValidDataSource));
             List <string>      list3         = new List <string>();
             foreach (IComponent component3 in allComponents)
             {
                 Control control = component3 as Control;
                 if (((control != null) && !string.IsNullOrEmpty(control.ID)) && !list3.Contains(control.ID))
                 {
                     list3.Add(control.ID);
                 }
             }
             list3.Sort(StringComparer.OrdinalIgnoreCase);
             list3.Insert(0, System.Design.SR.GetString("DataSourceIDChromeConverter_NoDataSource"));
             list3.Add(System.Design.SR.GetString("DataSourceIDChromeConverter_NewDataSource"));
             values = list3.ToArray();
         }
     }
     return(new TypeConverter.StandardValuesCollection(values));
 }
コード例 #6
0
        internal Type GetControlType(string tagName, IDictionary attribs, bool throwOnError)
        {
            string typeName;
            string ns = _nsRegisterEntry.Namespace;

            if (String.IsNullOrEmpty(ns))
            {
                typeName = tagName;
            }
            else
            {
                typeName = ns + "." + tagName;
            }

            // Look up the type name (case insensitive)
            if (_assembly != null)
            {
                Type type = null;

                if (throwOnError)
                {
                    // If loading the type from the assembly depends on a referenced assembly that cannot
                    // be loaded, we should throw the actual exception, instead of later reporting a more
                    // generic error saying the type was not found (Devdiv 138674)
                    try {
                        type = _assembly.GetType(typeName, true /*throwOnError*/, true /*ignoreCase*/);
                    }
                    catch (System.IO.FileNotFoundException) {
                        throw;
                    }
                    catch (System.IO.FileLoadException) {
                        throw;
                    }
                    catch (BadImageFormatException) {
                        throw;
                    }
                    catch {
                        // For all other exceptions, such as when the type is not present in the assembly,
                        // we ignore the exception so that we can continue to check other assemblies to look
                        // for the type.
                    }
                }
                else
                {
                    type = _assembly.GetType(typeName, false /*throwOnError*/, true /*ignoreCase*/);
                }
                return(type);
            }

#if !FEATURE_PAL
            // If we're in the designer, check the WebFormsReferenceManager and ITypeResolutionService first.
            if (_parser.FInDesigner && (_parser.DesignerHost != null))
            {
                // If we are in the DesignTimeThemes Host, we can't actually go down this code path, let the TypeResolutionService try instead
                if (_parser.DesignerHost.RootComponent != null)
                {
                    WebFormsRootDesigner rootDesigner = _parser.DesignerHost.GetDesigner(_parser.DesignerHost.RootComponent) as WebFormsRootDesigner;
                    if (rootDesigner != null)
                    {
                        WebFormsReferenceManager referenceManager = rootDesigner.ReferenceManager;
                        if (referenceManager != null)
                        {
                            Type type = referenceManager.GetType(_nsRegisterEntry.TagPrefix, tagName);
                            if (type != null)
                            {
                                // Only return the type if we found it. Otherwise fall back to the next service.
                                return(type);
                            }
                        }
                    }
                }

                ITypeResolutionService typeResolutionService = (ITypeResolutionService)_parser.DesignerHost.GetService(typeof(ITypeResolutionService));
                if (typeResolutionService != null)
                {
                    Type type = typeResolutionService.GetType(typeName, false, true);
                    if (type != null)
                    {
                        // Only return the type if we found it. Otherwise fall back to the next service.
                        return(type);
                    }
                }
            }
#endif // !FEATURE_PAL

            // Nothing more to try in non-hosted appdomains
            if (!HostingEnvironment.IsHosted)
            {
                return(null);
            }

            // If the assembly was not specified, look for the type in the code assemblies (including sub code assemblies)
            return(BuildManager.GetTypeFromCodeAssembly(typeName, true /*ignoreCase*/));
        }
        internal Type GetControlType(string tagName, IDictionary attribs, bool throwOnError)
        {
            string str;
            string str2 = this._nsRegisterEntry.Namespace;

            if (string.IsNullOrEmpty(str2))
            {
                str = tagName;
            }
            else
            {
                str = str2 + "." + tagName;
            }
            if (this._assembly != null)
            {
                Type type = null;
                if (throwOnError)
                {
                    try
                    {
                        return(this._assembly.GetType(str, true, true));
                    }
                    catch (FileNotFoundException)
                    {
                        throw;
                    }
                    catch (FileLoadException)
                    {
                        throw;
                    }
                    catch (BadImageFormatException)
                    {
                        throw;
                    }
                    catch
                    {
                        return(type);
                    }
                }
                return(this._assembly.GetType(str, false, true));
            }
            if (this._parser.FInDesigner && (this._parser.DesignerHost != null))
            {
                if (this._parser.DesignerHost.RootComponent != null)
                {
                    WebFormsRootDesigner designer = this._parser.DesignerHost.GetDesigner(this._parser.DesignerHost.RootComponent) as WebFormsRootDesigner;
                    if (designer != null)
                    {
                        WebFormsReferenceManager referenceManager = designer.ReferenceManager;
                        if (referenceManager != null)
                        {
                            Type type2 = referenceManager.GetType(this._nsRegisterEntry.TagPrefix, tagName);
                            if (type2 != null)
                            {
                                return(type2);
                            }
                        }
                    }
                }
                ITypeResolutionService service = (ITypeResolutionService)this._parser.DesignerHost.GetService(typeof(ITypeResolutionService));
                if (service != null)
                {
                    Type type3 = service.GetType(str, false, true);
                    if (type3 != null)
                    {
                        return(type3);
                    }
                }
            }
            if (!HostingEnvironment.IsHosted)
            {
                return(null);
            }
            return(BuildManager.GetTypeFromCodeAssembly(str, true));
        }
コード例 #8
0
        private string CreateNewDataSource(System.Type dataSourceType)
        {
            string text = this._idTextBox.Text;
            string str2 = string.Empty;

            if (dataSourceType != null)
            {
                object obj2 = Activator.CreateInstance(dataSourceType);
                if (obj2 == null)
                {
                    return(str2);
                }
                System.Web.UI.Control newControl = obj2 as System.Web.UI.Control;
                if (newControl == null)
                {
                    return(str2);
                }
                newControl.ID = text;
                ISite serviceProvider = this.GetSite();
                if (serviceProvider == null)
                {
                    return(str2);
                }
                INameCreationService service = (INameCreationService)serviceProvider.GetService(typeof(INameCreationService));
                if (service != null)
                {
                    try
                    {
                        service.ValidateName(text);
                    }
                    catch (Exception exception)
                    {
                        UIServiceHelper.ShowError(serviceProvider, System.Design.SR.GetString("CreateDataSource_NameNotValid", new object[] { exception.Message }));
                        this._idTextBox.Focus();
                        return(str2);
                    }
                    IContainer container = serviceProvider.Container;
                    if (container != null)
                    {
                        ComponentCollection components = container.Components;
                        if ((components != null) && (components[text] != null))
                        {
                            UIServiceHelper.ShowError(serviceProvider, System.Design.SR.GetString("CreateDataSource_NameNotUnique"));
                            this._idTextBox.Focus();
                            return(str2);
                        }
                    }
                }
                IDesignerHost host = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
                if (host == null)
                {
                    return(str2);
                }
                IComponent rootComponent = host.RootComponent;
                if (rootComponent == null)
                {
                    return(str2);
                }
                WebFormsRootDesigner designer = host.GetDesigner(rootComponent) as WebFormsRootDesigner;
                if (designer == null)
                {
                    return(str2);
                }
                System.Web.UI.Control component = this.GetComponent() as System.Web.UI.Control;
                str2 = designer.AddControlToDocument(newControl, component, ControlLocation.After);
                IDesigner           designer2 = host.GetDesigner(newControl);
                IDataSourceDesigner designer3 = designer2 as IDataSourceDesigner;
                if (designer3 != null)
                {
                    if (designer3.CanConfigure && this._configure)
                    {
                        designer3.Configure();
                    }
                    return(str2);
                }
                IHierarchicalDataSourceDesigner designer4 = designer2 as IHierarchicalDataSourceDesigner;
                if (((designer4 != null) && designer4.CanConfigure) && this._configure)
                {
                    designer4.Configure();
                }
            }
            return(str2);
        }