本文整理汇总了C#中IReadOnlyDictionary.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyDictionary.Select方法的具体用法?C# IReadOnlyDictionary.Select怎么用?C# IReadOnlyDictionary.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyDictionary
的用法示例。
在下文中一共展示了IReadOnlyDictionary.Select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTableIfNotExists
internal static string CreateTableIfNotExists(string tableName, CreateFlags createFlags, IReadOnlyDictionary<string, ColumnMapping> columns)
{
bool fts3 = (createFlags & CreateFlags.FullTextSearch3) != 0;
bool fts4 = (createFlags & CreateFlags.FullTextSearch4) != 0;
bool fts = fts3 || fts4;
var @virtual = fts ? "VIRTUAL " : string.Empty;
var @using = fts3 ? "USING FTS3 " : fts4 ? "USING FTS4 " : string.Empty;
// Build query.
var query = "CREATE " + @virtual + "TABLE IF NOT EXISTS \"" + tableName + "\" " + @using + "(\n";
var decls = columns.Select(c => SQLBuilder.SqlDecl(c.Key, c.Value));
var decl = string.Join(",\n", decls.ToArray());
query += decl;
var fkconstraints =
string.Join(
",\n",
columns.Where(x => x.Value.ForeignKeyConstraint != null).Select(x =>
string.Format("FOREIGN KEY(\"{0}\") REFERENCES \"{1}\"(\"{2}\")",
x.Key,
x.Value.ForeignKeyConstraint.TableName,
x.Value.ForeignKeyConstraint.ColumnName)));
query += (fkconstraints.Length != 0) ? "," + fkconstraints : "";
query += ")";
return query;
}
示例2: GetPkiTool
public IPkiTool GetPkiTool(IReadOnlyDictionary<string, object> initParams)
{
var kvPairs = initParams.Select(_ =>
new KeyValuePair<string, string>(_.Key, _.Value.ToString()));
var newParams = kvPairs.ToDictionary(
_ => _.Key,
_ => _.Value);
return new BCPkiTool(newParams);
}
示例3: GetSwitchMappings
static public Dictionary<string,string> GetSwitchMappings(
IReadOnlyDictionary<string, string> configurationStrings)
{
return configurationStrings.Select(item =>
new KeyValuePair<string, string>(
"-" + item.Key.Substring(item.Key.LastIndexOf(':')+1),
item.Key))
.ToDictionary(
item => item.Key, item=>item.Value);
}
示例4: AsRelativeUri
public static Uri AsRelativeUri(this string @this, PagingOptions paging,
IEnumerable<AppIdentifier> context = null, IReadOnlyDictionary<string, string> extraParameters = null)
{
var parameters = new List<string>();
if (paging.From.HasValue)
parameters.Add($"_from={WebUtility.UrlEncode(paging.From.ToString())}");
if (paging.To.HasValue)
parameters.Add($"_to={WebUtility.UrlEncode(paging.To.ToString())}");
if (context != null)
parameters.Add("context=" + string.Join("/", context));
if (extraParameters != null)
parameters.AddRange(extraParameters.Select(
p => $"{WebUtility.UrlEncode(p.Key)}={WebUtility.UrlEncode(p.Value)}"));
return AsRelativeUri(@this, parameters);
}
示例5: Handle
public IEnumerable<StageResult> Handle(IReadOnlyDictionary<Guid, List<IAggregatableMessage>> processingResultsMap)
{
return processingResultsMap.Select(pair => Handle(pair.Key, pair.Value));
}
示例6: Query
public async Task<IRow[]> Query(IReadOnlyDictionary<string, string> columns)
{
if (null == columns)
{
throw new ArgumentNullException(CommaDelimitedFileAdapter.ArgumentNameColumns);
}
string query =
string.Format(
CultureInfo.InvariantCulture,
CommaDelimitedFileAdapter.QueryTemplate,
this.fileName);
if (columns.Any())
{
IReadOnlyCollection<string> filters =
columns
.Select(
(KeyValuePair<string, string> item) =>
string.Format(
CultureInfo.InvariantCulture,
CommaDelimitedFileAdapter.FilterTemplate,
item.Key,
item.Value))
.ToArray();
string filter =
string.Join(CommaDelimitedFileAdapter.DelimiterFilter, filters);
query = string.Concat(query, CommaDelimitedFileAdapter.WhereClausePrefix, filter);
}
OleDbCommand commandQuery = null;
try
{
commandQuery = new OleDbCommand(query, connection);
DbDataReader reader = null;
try
{
reader = await commandQuery.ExecuteReaderAsync();
IList<IRow> rows = new List<IRow>();
while (reader.Read())
{
string rowKey = (string)reader[0];
Dictionary<string, string> rowColumns =
new Dictionary<string, string>(this.headers.Count - 1);
for (int indexColumn = 1; indexColumn < this.headers.Count; indexColumn++)
{
string columnValue = reader[indexColumn] as string;
if (string.IsNullOrWhiteSpace(columnValue))
{
continue;
}
string columnHeader = this.headers.ElementAt(indexColumn);
rowColumns.Add(columnHeader, columnValue);
}
IRow row = new Row(rowKey, rowColumns);
rows.Add(row);
}
IRow[] results = rows.ToArray();
return results;
}
finally
{
if (reader != null)
{
reader.Close();
reader = null;
}
}
}
finally
{
if (commandQuery != null)
{
commandQuery.Dispose();
commandQuery = null;
}
}
}
示例7: GetReplacedDefinitions
public static IReadOnlyCollection<ReplacementInfo> GetReplacedDefinitions(IReadOnlyDictionary<string, ITypeSymbol> sutSubstitutions, ISymbol typeSymbol)
{
var replacements = sutSubstitutions.Select(kv => new[]
{
new {Original = "<" + kv.Key + ">", Replacement = "<" + GetSimpleTypeName(kv.Value) + ">"},
new {Original = "<" + kv.Key + ",", Replacement = "<" + GetSimpleTypeName(kv.Value) + ","},
new {Original = ", " + kv.Key + ",", Replacement = ", " + GetSimpleTypeName(kv.Value) + ","},
new {Original = ", " + kv.Key + ">", Replacement = ", " + GetSimpleTypeName(kv.Value) + ">"}
});
var originalType = GetSimpleTypeName(typeSymbol);
var replacedDefinition = replacements.Select(s => s.Aggregate(originalType, (sum, repl) => sum.Replace(repl.Original, repl.Replacement)))
.Select(x => new ReplacementInfo { IsReplaced = x != originalType, Result = x})
.ToArray();
return replacedDefinition;
}