本文整理汇总了C#中SearchResult类的典型用法代码示例。如果您正苦于以下问题:C# SearchResult类的具体用法?C# SearchResult怎么用?C# SearchResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SearchResult类属于命名空间,在下文中一共展示了SearchResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Search
public List<SearchResult> Search(string searchQuery)
{
string url = "http://www.imdb.com/find?q={0}&s=all".Fmt(searchQuery);
string html = new WebClient().DownloadString(url);
CQ dom = html;
var searchResults = new List<SearchResult>();
foreach (var fragment in dom.Select("table.findList tr.findResult"))
{
var searchResult = new SearchResult();
searchResult.ImageUrl = fragment.Cq().Find(".primary_photo > a > img").Attr("src");
searchResult.Text = fragment.Cq().Find(".result_text").Html();
searchResult.Text = StringEx.RemoveHtmlTags(searchResult.Text);
string filmUrl = fragment.Cq().Find(".result_text > a").Attr("href");
filmUrl = filmUrl.Replace("/title/", "");
searchResult.FilmId = filmUrl.Substring(0, filmUrl.IndexOf("/"));
searchResults.Add(searchResult);
}
return searchResults;
}
开发者ID:jivkopetiov,项目名称:ImdbForums,代码行数:26,代码来源:ImdbScraper.cs
示例2: NetSuiteSearch
public NetSuiteSearch(SearchResult results)
{
this.Id = results.searchId;
this.LastPage = results.pageIndex;
this.records = this.getSearchResults(results);
this.needsMore = results.pageIndex != results.totalPages;
}
开发者ID:Parsimotion,项目名称:restsuite,代码行数:7,代码来源:NetSuiteSearch.cs
示例3: Caching_search_with_apikey_does_not_pass_auth_info_to_lucene
public void Caching_search_with_apikey_does_not_pass_auth_info_to_lucene() {
var searchMock = CreateMocks().Item1;
var responseXml = new XDoc("response");
var luceneXml = new XDoc("lucene");
var searchQuery = new SearchQuery("raw", "processed", new LuceneClauseBuilder(), null);
var searchResult = new SearchResult();
searchMock.Setup(x => x.BuildQuery("foo", "", SearchQueryParserType.BestGuess, true)).Returns(searchQuery).AtMostOnce().Verifiable();
searchMock.Setup(x => x.GetCachedQuery(searchQuery)).Returns((SearchResult)null).AtMostOnce().Verifiable();
XUri luceneUriCalled = null;
MockPlug.Register(Utils.Settings.LuceneMockUri, (p, v, u, req, res) => {
luceneUriCalled = u;
res.Return(DreamMessage.Ok(luceneXml));
});
searchMock.Setup(x => x.CacheQuery(It.Is<XDoc>(v => v == luceneXml), It.IsAny<SearchQuery>(), It.IsAny<TrackingInfo>()))
.Returns(searchResult);
searchMock.Setup(x => x.FormatResultSet(
searchResult,
It.IsAny<SetDiscriminator>(),
false,
It.IsAny<TrackingInfo>(),
It.IsAny<Result<XDoc>>()
))
.Returns(new Result<XDoc>().WithReturn(responseXml));
var response = _search
.With("q", "foo")
.With("apikey", Utils.Settings.ApiKey)
.Get(new Result<DreamMessage>()).Wait();
Assert.IsTrue(response.IsSuccessful, response.ToErrorString());
Assert.IsNotNull(luceneUriCalled, "lucene was not called");
Assert.AreEqual(Utils.Settings.LuceneMockUri.At("compact"), luceneUriCalled.WithoutQuery(), "lucene was called at wrong uri");
Assert.IsNull(luceneUriCalled.GetParam("apiuri"), "lucene request contained an apiuri parameter");
Assert.IsNull(luceneUriCalled.GetParam("userid"), "lucene request contained a userid parameter");
Assert.AreEqual(searchQuery.LuceneQuery, luceneUriCalled.GetParam("q"), "lucene request had incorrect q parameter");
}
开发者ID:heran,项目名称:DekiWiki,代码行数:34,代码来源:SearchTestsWithSearchBLMock.cs
示例4: BasicSearch_NonDefault_Parameters
public void BasicSearch_NonDefault_Parameters()
{
//arrange
var mockLogic = new Mock<IProjectLogic>();
var obj = new SearchResult<ProjectObj>
{
HasMore = false,
HasPrevious = true,
Results = new List<ProjectObj>()
{
new ProjectObj()
{
Id = 2
}
}
};
mockLogic.Setup(l => l.Search("query", 5, 10)).Returns(obj);
var controller = new ProjectController(mockLogic.Object);
//act
var actual = controller.BasicSearch("query", 5, 10) as ViewResult;
//assert
Assert.IsNotNull(actual);
var model = actual.Model as BasicSearchModel;
Assert.IsNotNull(model);
Assert.AreEqual(5, model.CurrentPage);
Assert.AreEqual(false, model.HasMoreResults);
Assert.AreEqual(true, model.HasPriorResults);
Assert.AreEqual("Project", model.ModelName);
Assert.AreEqual(10, model.PageSize);
Assert.AreEqual("query", model.Query);
Assert.AreEqual(1, model.Results.Count);
Assert.AreEqual(2, model.Results[0].Id);
}
开发者ID:briansalato,项目名称:InnerTrack,代码行数:35,代码来源:ProjectControllerTest.cs
示例5: Search
public async Task<SearchResult> Search(string key)
{
key = key.Trim();
var res = new SearchResult
{
Items = new List<IMusic>(),
Keyword = key,
SearchType = EnumSearchType.url,
Page = 1,
};
var url = string.Format(search_url, Uri.EscapeDataString(key));
var response = await NetAccess.DownloadStringAsync(url);
var json = response.ToDynamicObject();
if (json.song.Count > 0)
foreach (var obj in json.song)
{
var s = new Song
{
Id = "b" + MusicHelper.Get(obj, "songid"),
ArtistName = MusicHelper.Get(obj, "artistname"),
AlbumName = "",
Name = MusicHelper.Get(obj, "songname"),
WriteId3 = false,
};
res.Items.Add(s);
s.UrlMp3 =await getDownloadUrl(s.Id.Substring(1));
}
return res;
}
开发者ID:3ricguo,项目名称:xiami_downloader,代码行数:29,代码来源:BaiduSearchProvider.cs
示例6: SetAcl
private static void SetAcl(string path, SearchResult user, FileSystemRights right)
{
var userId = user.Properties["userPrincipalName"][0].ToString();
var fullUserName = user.Properties["name"][0].ToString();
var fullPath = path + fullUserName;
var dir = new DirectoryInfo(fullPath);
var ds = new DirectorySecurity();
ds.SetAccessRuleProtection(true, false);
var uacl = new FileSystemAccessRule(userId,
right,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
ds.AddAccessRule(uacl);
var domainAdmins = new SecurityIdentifier(WellKnownSidType.AccountDomainAdminsSid, AppSettings.GeneralSettings.DomainSid);
var pacl = new FileSystemAccessRule(domainAdmins,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
ds.AddAccessRule(pacl);
var system = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
var sacl = new FileSystemAccessRule(system,
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow);
ds.AddAccessRule(sacl);
dir.SetAccessControl(ds);
}
开发者ID:Kusado,项目名称:WindowsProjects,代码行数:34,代码来源:Program.cs
示例7: GetUsersAsync
public Task<SearchResult<UserListItem>> GetUsersAsync(string pagingToken = null)
{
var path = GetObjectPath() + "/items";
return Client.CallServiceMethod<SearchResult<IDictionary<string, object>>>("GET", path, new
{
token = pagingToken
}).WrapTask<BuddyResult<SearchResult<IDictionary<string,object>>>,SearchResult<UserListItem>>(t2 => {
var r = t2.Result;
var sr = new SearchResult<UserListItem>();
if (r.IsSuccess) {
sr.NextToken = r.Value.NextToken;
sr.PreviousToken = r.Value.PreviousToken;
sr.CurrentToken = r.Value.CurrentToken;
sr.PageResults = r.Value.PageResults.Select(i => new UserListItem(i));
}
else {
sr.Error = r.Error;
}
return sr;
});
}
开发者ID:nickatbuddy,项目名称:Buddy-DotNET-SDK,代码行数:26,代码来源:UserList.cs
示例8: Execute
public string Execute(TransitionContext context)
{
string retEvent = Events.Error;
try {
if (context.Request.Items[this.AccountItemNameIn] == null ||
!(context.Request.Items[this.AccountItemNameIn] is SearchResult<Account>) ||
context.Request.GetItem<SearchResult<Account>>(this.AccountItemNameIn).Items.Length != 1) {
throw new MissingFieldException("Could not retrieve an account or the more than one account was returned.");
}
Account account = context.Request.GetItem<SearchResult<Account>>(this.AccountItemNameIn).Items[0];
/* Hmm whats better... one line or 3...
context.Request.Items[this.AccountsItemNameIn] = new SearchResult<Account>( new[] { Deserialize.Populate(context.Request, accounts.Items[0]) });
*/
Account toReturn = Deserialize.Populate(context.Request, account);
SearchResult<Account> result = new SearchResult<Account>(new Account[] {toReturn});
context.Request.Items[this.AccountItemNameOut] = result;
retEvent = Events.Ok;
} catch (Exception ex) {
this.logger.Error("Error occured in Execute.", ex);
}
return retEvent;
}
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:31,代码来源:PopulateAccountFromRequestAction.cs
示例9: Execute
public string Execute(TransitionContext context)
{
string retEvent = "error";
try {
//for now this just returns all the states
List<State> states = new List<State>(DaoFactory.GetDao<IStateDao>().Get(new State{
IsTerritory = false
}));
SearchResult<State> results = new SearchResult<State>(states.ToArray());
switch (results.Items.Length) {
case 0:
retEvent = "zero";
break;
case 1:
retEvent = "one";
break;
default:
retEvent = "multiple";
break;
}
context.Request.Items[(this.RequestItemName ?? ADDRESS_STATES)] = results;
} catch (Exception ex) {
LogManager.GetLogger(typeof (GetStatesAction)).Error(
errorMessage => errorMessage("GetPropertyAction: Execute", ex));
}
return retEvent;
}
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:31,代码来源:GetStatesAction.cs
示例10: SearchKey
public SearchResult SearchKey(string key)
{
var search = new SearchResult() { Key = key };
if (!string.IsNullOrWhiteSpace(key))
{
SearchKeywordManager.Search(key); //用于统计搜索关键字的方法
IList<Duty_c> list = new List<Duty_c>();
list = BLL.Search.SearchGoods(key);
if (list.Count == 0)
{
search.Error = true;
}
else if (list.Count == 1)
{
search.Duty = list[0];
//goods_type = "<li class='one'>您输入的物品属于: " + duty.type.overname + "--->" + duty.type.midname + "--->" + duty.type.name + "</li><br/>";
//name = "<li class='one'>您输入的物品相关的品名是: " + duty.name + "</li><br/>";
//relatedwords = "<li class='one'>该品目相关的关键词: " + duty.relatedwords.ToString() + "</li><br/>";
//price = "<li class='one'>完税价格是: " + duty.price.ToString() + "元/" + duty.unit + "</li><br/>";
//rate = "<li class='one'>税率是: " + duty.rate.ToString() + "</li><br/>";
//lister = goods_type + name + relatedwords + price + rate;
}
else if (list.Count > 1)
{
search.SearchTakes = list.Select(r => r.name).ToList();
//lister = "你搜索结果大于一条,请在下列项中选择: </br>";
//for (int i = 0; i < list.Count; i++)
//{
// lister += "<a href=default.aspx?KeyWord=" + list[i].name + ">" + list[i].name + "</a> ";
//}
}
}
return search;
}
开发者ID:fengxing,项目名称:Customs_clearances,代码行数:34,代码来源:Search.ashx.cs
示例11: TestToString
public void TestToString()
{
SearchResult result1 = new SearchResult() { Index = 0, Exists = true };
Assert.AreEqual("Exists = True, Index = 0", result1.ToString(), "The wrong string representation was returned."); // implicit conversion
SearchResult result2 = new SearchResult() { Index = 1, Exists = false };
Assert.AreEqual("Exists = False, Index = 1", result2.ToString(), "The wrong string representation was returned."); // implicit conversion
}
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SearchResultTester.cs
示例12: TestIntegerConversion
public void TestIntegerConversion()
{
SearchResult result1 = new SearchResult() { Index = 0 };
Assert.AreEqual<int>(result1.Index, result1, "The result converted to the wrong index."); // implicit conversion
SearchResult result2 = new SearchResult() { Index = 2 };
Assert.AreEqual<int>(result2.Index, result2, "The result converted to the wrong index."); // implicit conversion
}
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SearchResultTester.cs
示例13: TestBooleanConversion
public void TestBooleanConversion()
{
SearchResult result1 = new SearchResult() { Exists = true };
Assert.IsTrue(result1, "The value should have existed."); // implicit conversion
SearchResult result2 = new SearchResult() { Exists = false };
Assert.IsFalse(result2, "The value should not have existed."); // implicit conversion
}
开发者ID:jehugaleahsa,项目名称:NDex,代码行数:7,代码来源:SearchResultTester.cs
示例14: SearchResultMultiLine_ToString_EqualsExpected
public void SearchResultMultiLine_ToString_EqualsExpected()
{
var settings = new SearchSettings();
var pattern = new Regex("Search");
var searchFile = new SearchFile(CsSearchPath, "Searcher.cs", FileType.Text);
var lineNum = 10;
var matchStartIndex = 15;
var matchEndIndex = 23;
var line = "\tpublic class Searcher";
var linesBefore = new List<string> { "namespace CsSearch", "{" };
var linesAfter = new List<string> {"\t{", "\t\tprivate readonly FileTypes _fileTypes;"};
var searchResult = new SearchResult(pattern, searchFile, lineNum,
matchStartIndex, matchEndIndex,
line, linesBefore, linesAfter);
var expectedPath = CsSearchPath + "/Searcher.cs";
var expectedOutput = string.Format(new string('=', 80) + "\n" +
"{0}: {1}: [{2}:{3}]\n" +
new string('-', 80) + "\n" +
" 8 | namespace CsSearch\n" +
" 9 | {{\n" +
"> 10 | public class Searcher\n" +
" 11 | {{\n" +
" 12 | private readonly FileTypes _fileTypes;\n",
expectedPath, lineNum, matchStartIndex, matchEndIndex);
Assert.AreEqual(searchResult.ToString(settings), expectedOutput);
}
开发者ID:clarkcb,项目名称:xsearch,代码行数:26,代码来源:SearchResultTests.cs
示例15: Execute
public string Execute(TransitionContext context)
{
string retEvent = Events.Error;
try {
if (context.Request.Items[this.RoleItemNameIn] == null ||
!(context.Request.Items[this.RoleItemNameIn] is SearchResult<Role>) ||
context.Request.GetItem<SearchResult<Role>>(this.RoleItemNameIn).Items.Length != 1) {
throw new MissingFieldException("Could not retrieve an role or the more than one role was returned.");
}
Role role = context.Request.GetItem<SearchResult<Role>>(this.RoleItemNameIn).Items[0];
Role toReturn = Deserialize.Populate(context.Request, role);
SearchResult<Role> result = new SearchResult<Role>(new Role[] {toReturn});
context.Request.Items[this.RoleItemNameOut] = result;
retEvent = Events.Ok;
} catch (Exception ex) {
this.logger.Error("Error occured in Execute.", ex);
}
return retEvent;
}
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:26,代码来源:PopulateRoleFromRequestAction.cs
示例16: ABNegamax
/// <summary>
/// Execute Alpha - Beta Negemax search to find the next best cell.
/// </summary>
/// <returns>
/// The best cell and its score.
/// </returns>
/// <param name='board'>
/// The Game Board.
/// </param>
/// <param name='cell'>
/// The last taken <see cref="Yavalath.cell"/>.
/// </param>
/// <param name='height'>
/// The Height to which the search should be run until.
/// </param>
/// <param name='achievable'>
/// The Achievable Cell.
/// </param>
/// <param name='hope'>
/// Hope.
/// </param>
/// <param name='player'>
/// Player.
/// </param>
public static SearchResult ABNegamax(Board board, Cell cell, int height,
SearchResult achievable, SearchResult hope, int player)
{
var emptyCells = board.EmptyCells ();
if (height == 0 || emptyCells.Length == 0) {
return new SearchResult {
Score = Evaluation (board, cell, player),
Cell = cell,
Count = 1
};
} else {
SearchResult temp;
var score = Evaluation (board, cell, player);
achievable.Count += 1;
foreach (var _cell in emptyCells)
{
_cell.Player = player;
temp = -ABNegamax (board, _cell, height-1, -hope, -achievable, -player);
temp.Score += score;
_cell.Player = 0;
if (temp.Score >= hope.Score) {
return temp;
}
achievable.Count = temp.Count = achievable.Count + temp.Count;
achievable = temp.Score >= achievable.Score ? temp : achievable;
}
return achievable;
}
}
开发者ID:balazspete,项目名称:AIforGames,代码行数:54,代码来源:Algorithms.cs
示例17: Execute
public string Execute(TransitionContext context)
{
string retEvent = Events.Error;
try {
if (context.Request.Items[this.AttributeTypeItemNameIn] == null &&
!(context.Request.Items[this.AttributeTypeItemNameIn] is SearchResult<AttributeType>) &&
context.Request.GetItem<SearchResult<AttributeType>>(this.AttributeTypeItemNameIn).Items.Length != 1) {
throw new MissingFieldException("Could not retrieve an attribute type or the more than one attribute type was returned.");
}
AttributeType account = context.Request.GetItem<SearchResult<AttributeType>>(this.AttributeTypeItemNameIn).Items[0];
AttributeType toReturn = Deserialize.Populate(context.Request, account);
SearchResult<AttributeType> result = new SearchResult<AttributeType>(new AttributeType[] {toReturn});
context.Request.Items[this.AttributeTypeItemNameOut] = result;
retEvent = Events.Ok;
} catch (Exception ex) {
this.logger.Error("Error occured in Execute.", ex);
}
return retEvent;
}
开发者ID:rogue-bit,项目名称:Triton-Framework,代码行数:26,代码来源:PopulateAttributeTypeFromRequestAction.cs
示例18: SearchAll
static async Task<SearchResult> SearchAll(string key)
{
string url = XiamiUrl.UrlSearchAll(key);
string json = await NetAccess.DownloadStringAsync(url);
/////////////
dynamic obj = json.ToDynamicObject();
var items = new List<IMusic>();
foreach(var type in new string[] { "song", "album", "artist", "collect" })
{
var data = obj[type + "s"] as ArrayList;
if(data == null) continue;
foreach(dynamic x in data)
{
items.Add(MusicFactory.CreateFromJson(x, (EnumMusicType)Enum.Parse(typeof(EnumMusicType), type)));
}
}
var sr = new SearchResult
{
Items = items,
Keyword = key,
Page = -1,
SearchType = EnumSearchType.key
};
return sr;
}
开发者ID:3ricguo,项目名称:xiami_downloader,代码行数:25,代码来源:XiamiSearchProvider.cs
示例19: WriteLog
protected void WriteLog(string path,string searchwords,string index,int recNum,SearchResult sr)
{
try
{
FileStream fs = new FileStream(path, FileMode.Append);
StreamWriter sw = new StreamWriter(fs);
string str = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff") + "]" ;
sw.WriteLine(str);
sw.WriteLine("SearchWords=\t" + searchwords);
sw.WriteLine("Index=\t" + index);
sw.WriteLine("Search Record:\t" + recNum.ToString());
sw.WriteLine("PageNum:\t"+sr.PageNum);
foreach (SearchRecord record in sr.Records)
{
sw.WriteLine("==============================================");
sw.WriteLine("Caption:\t" + record.Caption);
foreach (SearchField field in record.Fields)
{
sw.WriteLine(field.Caption + "\t\t" + field.Name + "\t\t" + field.Value);
}
}
sw.WriteLine("#########################################################################");
sw.Flush();
sw.Close();
fs.Close();
}
catch (Exception e)
{
throw e;
}
}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:32,代码来源:searchutils.aspx.cs
示例20: ParseResponseProperties
/// <summary>
/// Parses the various properties from the XML document and populates the given SearchResult.
/// </summary>
/// <param name="result">The Google.CustomSearch.SearchResult to populate.</param>
/// <param name="nav">The XPathNavigator for the response document.</param>
private void ParseResponseProperties(SearchResult result, XPathNavigator nav)
{
XPathNavigator timeNode = nav.SelectSingleNode("/GSP/TM");
if (timeNode != null)
result.Time = timeNode.Value;
XPathNavigator titleNode = nav.SelectSingleNode("/GSP/Context/title");
if (titleNode != null)
result.Title = titleNode.Value;
XPathNavigator resultContainer = nav.SelectSingleNode("/GSP/RES");
if (resultContainer != null)
{
// See http://www.google.com/cse/docs/resultsxml.html#results_xml_tag_XT
result.Exact = resultContainer.SelectSingleNode("XT") != null;
result.Filtered = resultContainer.SelectSingleNode("FI") != null;
int startIndex;
string start = resultContainer.GetAttribute("SN", string.Empty);
if (int.TryParse(start, out startIndex))
{
result.StartIndex = startIndex;
}
int endIndex;
string end = resultContainer.GetAttribute("EN", string.Empty);
if (int.TryParse(end, out endIndex))
{
result.EndIndex = endIndex;
}
// Next and previous URLs
XPathNavigator navigation = resultContainer.SelectSingleNode("NB");
if (null != navigation)
{
XPathNavigator nextLink = navigation.SelectSingleNode("NU");
if (null != nextLink)
result.NextPageLink = nextLink.Value;
XPathNavigator previousLink = navigation.SelectSingleNode("NP");
if (null != previousLink)
result.PreviousPageLink = previousLink.Value;
}
XPathNavigator totalNode = resultContainer.SelectSingleNode("M");
if (totalNode != null)
{
int total;
if (int.TryParse(totalNode.Value, out total))
{
result.Total = total;
}
}
}
this.ParseSpellings(result, nav);
this.ParseFacets(result, nav);
}
开发者ID:musakkhir,项目名称:cse-net,代码行数:65,代码来源:ResponseParser.cs
注:本文中的SearchResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论