本文整理汇总了C#中StringCollection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# StringCollection.ToArray方法的具体用法?C# StringCollection.ToArray怎么用?C# StringCollection.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringCollection
的用法示例。
在下文中一共展示了StringCollection.ToArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Item
public Item(string key, StringCollection value)
{
if (key == null)
{
throw new ArgumentNullException("key");
}
if (value == null)
{
throw new ArgumentNullException("value");
}
this.key = key;
this.text = value.ToArray();
}
示例2: GetList
//***************************************************************************
// Public Methods
//
public string GetList()
{
int longLen = 0;
StringCollection strCol = new StringCollection();
string[] lns = this.txtItems.Text.Split(new char[] { ',', ';', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < lns.Length; i++)
{
if (chkDistinct.Checked)
strCol.AddUnique(lns[i]);
else
strCol.Add(lns[i]);
longLen = (int)System.Math.Max(longLen, lns[i].Length);
}
string retVal = "";
lns = strCol.ToArray();
for (int i = 0; i < lns.Length; i++)
{
string newVal = string.Format("{2}{3}{1}{0}{1}{4}",
lns[i],
(this.chkQuotes.Checked)
? "'"
: "",
(i > 0) ? "," : "",
(this.chkCheckSpace.Checked)
? ((i > 0) ? " " : "")
: "",
(this.numLnBreak.Value > 0 && ((i + 1) % (int)numLnBreak.Value == 0))
? "\n"
: "");
if (this.chkAlign.Checked)
newVal = newVal.PadLeft(longLen + ((this.chkCheckSpace.Checked) ? 1 : 0) + ((this.chkQuotes.Checked) ? 2 : 0) + ((this.numLnBreak.Value > 0 && ((i + 1) % (int)numLnBreak.Value == 0)) ? 1 : 0) + 1, ' ');
retVal += newVal;
}
return retVal.TrimEnd(',', '\n');
}
示例3: SetText
public void SetText (StringCollection fields)
{
raw_data = null;
Text = fields != null ? fields.ToArray () : null;
}
示例4: UpdateLocaleIds
/// <summary>
/// Updates the requested locale ids.
/// </summary>
/// <returns>true if the new locale ids are different from the old locale ids.</returns>
public bool UpdateLocaleIds(StringCollection localeIds)
{
if (localeIds == null) throw new ArgumentNullException("localeIds");
lock (m_lock)
{
string[] ids = localeIds.ToArray();
if (!Utils.IsEqual(ids, m_localeIds))
{
m_localeIds = ids;
// update diagnostics.
lock (m_diagnostics)
{
m_diagnostics.LocaleIds = new StringCollection(localeIds);
}
return true;
}
return false;
}
}
示例5: BreakAppart
public static string[] BreakAppart(string value, int size, bool keepOfflen)
{
StringCollection retVal = new StringCollection();
for (int i = 0; i < value.Length; i += size)
{
if (i + size < value.Length)
retVal.Add(value.Substring(i, size), i.ToString().PadLeft(5, '0'));
else if (keepOfflen)
retVal.Add(value.Substring(i), i.ToString().PadLeft(5, '0'));
}
return retVal.ToArray();
}
示例6: ParseBaseTableName
/// <summary>
/// Parses a given QueryString to determine the base table name specified in the query.
/// </summary>
/// <param name="QueryString">The query to parse.</param>
/// <param name="RemoveQualifier">If set to true, all table qualifiers are removed from the returned value.</param>
/// <returns>A string value containing the base table name from the query with all leading/trailing spaces removed.</returns>
public static string[] ParseBaseTableName(string QueryString, bool RemoveQualifier)
{
StringCollection retVals = new StringCollection();
if (QueryString.ToUpper().IndexOf("FROM") > -1 && (QueryString.Length - (QueryString.ToUpper().IndexOf("FROM") + 5) > 0))
{
// Find the start and end positions of the table names.
int tblStart = QueryString.ToUpper().IndexOf("FROM") + 5;
int tblEnd = -1;
if (QueryString.ToUpper().IndexOf("WHERE") > -1)
tblEnd = QueryString.ToUpper().IndexOf("WHERE", tblStart);
else if (QueryString.ToUpper().IndexOf("HAVING") > -1)
tblEnd = QueryString.ToUpper().IndexOf("HAVING", tblStart);
else
tblEnd = QueryString.Length;
// Get a string of just the table names.
string tableNames = QueryString.Substring(tblStart, tblEnd - tblStart);
// Split the tableNames string by coma's.
string[] tblNames = tableNames.Split(',');
foreach (string tbl in tblNames)
{
string tblName = tbl;
// Strip any alias names
if (tblName.IndexOf(' ') > -1)
tblName = tblName.Substring(0, tblName.IndexOf(' '));
// Remove qualifiers if required.
if (RemoveQualifier && tblName.IndexOf('.') > -1)
tblName = tblName.Substring(tblName.LastIndexOf('.') + 1);
// Add each table name to the collection, stripping off
// any leading/trailing commas & spaces.
retVals.Add(tblName.Trim(',', ' '));
}
}
#region Depreciated Code
// This method did not accomodate queries pulling from multiple tables.
//
//if (QueryString.ToUpper().IndexOf("FROM") > -1 && (QueryString.Length - (QueryString.ToUpper().IndexOf("FROM") + 5) > 0))
//{
// baseTableName = QueryString.Substring(QueryString.ToUpper().IndexOf("FROM") + 5, QueryString.Length - (QueryString.ToUpper().IndexOf("FROM") + 5)).Trim();
// if (baseTableName.IndexOf(' ', 0) > -1 && baseTableName.IndexOf(' ', 0) < baseTableName.Length)
// baseTableName = baseTableName.Substring(0, baseTableName.IndexOf(' ', 0));
// if (RemoveQualifier == true)
// {
// while (baseTableName.IndexOf('.') > 0) baseTableName = baseTableName.Substring(baseTableName.IndexOf('.') + 1, baseTableName.Length - (baseTableName.IndexOf('.') + 1));
// }
//}
#endregion
return retVals.ToArray();
}
示例7: SetText
public void SetText(StringCollection fields)
{
this.raw_data = null;
this.Text = (fields == null) ? null : fields.ToArray();
}
示例8: GetObjectTextCreate
public string[] GetObjectTextCreate(string databaseName, string spName)
{
this._qryExec = true;
try
{
this.CheckConnectionReady();
//if (spName.IndexOf('.') > -1)
// spName = spName.Substring(spName.LastIndexOf('.') + 1);
spName = spName.Replace("'", "''");
string qry = string.Format("USE {0} EXEC sp_helptext '{1}'", databaseName, spName);
StringCollection returnText = new StringCollection();
using (SqlCommand cmd = new SqlCommand(qry, this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
returnText.Add(rdr.GetString(0).TrimEnd());
return returnText.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例9: SearchForObjName
private string[] SearchForObjName(string funcName, string srchName, bool continueOnPermError)
{
System.Reflection.MethodInfo miFunc = this.GetType().GetMethod(funcName, new Type[] { typeof(string) });
this._qryExec = true;
try
{
// Create a RegularExpression object so that we can easily search
// using wildcard characters ('*' or '%').
string regExStr = "^" + srchName.Replace("*", ".*").Replace("%", ".*") + "$";
System.Text.RegularExpressions.Regex regxWldCrd = new System.Text.RegularExpressions.Regex(regExStr, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
// Get a list of all databases for the given connection string.
string[] dbList = this.GetDatabaseList();
this._qryExec = true;
// Create a StringCollection
StringCollection tblCol = new StringCollection();
foreach (string dbName in dbList)
{
try
{
string[] tblList = (string[])miFunc.Invoke(this, new object[] { dbName });
this._qryExec = true;
foreach (string tblName in tblList)
{
try
{
// If the passed search string doesn't have a schema qualifier,
// then remove the one from the current table name.
string tblNameQual = (tblName.IndexOf('.') > -1 && srchName.IndexOf('.') < 0)
? tblName.Substring(tblName.IndexOf('.') + 1)
: tblName;
// If a match was found, add the table name to the collection
if (regxWldCrd.IsMatch(tblNameQual))
tblCol.Add(dbName + "." + tblName);
}
catch (System.Exception ex)
{
if (ex.InnerException is System.Data.SqlClient.SqlException && continueOnPermError && ex.ToString().Contains("The server principal ") && ex.ToString().Contains(" is not able to access the database ") && ex.ToString().Contains(" under the current security context."))
{
// We're going to ignore this error and continue
// searching whichever databases we *are*
// allowed to access.
}
else
throw;
}
}
}
catch (System.Exception ex)
{
if (ex.InnerException is System.Data.SqlClient.SqlException && continueOnPermError && ex.ToString().Contains("The server principal ") && ex.ToString().Contains(" is not able to access the database ") && ex.ToString().Contains(" under the current security context."))
{
// We're going to ignore this error and continue
// searching whichever databases we *are*
// allowed to access.
}
else
throw;
}
}
// Return the collection as a flat string array.
return tblCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例10: GetIndexList
public string[] GetIndexList(string databaseName, string tableName, bool isView, bool allIdxs)
{
this._qryExec = true;
try
{
string tblNm, usrNm;
rsDbSql.ParseSchemaAndTableName(tableName, out tblNm, out usrNm);
this.CheckConnectionReady();
StringCollection idxCol = new StringCollection();
using (SqlCommand cmd = new SqlCommand(string.Format("SELECT name FROM {0}.sys.sysindexes WHERE id = (SELECT so.id FROM {0}.sys.sysobjects so INNER JOIN {0}.sys.schemas su ON su.schema_id = so.uid AND su.name = '{2}' WHERE xtype=N'{3}' AND so.name='{1}') ORDER BY name", databaseName, tblNm, usrNm, (isView) ? "V" : "U"), this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
{
string rowVal = rdr.GetString(0);
if (allIdxs || (!rowVal.StartsWith("_dta_") && !rowVal.StartsWith("_WA_sys_")))
idxCol.Add(rowVal);
}
return idxCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例11: GetColumnList
public string[] GetColumnList(string databaseName, string tableName, bool isView)
{
this._qryExec = true;
try
{
string tblNm, usrNm;
rsDbSql.ParseSchemaAndTableName(tableName, out tblNm, out usrNm);
this.CheckConnectionReady();
StringCollection colmnCol = new StringCollection();
string qry = string.Format("SELECT sc.name FROM {0}.sys.syscolumns sc INNER JOIN {0}.sys.sysobjects so ON sc.id = so.id AND so.id = (SELECT so.id FROM {0}.sys.sysobjects so INNER JOIN {0}.sys.schemas su ON su.schema_id = so.uid AND su.name = '{2}' WHERE so.name = '{1}' AND so.xtype=N'{3}') ORDER BY sc.colorder", databaseName, tblNm, usrNm, (!isView) ? "U" : "V");
using (SqlCommand cmd = new SqlCommand(qry, this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
colmnCol.Add(rdr.GetValue(0).ToString());
return colmnCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例12: GetConstraintList
public string[] GetConstraintList(string databaseName, string tableName)
{
this._qryExec = true;
try
{
string tblNm, usrNm;
rsDbSql.ParseSchemaAndTableName(tableName, out tblNm, out usrNm);
this.CheckConnectionReady();
StringCollection cnCol = new StringCollection();
using (SqlCommand cmd = new SqlCommand(string.Format("SELECT name FROM {0}.sys.sysobjects WHERE xtype=N'D' AND parent_obj = (SELECT so.id FROM {0}.sys.sysobjects so INNER JOIN {0}.sys.schemas su ON su.schema_id = so.uid AND su.name = '{2}' WHERE xtype=N'U' AND so.name='{1}') ORDER BY name", databaseName, tblNm, usrNm), this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
cnCol.Add(rdr.GetValue(0).ToString());
return cnCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例13: GetUserList
public string[] GetUserList(string databaseName)
{
this._qryExec = true;
try
{
StringCollection uCol = new StringCollection();
using (SqlCommand cmd = new SqlCommand(string.Format("SELECT su.name FROM {0}.sys.sysusers su WHERE su.sid IS NOT NULL ORDER BY su.name", databaseName), this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
uCol.Add(rdr.GetValue(0).ToString());
return uCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例14: GetAllFunctionList
public string[] GetAllFunctionList(string databaseName)
{
this._qryExec = true;
try
{
StringCollection fCol = new StringCollection();
foreach (string str in this.GetTableValueFunctionList(databaseName))
fCol.Add(str);
foreach (string str in this.GetScalarFunctionList(databaseName))
fCol.Add(str);
return fCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}
示例15: GetScalarFunctionList
public string[] GetScalarFunctionList(string databaseName)
{
this._qryExec = true;
try
{
this.CheckConnectionReady();
StringCollection fCol = new StringCollection();
using (SqlCommand cmd = new SqlCommand(string.Format("SELECT (su.name + '.' + so.name) as [name] FROM {0}.sys.sysobjects so INNER JOIN {0}.sys.schemas su ON su.schema_id = so.uid WHERE xtype=N'FN' ORDER BY so.name", databaseName), this.DbConnection))
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
fCol.Add(rdr.GetValue(0).ToString());
return fCol.ToArray();
}
catch
{ throw; }
finally
{
this._qryExec = false;
}
}