private void LoadExpressionEditors()
        {
            this._expressionEditors = new HybridDictionary(true);
            IWebApplication service = (IWebApplication)base.ServiceProvider.GetService(typeof(IWebApplication));

            if (service != null)
            {
                try
                {
                    System.Configuration.Configuration configuration = service.OpenWebConfiguration(true);
                    if (configuration != null)
                    {
                        CompilationSection section = (CompilationSection)configuration.GetSection("system.web/compilation");
                        foreach (ExpressionBuilder builder in section.ExpressionBuilders)
                        {
                            string           expressionPrefix = builder.ExpressionPrefix;
                            ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(expressionPrefix, base.ServiceProvider);
                            if (expressionEditor != null)
                            {
                                this._expressionEditors[expressionPrefix] = expressionEditor;
                                this._expressionBuilderComboBox.Items.Add(new ExpressionItem(expressionPrefix));
                            }
                        }
                    }
                }
                catch
                {
                }
                this._expressionBuilderComboBox.InvalidateDropDownWidth();
            }
            this._expressionBuilderComboBox.Items.Add(this.NoneItem);
        }
        private static string LocalizeControl(Control control, IServiceProvider serviceProvider, IDesignTimeResourceWriter resourceWriter, bool shouldLocalizeInnerContent)
        {
            ResourceExpressionEditor expressionEditor  = (ResourceExpressionEditor)ExpressionEditor.GetExpressionEditor("resources", serviceProvider);
            IControlBuilderAccessor  accessor          = control;
            ControlBuilder           controlBuilder    = accessor.ControlBuilder;
            ObjectPersistData        objectPersistData = controlBuilder.GetObjectPersistData();
            string resourceKey = controlBuilder.GetResourceKey();
            string b           = LocalizeObject(serviceProvider, control, objectPersistData, expressionEditor, resourceWriter, resourceKey, string.Empty, control, string.Empty, shouldLocalizeInnerContent, false, false);

            if (!string.Equals(resourceKey, b, StringComparison.OrdinalIgnoreCase))
            {
                controlBuilder.SetResourceKey(b);
            }
            if (objectPersistData != null)
            {
                foreach (PropertyEntry entry in objectPersistData.AllPropertyEntries)
                {
                    BoundPropertyEntry entry2 = entry as BoundPropertyEntry;
                    if ((entry2 != null) && !entry2.Generated)
                    {
                        string[] strArray = entry2.Name.Split(new char[] { '.' });
                        if (strArray.Length > 1)
                        {
                            object component = control;
                            foreach (string str3 in strArray)
                            {
                                PropertyDescriptor descriptor = TypeDescriptor.GetProperties(component)[str3];
                                if (descriptor == null)
                                {
                                    break;
                                }
                                PersistenceModeAttribute attribute = descriptor.Attributes[typeof(PersistenceModeAttribute)] as PersistenceModeAttribute;
                                if (attribute != PersistenceModeAttribute.Attribute)
                                {
                                    if (string.Equals(entry2.ExpressionPrefix, "resources", StringComparison.OrdinalIgnoreCase))
                                    {
                                        System.Web.Compilation.ResourceExpressionFields parsedExpressionData = entry2.ParsedExpressionData as System.Web.Compilation.ResourceExpressionFields;
                                        if ((parsedExpressionData != null) && string.IsNullOrEmpty(parsedExpressionData.ClassKey))
                                        {
                                            object obj3 = expressionEditor.EvaluateExpression(entry2.Expression, entry2.ParsedExpressionData, entry2.PropertyInfo.PropertyType, serviceProvider);
                                            if (obj3 == null)
                                            {
                                                object obj4;
                                                obj3 = ControlDesigner.GetComplexProperty(control, entry2.Name, out obj4).GetValue(obj4);
                                            }
                                            resourceWriter.AddResource(parsedExpressionData.ResourceKey, obj3);
                                        }
                                    }
                                    break;
                                }
                                component = descriptor.GetValue(component);
                            }
                        }
                    }
                }
            }
            return(b);
        }
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            System.Web.UI.Control instance = context.Instance as System.Web.UI.Control;
            if (provider != null)
            {
                IDataEnvironment environment = (IDataEnvironment)provider.GetService(typeof(IDataEnvironment));
                if (environment != null)
                {
                    IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
                    if ((edSvc != null) && (context.Instance != null))
                    {
                        if (this._connectionStringPicker == null)
                        {
                            this._connectionStringPicker = new ConnectionStringPicker();
                        }
                        string           connectionString = (string)value;
                        ExpressionEditor expressionEditor = ExpressionEditor.GetExpressionEditor(typeof(ConnectionStringsExpressionBuilder), provider);
                        if (expressionEditor == null)
                        {
                            return(value);
                        }
                        string expressionPrefix = expressionEditor.ExpressionPrefix;
                        DesignerDataConnection currentConnection = GetCurrentConnection(instance, context.PropertyDescriptor.Name, connectionString, expressionPrefix);
                        this._connectionStringPicker.Start(edSvc, environment.Connections, currentConnection);
                        edSvc.DropDownControl(this._connectionStringPicker);
                        if (this._connectionStringPicker.SelectedItem != null)
                        {
                            DesignerDataConnection selectedConnection = this._connectionStringPicker.SelectedConnection;
                            if (selectedConnection == null)
                            {
                                selectedConnection = environment.BuildConnection(UIServiceHelper.GetDialogOwnerWindow(provider), null);
                            }
                            if (selectedConnection != null)
                            {
                                if (selectedConnection.IsConfigured)
                                {
                                    ((IExpressionsAccessor)instance).Expressions.Add(new ExpressionBinding(context.PropertyDescriptor.Name, context.PropertyDescriptor.PropertyType, expressionPrefix, selectedConnection.Name));
                                    this.SetProviderName(context.Instance, selectedConnection);
                                    IComponentChangeService service = (IComponentChangeService)provider.GetService(typeof(IComponentChangeService));
                                    if (service != null)
                                    {
                                        service.OnComponentChanged(instance, null, null, null);
                                    }
                                }
                                else
                                {
                                    value = selectedConnection.ConnectionString;
                                    this.SetProviderName(context.Instance, selectedConnection);
                                }
                            }
                        }
                        this._connectionStringPicker.End();
                    }
                    return(value);
                }
            }
            string providerName = this.GetProviderName(context.Instance);
            ConnectionStringEditorDialog form = new ConnectionStringEditorDialog(provider, providerName)
            {
                ConnectionString = (string)value
            };

            if (UIServiceHelper.ShowDialog(provider, form) == DialogResult.OK)
            {
                value = form.ConnectionString;
            }
            return(value);
        }