protected TagInputModelBase(ITagIndex tagIndex) { _tagIndex = tagIndex; PinCurrentInputCommand = new DelegateCommand(CanPinCurrentInput, PinCurrentInput); CurrentInput.ValueChanged += UpdateAutoCompleteSuggestions; }
void Reset(ITagIndex owner, BlamVersion version) { if (owner != null) { ownerId = owner.IndexId; flags.Add(owner is CacheTagIndex, IO.ITagStreamFlags.ResidesInCacheFile); } tagIndex = Blam.DatumIndex.Null; headerGroupTag = uint.MaxValue; headerVersion = -1; headerSignature = uint.MaxValue; tagGroupAttr = null; tagGroup = null; tagDefinition = null; Close(); engine = version; DetermineEndianState(InCache); }
/// <summary> /// Construct a tag manager which is an instance owned by the specified tag index /// </summary> /// <param name="owner">Index this tag belongs to</param> internal TagManager(ITagIndex owner) { Reset(owner, owner.Engine); }
/// <summary> /// Resets a tag manager based on a tag index and a /// endian state for the internal tag I\O streams /// </summary> /// <param name="owner">Index this tag belong to</param> /// <param name="endian_state">The endian format of the tag file</param> /// <remarks>Generally used for creating\writing</remarks> void Reset(ITagIndex owner, IO.EndianState endian_state) { Reset(owner); this.endianState = endian_state; }
/// <summary> /// Resets a tag manager based on a tag index and a file path /// </summary> /// <param name="owner">Index this tag belong to</param> /// <remarks>Generally used for creating\writing</remarks> void Reset(ITagIndex owner) { Reset(owner, owner.Engine); }
private async Task <EmbedBuilder> SearchAsync(string searchTerm, CATEGORY category, ITagIndex tagIndex, int postIndex = 0, ROLL_SEQUENCE rollSequence = ROLL_SEQUENCE.RANDOM) { if (string.IsNullOrEmpty(searchTerm)) { string usageString = "Usage: "; switch (category) { case CATEGORY.CHARACTER: await ReplyAsync(usageString + "oka.character character_name"); break; case CATEGORY.SERIES: await ReplyAsync(usageString + "oka.series series_name"); break; } return(null); } if (!_pageService.HandlerAdded) { Context.Client.ReactionAdded += ReactionAdded_Event; _pageService.HandlerAdded = true; } searchTerm = TagParser.Format(searchTerm); string tag; string searchTermEscaped; string searchTermMatched; int id; PostData postData = null; List <string> tags; List <TagData> tagData; EmbedBuilder embed; List <EmbedFieldBuilder> fields = new List <EmbedFieldBuilder>(); string embedDescription = rerollCharacterDescription + ", " + rerollSeriesDescription + ". " + Environment.NewLine + listCharactersDescription + "."; using (MySqlConnection conn = tagIndex.GetConnection()) { if (int.TryParse(searchTerm, out id)) { tag = tagIndex.LookupTagById(id, conn); if (!string.IsNullOrEmpty(tag)) { searchTerm = tag; } } searchTermEscaped = TagParser.EscapeUnderscore(searchTerm); if (tagIndex.HasExactMatch(searchTerm, conn, out searchTermMatched)) { switch (rollSequence) { case ROLL_SEQUENCE.RANDOM: postData = tagIndex.LookupRandomPost(searchTermMatched, conn); break; case ROLL_SEQUENCE.PREVIOUS: postData = tagIndex.LookupPreviousPost(searchTermMatched, postIndex, conn); break; case ROLL_SEQUENCE.NEXT: postData = tagIndex.LookupNextPost(searchTermMatched, postIndex, conn); break; } switch (category) { case CATEGORY.CHARACTER: embedDescription += Environment.NewLine + cycleCharacterPageDescription + "."; break; } if (postData != null && !string.IsNullOrEmpty(postData.Link)) { embed = BuildImageEmbed(postData, embedDescription); } else { await ReplyAsync(NoImages.Replace("%", searchTermEscaped)); return(null); } } else { embed = new EmbedBuilder(); tags = tagIndex.LookupTags(searchTerm, conn); if (tags.Count > 0) { if (tags.Count > MaxSearchResults) { await ReplyAsync(ExcessiveResults.Replace("%", searchTerm)); return(null); } tagData = tagIndex.LookupTagData(tags, conn); pages = TagParser.CompileSuggestions(tagData, EmbedBuilder.MaxFieldCount); embed = BuildSuggestionsEmbed(pages); } else { await ReplyAsync(NoResults.Replace("%", searchTermEscaped)); return(null); } } return(embed); } }
public SearchModel(ITagIndex tagIndex, IMessageRelay relay) : base(tagIndex) { _relay = relay; }