/// <summary> /// Returns the collection of standard values for /// the <see cref="HsqlConnectionStringBuilder.DataSource"/> /// property. /// </summary> /// <param name="context">Which may hold</param> /// <returns> /// The standard set of valid values. /// </returns> public override TypeConverter.StandardValuesCollection GetStandardValues( ITypeDescriptorContext context) { DataTable dataSources = DSEC.GetDataSources(); DataRowCollection rows = dataSources.Rows; int rowCount = rows.Count; string[] array; if (context != null && context.Instance != null) { // might be a connection string builder or wrapper for one. try { HsqlConnectionStringBuilder csb = new HsqlConnectionStringBuilder( Convert.ToString(context.Instance)); array = new string[rowCount + 1]; array[rowCount] = csb.DataSource; } catch (Exception) { array = new string[rowCount]; } } else { array = new string[rowCount]; } for (int i = 0; i < rowCount; i++) { DataRow row = rows[i]; string prefix = row[DSEC.ServerNameColumnOrdinal] as string; string suffix = row[DSEC.InstanceNameColumnOrdinal] as string; string version = row[DSEC.VersionColumnOrdinal] as string; if (string.IsNullOrEmpty(version) || version.StartsWith("1.8.0", StringComparison.Ordinal)) { array[i] = (string.IsNullOrEmpty(suffix)) ? prefix.Replace('\\', '/') : new StringBuilder(prefix) .Replace('\\', '/') .Append('/') .Append(suffix.Replace('\\', '/').TrimStart('/')) .ToString(); } else { array[i] = string.Empty; } } org.hsqldb.lib.HashSet set = new org.hsqldb.lib.HashSet(); set.addAll(array); set.remove(string.Empty); if (array.Length != set.size()) { array = new string[set.size()]; } set.toArray(array); Array.Sort<string>(array); return new TypeConverter.StandardValuesCollection(array); }
/// <summary> /// Returns the collection of standard values for /// the <see cref="HsqlConnectionStringBuilder.DataSource"/> /// property. /// </summary> /// <param name="context">Which may hold</param> /// <returns> /// The standard set of valid values. /// </returns> public override TypeConverter.StandardValuesCollection GetStandardValues( ITypeDescriptorContext context) { DataTable dataSources = DSEC.GetDataSources(); DataRowCollection rows = dataSources.Rows; int rowCount = rows.Count; string[] array; if (context != null && context.Instance != null) { // might be a connection string builder or wrapper for one. try { HsqlConnectionStringBuilder csb = new HsqlConnectionStringBuilder( Convert.ToString(context.Instance)); array = new string[rowCount + 1]; array[rowCount] = csb.DataSource; } catch (Exception) { array = new string[rowCount]; } } else { array = new string[rowCount]; } for (int i = 0; i < rowCount; i++) { DataRow row = rows[i]; string prefix = row[DSEC.ServerNameColumnOrdinal] as string; string suffix = row[DSEC.InstanceNameColumnOrdinal] as string; string version = row[DSEC.VersionColumnOrdinal] as string; if (string.IsNullOrEmpty(version) || version.StartsWith("1.8.0", StringComparison.Ordinal)) { array[i] = (string.IsNullOrEmpty(suffix)) ? prefix.Replace('\\', '/') : new StringBuilder(prefix) .Replace('\\', '/') .Append('/') .Append(suffix.Replace('\\', '/').TrimStart('/')) .ToString(); } else { array[i] = string.Empty; } } org.hsqldb.lib.HashSet set = new org.hsqldb.lib.HashSet(); set.addAll(array); set.remove(string.Empty); if (array.Length != set.size()) { array = new string[set.size()]; } set.toArray(array); Array.Sort <string>(array); return(new TypeConverter.StandardValuesCollection(array)); }