本文整理汇总了C#中IReadOnlyDictionary.Any方法的典型用法代码示例。如果您正苦于以下问题:C# IReadOnlyDictionary.Any方法的具体用法?C# IReadOnlyDictionary.Any怎么用?C# IReadOnlyDictionary.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReadOnlyDictionary
的用法示例。
在下文中一共展示了IReadOnlyDictionary.Any方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetItemsToCleanupInternal
/// <summary>
/// Returns items that can be cleaned up.
/// </summary>
/// <param name="items">
/// Available items for cleanup. Each dictionary item represents an image with specific key (uri). The value of the dictionary item is a list of concrete instances
/// of the image ordered by image size, from smallest to largest.
/// </param>
/// <param name="itemSizeEvaluator">
/// The evaluator to use for calculation a size of the item in cache. The bigger this number, the heavier item in a cache, the less such items we
/// need to remove to free desired space.
/// </param>
/// <param name="sizeToFree">
/// The total size to free.
/// </param>
/// <returns>
/// The list of items that can be cleaned up.
/// </returns>
protected override IEnumerable<CacheImageLoader.CacheItem> GetItemsToCleanupInternal(IReadOnlyDictionary<string, List<CacheImageLoader.CacheItem>> items, Func<CacheImageLoader.CacheItem, ulong> itemSizeEvaluator, ulong sizeToFree)
{
var itemsToDelete = new List<CacheImageLoader.CacheItem>();
if (items.Any())
{
var itemsGroupedByKeys = items.Values;
var releasedSize = (ulong)0;
var maxGroupSize = itemsGroupedByKeys.Max(v => v.Count);
var currentSize = maxGroupSize;
while (currentSize > 0 && releasedSize < sizeToFree)
{
foreach (var item in from groupedItems in itemsGroupedByKeys
where groupedItems.Count >= currentSize
select groupedItems[groupedItems.Count - currentSize])
{
itemsToDelete.Add(item);
releasedSize += itemSizeEvaluator(item);
if (releasedSize >= sizeToFree)
{
break;
}
}
currentSize--;
}
}
return itemsToDelete;
}
示例2: IsMicrosoftHal
/// <summary>
/// Determine if this device represents a Microsoft-provided HAL.
/// </summary>
/// <param name="properties"></param>
/// <returns></returns>
private static bool IsMicrosoftHal(IReadOnlyDictionary<string, object> properties)
{
return
properties.Any(p => p.Value.ToString().Equals(HalDeviceClass) && p.Key.Equals(DeviceClassKey.Replace(',', ' '))) &&
properties.Any(p => p.Key.Equals(DeviceDriverProviderKey.Replace(',', ' ')) && p.Value.Equals("Microsoft"));
}
示例3: 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;
}
}
}