protected override void Search <TSimulationObject>(SearchTargetType type) { if (!Ground.CheckTheEnd(X, Y, Radius, Radius) || !Ground.CheckTheEnd(X, Y, -Radius, -Radius)) { return; } for (var x = X - Radius; x < X + Radius; x++) { for (var y = Y - Radius; y < Y + Radius; y++) { if (!Ground.Field[x, y].Objects.Any()) { continue; } foreach (var i in Ground.Field[x, y].Objects) { switch (type) { case SearchTargetType.Couple: if (i is TSimulationObject) { var aim = i as Human; if (aim != null && GenderThis != aim.GenderThis) { Couple = aim; aim.Couple = this; return; } } break; case SearchTargetType.Food: if (i is TSimulationObject && i != this) { AimFood = i as Creature; return; } break; case SearchTargetType.House: if (i is TSimulationObject) { NeighboringHouse = i as House; return; } break; } } } } }
public static string ToQueryString(SearchTargetType targets) { return(targets switch { SearchTargetType.Title => "title", SearchTargetType.Tags => "tags", SearchTargetType.Description => "description", SearchTargetType.Title | SearchTargetType.Tags => "title,tags", SearchTargetType.Title | SearchTargetType.Description => "title,description", SearchTargetType.Tags | SearchTargetType.Description => "tags,description", SearchTargetType.All => "title,description,tags", _ => "title,description,tags" });
public Task <Live.LiveSearchResponse> LiveSearchAsync( string q, int offset, int limit, SearchTargetType targets = SearchTargetType.All, LiveSearchFieldType fields = LiveSearchFieldType.All, LiveSearchSortType sortType = LiveSearchSortType.StartTime | LiveSearchSortType.SortDecsending, ISearchFilter searchFilter = null ) { return(Live.LiveSearchClient.GetLiveSearchAsync(_context, q, offset, limit, targets, fields, sortType, searchFilter )); }
/// <summary> /// 生放送情報の検索結果を取得します。 /// </summary> /// <param name="q">検索キーワード</param> /// <param name="offset">返ってくるコンテンツの取得オフセット。最大:1600</param> /// <param name="limit">返ってくるコンテンツの最大数。最大:100</param> /// <param name="targets">検索対象のフィールド</param> /// <param name="fields">レスポンスに含みたいヒットしたコンテンツのフィールド</param> /// <param name="sortType">ソート順(デフォルトは降順/Decsending)。昇順指定する場合は LiveSearchSortType.SortAcsending を | で繋いで指定します。</param> /// <param name="filterExpression">検索結果をフィルタの条件にマッチするコンテンツだけに絞ります。</param> /// <see cref="https://site.nicovideo.jp/search-api-docs/search.html"/> public Task <Live.LiveSearchResponse> LiveSearchAsync( string q, int offset, int limit, SearchTargetType targets = SearchTargetType.All, LiveSearchFieldType fields = LiveSearchFieldType.All, LiveSearchSortType sortType = LiveSearchSortType.StartTime | LiveSearchSortType.SortDecsending, Expression <Func <SearchFilterField, bool> > filterExpression = null ) { return(Live.LiveSearchClient.GetLiveSearchAsync(_context, q, offset, limit, targets, fields, sortType, filterExpression )); }
public static Task <LiveSearchResponse> GetLiveSearchAsync( NiconicoContext context, string q, int offset, int limit, SearchTargetType targets = SearchTargetType.All, LiveSearchFieldType fields = LiveSearchFieldType.ContentId, LiveSearchSortType sortType = LiveSearchSortType.StartTime | LiveSearchSortType.SortDecsending, Expression <Func <SearchFilterField, bool> > filterExpression = null ) { return(GetLiveSearchAsync( context, q, offset, limit, targets, fields, sortType, searchFilter: filterExpression != null ? new ExpressionSearchFilter(filterExpression) : default(ISearchFilter) )); }
public static async Task <LiveSearchResponse> GetLiveSearchAsync( NiconicoContext context, string q, int offset, int limit, SearchTargetType targets = SearchTargetType.All, LiveSearchFieldType fields = LiveSearchFieldType.ContentId, LiveSearchSortType sortType = LiveSearchSortType.StartTime | LiveSearchSortType.SortDecsending, ISearchFilter searchFilter = null ) { if (string.IsNullOrWhiteSpace(q)) { throw new ArgumentException("q value must contains any character."); } if (offset < 0 || offset >= SearchConstants.MaxSearchOffset) { throw new ArgumentException("offset value out of bounds. (0 <= offset <= 1600)"); } if (limit < 0 || limit >= SearchConstants.MaxSearchLimit) { throw new ArgumentException("limit value out of bounds. (0 <= limit <= 100)"); } var dict = new Dictionary <string, string>() { { SearchConstants.QuaryParameter, q }, { SearchConstants.OffsetParameter, offset.ToString() }, { SearchConstants.LimitParameter, limit.ToString() }, { SearchConstants.TargetsParameter, SearchHelpers.ToQueryString(targets) }, }; if (context.AdditionalUserAgent != null) { dict.Add(SearchConstants.ContextParameter, context.AdditionalUserAgent); } if (fields != LiveSearchFieldType.None) { dict.Add(SearchConstants.FieldsParameter, SearchHelpers.ToQueryString(fields)); } if (sortType != LiveSearchSortType.None) { dict.Add(SearchConstants.SortParameter, SearchHelpers.ToQueryString(sortType)); } if (searchFilter != null) { var filters = searchFilter.GetFilterKeyValues(); foreach (var f in filters) { dict.Add(f.Key, f.Value); } } var json = await context.GetStringAsync(SearchConstants.LiveSearchEndPoint, dict); return(JsonSerializerExtensions.Load <LiveSearchResponse>(json)); }
public Task<SearchRepositoryResult> FindRepositories(string filter, string organization, SearchTargetType targetType = SearchTargetType.Name, int pageSize = 100) { return this.GetAsync<SearchRepositoryResult>(string.Format("/search/repositories?q={0}+fork:true+user:{1}+in:{2}&per_page={3}", filter, organization, targetType, pageSize)); }