Пример #1
0
        protected override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection descriptors = base.GetProperties(attributes);

            if (SqlNativeClientRegistered)
            {
                DynamicPropertyDescriptor providerDescriptor = descriptors.Find("Provider", true) as DynamicPropertyDescriptor;
                if (providerDescriptor != null)
                {
                    if (!DisableProviderSelection)
                    {
                        providerDescriptor.SetIsReadOnly(false);
                    }
                    providerDescriptor.SetConverterType(typeof(SqlProviderConverter));
                }
            }
            return(descriptors);
        }
Пример #2
0
        protected override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection descriptors = base.GetProperties(attributes);

            if (Access12ProviderRegistered)
            {
                DynamicPropertyDescriptor providerDescriptor = descriptors.Find("Provider", true) as DynamicPropertyDescriptor;
                if (providerDescriptor != null)
                {
                    if (!DisableProviderSelection)
                    {
                        providerDescriptor.SetIsReadOnly(false);
                    }
                    providerDescriptor.SetConverterType(typeof(JetProviderConverter));
                    providerDescriptor.AddValueChanged(ConnectionStringBuilder, new EventHandler(OnProviderChanged));
                }
                PropertyDescriptor dataSourceDescriptor = descriptors.Find("DataSource", true);
                if (dataSourceDescriptor != null)
                {
                    int index = descriptors.IndexOf(dataSourceDescriptor);
                    PropertyDescriptor[] descriptorArray = new PropertyDescriptor[descriptors.Count];
                    descriptors.CopyTo(descriptorArray, 0);
                    descriptorArray[index] = new DynamicPropertyDescriptor(dataSourceDescriptor);
                    descriptorArray[index].AddValueChanged(ConnectionStringBuilder, new EventHandler(OnDataSourceChanged));
                    descriptors = new PropertyDescriptorCollection(descriptorArray, true);
                }
            }
            PropertyDescriptor passwordDescriptor = descriptors.Find("Jet OLEDB:Database Password", true);

            if (passwordDescriptor != null)
            {
                int index = descriptors.IndexOf(passwordDescriptor);
                PropertyDescriptor[] descriptorArray = new PropertyDescriptor[descriptors.Count];
                descriptors.CopyTo(descriptorArray, 0);
                descriptorArray[index] = new DynamicPropertyDescriptor(passwordDescriptor, PasswordPropertyTextAttribute.Yes);
                descriptors            = new PropertyDescriptorCollection(descriptorArray, true);
            }
            return(descriptors);
        }