private void OnOKButtonClick(object sender, EventArgs e)
 {
     if (this._bindingsDirty)
     {
         ExpressionBindingCollection expressions  = ((IExpressionsAccessor)this.Control).Expressions;
         DataBindingCollection       dataBindings = ((IDataBindingsAccessor)this.Control).DataBindings;
         expressions.Clear();
         foreach (BindablePropertyNode node in this._bindablePropsTree.Nodes)
         {
             if (node.IsBound)
             {
                 expressions.Add(node.Binding);
                 if (dataBindings.Contains(node.Binding.PropertyName))
                 {
                     dataBindings.Remove(node.Binding.PropertyName);
                 }
             }
         }
         foreach (ExpressionBinding binding in this._complexBindings.Values)
         {
             expressions.Add(binding);
         }
     }
     base.DialogResult = DialogResult.OK;
     base.Close();
 }
 internal static void PersistConnectionSettings(SqlDataSource sqlDataSource, SqlDataSourceDesigner sqlDataSourceDesigner, DesignerDataConnection dataConnection)
 {
     if (dataConnection.IsConfigured)
     {
         ExpressionBindingCollection expressions = sqlDataSource.Expressions;
         PropertyDescriptor          descriptor  = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
         descriptor.ResetValue(sqlDataSource);
         if (dataConnection.ProviderName != "System.Data.SqlClient")
         {
             expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name + ".ProviderName"));
         }
         descriptor = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
         descriptor.ResetValue(sqlDataSource);
         expressions.Add(new ExpressionBinding(descriptor.Name, descriptor.PropertyType, "ConnectionStrings", dataConnection.Name));
     }
     else
     {
         PropertyDescriptor descriptor2;
         if (sqlDataSource.ProviderName != dataConnection.ProviderName)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ProviderName"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ProviderName);
         }
         if (sqlDataSource.ConnectionString != dataConnection.ConnectionString)
         {
             descriptor2 = TypeDescriptor.GetProperties(sqlDataSource)["ConnectionString"];
             descriptor2.ResetValue(sqlDataSource);
             descriptor2.SetValue(sqlDataSource, dataConnection.ConnectionString);
         }
     }
 }
        private void LoadBindableProperties()
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.Control, BindablePropertiesFilter);
            string             name            = null;
            PropertyDescriptor defaultProperty = TypeDescriptor.GetDefaultProperty(this.Control);

            if (defaultProperty != null)
            {
                name = defaultProperty.Name;
            }
            TreeNodeCollection          nodes       = this._bindablePropsTree.Nodes;
            ExpressionBindingCollection expressions = ((IExpressionsAccessor)this.Control).Expressions;
            Hashtable hashtable = new Hashtable(StringComparer.OrdinalIgnoreCase);

            foreach (ExpressionBinding binding in expressions)
            {
                hashtable[binding.PropertyName] = binding;
            }
            TreeNode node = null;

            foreach (PropertyDescriptor descriptor2 in properties)
            {
                if (string.Compare(descriptor2.Name, "ID", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    ExpressionBinding binding2 = null;
                    if (hashtable.Contains(descriptor2.Name))
                    {
                        binding2 = (ExpressionBinding)hashtable[descriptor2.Name];
                        hashtable.Remove(descriptor2.Name);
                    }
                    TreeNode node2 = new BindablePropertyNode(descriptor2, binding2);
                    if (descriptor2.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
                    {
                        node = node2;
                    }
                    nodes.Add(node2);
                }
            }
            this._complexBindings = hashtable;
            if ((node == null) && (nodes.Count != 0))
            {
                int count = nodes.Count;
                for (int i = 0; i < count; i++)
                {
                    BindablePropertyNode node3 = (BindablePropertyNode)nodes[i];
                    if (node3.IsBound)
                    {
                        node = node3;
                        break;
                    }
                }
                if (node == null)
                {
                    node = nodes[0];
                }
            }
            if (node != null)
            {
                this._bindablePropsTree.SelectedNode = node;
            }
        }