本文整理汇总了C#中System.Collections.Generic.System.Collections.Generic.Dictionary.ContainsValue方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.Dictionary.ContainsValue方法的具体用法?C# System.Collections.Generic.Dictionary.ContainsValue怎么用?C# System.Collections.Generic.Dictionary.ContainsValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic.System.Collections.Generic.Dictionary
的用法示例。
在下文中一共展示了System.Collections.Generic.Dictionary.ContainsValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportTextToDataTableUsingKeys
//.........这里部分代码省略.........
//{
// ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, uniqueKeyColumnFriendlyNames);
//}
string[] argsArray = new string[100];
argsArray[0] = GetFriendlyFieldName(destinationTable.PrimaryKey[0], destinationTable.PrimaryKey[0].ColumnName);
argsArray[1] = uniqueKeyColumnFriendlyNames;
ggMessageBox.MessageText = string.Format(ggMessageBox.MessageText, argsArray);
// Ask the user if they wish to perform a 'block paste' of the data...
if (DialogResult.Yes == ggMessageBox.ShowDialog())
{
return false;
}
else
{
return true;
}
}
// Since we made it here, it looks like we found a row in the import text that contains the column names for the destination tables primary/unique key...
string[] importColumnNames = rawImportRows[columnHeaderRowIndex].Split(columnDelimiters, StringSplitOptions.None);
System.Collections.Generic.Dictionary<string, int> columnNameMap = new System.Collections.Generic.Dictionary<string, int>();
// So now we need to build a map of datatable columns in import text columns (because they may not be in the same order)...
for (int i = 0; i < importColumnNames.Length; i++)
{
// Map the friendly field name from the incoming text to the matching column in the datatable (case sensitive)...
foreach (DataColumn dc in destinationTable.Columns)
{
if (GetFriendlyFieldName(dc, dc.ColumnName) == importColumnNames[i])
{
columnNameMap.Add(dc.ColumnName, i);
}
}
// If the column header was not matched - try matching again (case insensitive)...
if (!columnNameMap.ContainsValue(i))
{
// Map the friendly field name from the incoming text to the matching column in the datatable (case insensitive)...
foreach (DataColumn dc in destinationTable.Columns)
{
if (GetFriendlyFieldName(dc, dc.ColumnName).ToLower() == importColumnNames[i].ToLower())
{
columnNameMap.Add(dc.ColumnName, i);
}
}
}
// If the column header was still not matched - try the raw table field name...
if (!columnNameMap.ContainsValue(i))
{
// Map the friendly field name from the incoming text to the matching column in the datatable (case insensitive)...
foreach (DataColumn dc in destinationTable.Columns)
{
if (dc.ColumnName.ToLower() == importColumnNames[i].ToLower())
{
columnNameMap.Add(dc.ColumnName, i);
}
}
}
}
// Now that we have the column map, start processing the rows (starting with the one right after the column header row)...
for (int i = columnHeaderRowIndex + 1; i < rawImportRows.Length; i++)
{
DataRow dr = null;
string[] rawFieldData = rawImportRows[i].Split(columnDelimiters, StringSplitOptions.None);
if (primaryKeyFound)
{
System.Collections.Generic.List<object> rowKeys = new System.Collections.Generic.List<object>();