本文整理汇总了C#中IDictionary.Any方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.Any方法的具体用法?C# IDictionary.Any怎么用?C# IDictionary.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.Any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommandContext
public CommandContext(IDictionary<string, IEnumerable<string>> propertyErrors, IEnumerable<string> operationErrors)
{
PropertyErrors = propertyErrors;
OperationErrors = operationErrors;
IsValid = !(operationErrors.Any() || propertyErrors.Any(t => t.Value.Any()));
}
示例2: Send
public async Task<HttpResponseMessage> Send(HttpMethod method, Uri uri, IDictionary<string, string> requestHeaders, object content)
{
requestHeaders = requestHeaders ?? new Dictionary<string, string>() { };
var httpRequestMessage = new HttpRequestMessage(method, uri)
{
Content = GetContent(content, requestHeaders),
};
foreach (var header in DefaultRequestHeaders)
{
if (requestHeaders.Any(x => x.Key == header.Key))
requestHeaders.Remove(header.Key);
requestHeaders.Add(header.Key, header.Value);
}
foreach (var header in requestHeaders)
{
if (httpRequestMessage.Headers.Contains(header.Key))
httpRequestMessage.Headers.Remove(header.Key);
httpRequestMessage.Headers.Add(header.Key, header.Value);
}
return await _httpClient.SendAsync(httpRequestMessage);
}
示例3: Generate
protected string Generate(IDictionary<int, string> divisibleByLabels, int start, int end)
{
if (end <= start)
throw new ArgumentException("Invalid start and end values. Start must less than end");
if (null != divisibleByLabels && divisibleByLabels.Any(x => x.Key == 0))
throw new ArgumentException("Cannot have a zero divisible by", "divisibleByLabels");
var returnValue = new StringBuilder();
for (int i = start; i <= end; i++)
{
var line = string.Empty;
if (null != divisibleByLabels)
{
foreach (var label in divisibleByLabels)
{
if (i%label.Key == 0)
line += label.Value;
}
}
if (string.IsNullOrEmpty(line))
line = i.ToString(CultureInfo.InvariantCulture);
returnValue.AppendLine(line);
}
return returnValue.ToString();
}
示例4: OnNavigatedToAsync
/// <summary>
///
/// </summary>
/// <param name="parameter">FortData containing the Pokestop that we're visiting</param>
/// <param name="mode"></param>
/// <param name="suspensionState"></param>
/// <returns></returns>
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode,
IDictionary<string, object> suspensionState)
{
if (suspensionState.Any())
{
// Recovering the state
CurrentPokestop = (FortDataWrapper) suspensionState[nameof(CurrentPokestop)];
CurrentPokestopInfo = (FortDetailsResponse) suspensionState[nameof(CurrentPokestopInfo)];
CurrentSearchResponse = (FortSearchResponse) suspensionState[nameof(CurrentSearchResponse)];
}
else if (parameter is bool)
{
// Navigating from game page, so we need to actually load the Pokestop
Busy.SetBusy(true, "Loading Pokestop");
CurrentPokestop = (FortDataWrapper)NavigationHelper.NavigationState[nameof(CurrentPokestop)];
NavigationHelper.NavigationState.Remove(nameof(CurrentPokestop));
Logger.Write($"Searching {CurrentPokestop.Id}");
CurrentPokestopInfo = await GameClient.GetFort(CurrentPokestop.Id, CurrentPokestop.Latitude, CurrentPokestop.Longitude);
Busy.SetBusy(false);
// If timeout is expired we can go to to pokestop page
if (CurrentPokestop.CooldownCompleteTimestampMs >= DateTime.UtcNow.ToUnixTime())
{
// Timeout is not expired yet, player can't get items from the fort
SearchInCooldown?.Invoke(null, null);
}
}
await Task.CompletedTask;
}
示例5: OnNavigatedToAsync
public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> state) {
if (state.Any()) {
Value = state[nameof(Value)]?.ToString();
state.Clear();
}
return Task.CompletedTask;
}
示例6: GetBdmtTitles
private static string GetBdmtTitles(IDictionary<Language, string> bdmtTitles)
{
return !bdmtTitles.Any()
? null
: string.Join(Environment.NewLine,
bdmtTitles.Select(pair => string.Format("{0}: {1}", pair.Key.ISO_639_2, pair.Value)));
}
示例7: OnNavigatedToAsync
public async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> state)
{
if (state.Any())
{
Sub = JsonConvert.DeserializeObject<SubredditItem>((string)state["sub"]);
Images = IncrementalSubredditGallery.fromJson((string)state["images"]);
state.Clear();
}
else
{
if (mode == NavigationMode.Back)
{
if (galleryMetaInfo == null)
{
galleryMetaInfo = BootStrapper.Current.SessionState["GalleryInfo"] as GalleryMetaInfo;
Images = galleryMetaInfo?.Gallery as IncrementalSubredditGallery;
var sub = (await Reddits.SearchSubreddits(Images.Subreddit)).First(s => s.Data.DisplayName == Images.Subreddit);
Sub = new SubredditItem(sub);
}
ImageSelectedIndex = galleryMetaInfo?.SelectedIndex ?? 0;
}
else
{
Activate(parameter);
}
}
await Task.CompletedTask;
}
示例8: ClearColumnsExcept
/// <summary>
/// Clears all columns from the parts list, except the ones that appear in a specified collection.
/// </summary>
/// <param name="partsList">The <see cref="PartsList"/> instance that this extension method affects.</param>
/// <param name="columnIdsToKeep">A dictionary of IDs of <see cref="PropertyTypeEnum.kFileProperty"/> columns
/// that shouldn't be removed.</param>
/// <param name="propertyTypesToKeep"></param>
/// <exception cref="ArgumentNullException"><paramref name="partsList"/> is <c>null</c>.</exception>
public static void ClearColumnsExcept(
this PartsList partsList,
IDictionary<string, int> columnIdsToKeep,
params PropertyTypeEnum[] propertyTypesToKeep
)
{
if (partsList == null)
throw new ArgumentNullException(nameof(partsList));
foreach (PartsListColumn column in partsList.PartsListColumns)
{
if (column.PropertyType == PropertyTypeEnum.kFileProperty)
{
var filePropertyId = column.GetFilePropertyId();
if (columnIdsToKeep != null &&
columnIdsToKeep.Any(x => x.Key == filePropertyId.Key && x.Value == filePropertyId.Value))
continue;
}
else if (propertyTypesToKeep != null && propertyTypesToKeep.Contains(column.PropertyType))
continue;
column.Remove();
}
}
示例9: ParseContentHeaders
private Tuple<string, Encoding> ParseContentHeaders(IDictionary<string, string> headers)
{
string contentType = null;
Encoding encoding = null;
if (headers != null && headers.Any())
{
foreach (var header in headers)
{
if (header.Key.Equals("Content-Type", StringComparison.InvariantCultureIgnoreCase))
{
var contentTypeHeaderSplit = header.Value.Split(';');
contentType = contentTypeHeaderSplit.First().Trim().ToLower();
var encodingString = contentTypeHeaderSplit.FirstOrDefault(x => x.Contains("charset="));
if (!String.IsNullOrEmpty(encodingString))
{
encodingString = encodingString.Trim().Replace("charset=", "").ToLower();
encoding = _encodingMapper.Convert(encodingString);
}
break;
}
}
}
return new Tuple<string, Encoding>(contentType, encoding);
}
示例10: OnNavigatedToAsync
/// <summary>
///
/// </summary>
/// <param name="parameter">MapPokemonWrapper containing the Pokemon that we're trying to capture</param>
/// <param name="mode"></param>
/// <param name="suspensionState"></param>
/// <returns></returns>
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode,
IDictionary<string, object> suspensionState)
{
if (suspensionState.Any())
{
// Recovering the state
CurrentPokemon = (MapPokemonWrapper) suspensionState[nameof(CurrentPokemon)];
CurrentEncounter = (EncounterResponse) suspensionState[nameof(CurrentEncounter)];
CurrentCaptureAward = (CaptureAward) suspensionState[nameof(CurrentCaptureAward)];
SelectedCaptureItem = (ItemData) suspensionState[nameof(SelectedCaptureItem)];
} else if (parameter is bool)
{
// Navigating from game page, so we need to actually load the encounter
CurrentPokemon = (MapPokemonWrapper) NavigationHelper.NavigationState[nameof(CurrentPokemon)];
Busy.SetBusy(true, Utils.Resources.Translation.GetString("LoadingEncounter") + Utils.Resources.Pokemon.GetString(CurrentPokemon.PokemonId.ToString()));
NavigationHelper.NavigationState.Remove(nameof(CurrentPokemon));
Logger.Write($"Catching {CurrentPokemon.PokemonId}");
CurrentEncounter = await GameClient.EncounterPokemon(CurrentPokemon.EncounterId, CurrentPokemon.SpawnpointId);
SelectedCaptureItem = ItemsInventory.First(item => item.ItemId == ItemId.ItemPokeBall);
Busy.SetBusy(false);
if (CurrentEncounter.Status != EncounterResponse.Types.Status.EncounterSuccess)
{
// Encounter failed, probably the Pokemon ran away
await new MessageDialog(Utils.Resources.Translation.GetString("PokemonRanAway")).ShowAsyncQueue();
ReturnToGameScreen.Execute();
}
}
await Task.CompletedTask;
}
示例11: Filter
public virtual bool Filter(IDictionary<string, dynamic> data)
{
if (!data.Any(prop => prop.Key == Key && prop.Value.ToString() == Value.Trim('\'')))
return false;
return true;
}
示例12: GetParameters
private string GetParameters(IDictionary<string, object> param)
{
var result = param.Any()
? "Params: [" + string.Join(";", param.Keys.Select(key => key + ": " + param[key])) + "]"
: "No params";
return result;
}
示例13: SaveTempData
protected virtual void SaveTempData(ControllerContext controllerContext, IDictionary<string, object> values)
{
if (!values.Any())
{
var cookied = new HttpCookie(TempDataCookieKey)
{
Expires = DateTime.Now.AddDays(-30),
Path = controllerContext.HttpContext.Request.ApplicationPath,
Secure = controllerContext.HttpContext.Request.IsSecureConnection
};
_httpContext.Response.Cookies.Add(cookied);
return;
}
var cookieValue = SerializeToBase64EncodedString(values);
var cookie = new HttpCookie(TempDataCookieKey)
{
HttpOnly = true,
Value = cookieValue,
Path = controllerContext.HttpContext.Request.ApplicationPath,
Secure = controllerContext.HttpContext.Request.IsSecureConnection
};
_httpContext.Response.Cookies.Add(cookie);
}
示例14: OnNavigatedToAsync
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary<string, object> suspensionState)
{
if (suspensionState.Any())
{
Value = suspensionState[nameof(Value)]?.ToString();
}
await Task.CompletedTask;
}
示例15: StempelPolishStemFilterFactory
/// <summary>
/// Creates a new <see cref="StempelPolishStemFilterFactory"/>
/// </summary>
public StempelPolishStemFilterFactory(IDictionary<string, string> args)
: base(args)
{
if (args.Any())
{
throw new ArgumentException("Unknown parameters: " + args);
}
}