public async Task OnChannelUpdate(HelixChannelInfo info) { _channelState.State.LastCategoryId = info.GameId; _channelState.State.LastCategoryName = info.GameName; _channelState.State.LastLanguage = info.BroadcasterLanguage; _channelState.State.LastTitle = info.Title; await _channelState.WriteStateAsync(); if (_chatBot == null) { return; } var botContext = new ProcessorContext { ChannelId = info.BroadcasterId, ChannelName = info.BroadcasterName, Language = info.BroadcasterLanguage, CategoryId = info.GameId, }; var key = new CategoryKey { TwitchCategoryId = info.GameId, Locale = info.BroadcasterLanguage }; if (_categoriesState.State.Descriptions.TryGetValue(key, out var customDescription)) { botContext.CustomCategoryDescription = customDescription.Description; } else { botContext.CustomCategoryDescription = null; } await _chatBot.UpdateContext(botContext); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the value to convert into an instance of <see cref="CategoryKey" />.</param> /// <returns> /// an instance of <see cref="CategoryKey" />, or <c>null</c> if there is no suitable conversion. /// </returns> public static object ConvertFrom(dynamic sourceValue) { if (null == sourceValue) { return(null); } try { CategoryKey.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString()); } catch { // Unable to use JSON pattern } try { return(new CategoryKey { Name = sourceValue.Name, Description = sourceValue.Description, ApiVersion = sourceValue.ApiVersion, }); } catch { } return(null); }
internal Product( string name, string description, CategoryKey categoryId) { Id = new ProductKey(Guid.NewGuid()); Name = name; Description = description; CategoryId = categoryId; }
/// <summary> /// Returns value under specified CategoryKey in Categories collection /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public static string GetExpressionCategoryValue(CategoryKey key) { if (Categories.ContainsKey(key.ToString().ToLower())) { return(Categories[key.ToString().ToLower()]); } else { return(null); } }
/// <summary> /// Gets the expression category. /// </summary> /// <param name="key">The key.</param> /// <returns></returns> public static KeyValuePair <string, string> GetExpressionCategory(CategoryKey key) { if (Categories.ContainsKey(key.ToString().ToLower())) { return(new KeyValuePair <string, string>(key.ToString().ToLower(), Categories[key.ToString().ToLower()])); } else { return(new KeyValuePair <string, string>(String.Empty, String.Empty)); } }
public Task <CustomCategoryDescription> GetCustomizedCategoryDescription(string twitchCategory, string locale) { var key = new CategoryKey { TwitchCategoryId = twitchCategory, Locale = locale }; if (_categoriesState.State.Descriptions.TryGetValue(key, out var categoryDescription)) { return(Task.FromResult(categoryDescription)); } return(Task.FromResult <CustomCategoryDescription>(null)); }
public Product Create( string name, string description, CategoryKey categoryId) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } if (categoryId is null) { throw new ArgumentNullException(nameof(categoryId)); } return(new Product(name, description, categoryId)); }
public async Task ClearCustomizedCategoryDescription(string twitchCategory, string locale) { var key = new CategoryKey { TwitchCategoryId = twitchCategory, Locale = locale }; if (_categoriesState.State.Descriptions.TryGetValue(key, out var category)) { _categoriesState.State.Descriptions.Remove(key); } await _categoriesState.WriteStateAsync(); if (twitchCategory == _channelInfo.GameId && locale == _channelInfo.BroadcasterLanguage) { await OnChannelUpdate(_channelInfo); } }
public bool Equals(CategoryKey y) { if (y == null) { return(false); } if (Category != null && y.Category != null) { return(Category.Id == y.Category.Id); } if ((StoresIds.Any() || y.StoresIds.Any()) && (StoresIds.All(id => !y.StoresIds.Contains(id)) || y.StoresIds.All(id => !StoresIds.Contains(id)))) { return(false); } return(Key.Equals(y.Key)); }
public async Task SetCustomizedCategoryDescription(CustomCategoryDescription categoryDescription) { var key = new CategoryKey { TwitchCategoryId = categoryDescription.TwitchCategoryId, Locale = categoryDescription.Locale }; if (_categoriesState.State.Descriptions.TryGetValue(key, out var category)) { category.Description = categoryDescription.Description; } else { category = categoryDescription; _categoriesState.State.Descriptions.Add(key, category); } await _categoriesState.WriteStateAsync(); if (categoryDescription.TwitchCategoryId == _channelInfo.GameId && categoryDescription.Locale == _channelInfo.BroadcasterLanguage) { await OnChannelUpdate(_channelInfo); } }
public ProductsByCategorySpecification(CategoryKey categoryId) : base(p => p.CategoryId == categoryId) { }
public PatternImage GetImage(PatternImageSize size) { Contract.Ensures(Contract.Result <PatternImage>() != null); return(PatternImage.Create(DesignerKey.ToString(), CategoryKey.ToString(), Reference, Variant, size)); }
public ProductsByCategoryPagingSpecification(CategoryKey categoryId, int pageIndex, int pageSize) : base(product => product.CategoryId == categoryId, pageIndex, pageSize) { }