public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
 {
     TypeConverter.StandardValuesCollection valuess = this._standardValues;
     if (this._standardValues == null)
     {
         DataTable     elements = new OleDbEnumerator().GetElements();
         DataColumn    column2  = elements.Columns["SOURCES_NAME"];
         DataColumn    column   = elements.Columns["SOURCES_TYPE"];
         List <string> values   = new List <string>(elements.Rows.Count);
         foreach (DataRow row in elements.Rows)
         {
             int num = (int)row[column];
             if ((1 == num) || (3 == num))
             {
                 string item = (string)row[column2];
                 if (!OleDbConnectionString.IsMSDASQL(item.ToLower(CultureInfo.InvariantCulture)) && (0 > values.IndexOf(item)))
                 {
                     values.Add(item);
                 }
             }
         }
         valuess = new TypeConverter.StandardValuesCollection(values);
         this._standardValues = valuess;
     }
     return(valuess);
 }
Пример #2
0
            public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                StandardValuesCollection dataSourceNames = _standardValues;

                if (null == _standardValues)
                {
                    // Get the sources rowset for the SQLOLEDB enumerator
                    DataTable table = (new OleDbEnumerator()).GetElements();

                    DataColumn column2 = table.Columns["SOURCES_NAME"];
                    DataColumn column5 = table.Columns["SOURCES_TYPE"];
                    //DataColumn column4 = table.Columns["SOURCES_DESCRIPTION"];

                    System.Collections.Generic.List <string> providerNames = new System.Collections.Generic.List <string>(table.Rows.Count);
                    foreach (DataRow row in table.Rows)
                    {
                        int sourceType = (int)row[column5];
                        if (DBSOURCETYPE_DATASOURCE_TDP == sourceType || DBSOURCETYPE_DATASOURCE_MDP == sourceType)
                        {
                            string progid = (string)row[column2];
                            if (!OleDbConnectionString.IsMSDASQL(progid.ToLowerInvariant()))
                            {
                                if (0 > providerNames.IndexOf(progid))
                                {
                                    providerNames.Add(progid);
                                }
                            }
                        }
                    }

                    // Create the standard values collection that contains the sources
                    dataSourceNames = new StandardValuesCollection(providerNames);
                    _standardValues = dataSourceNames;
                }
                return(dataSourceNames);
            }