本文整理汇总了C#中System.Uri.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Uri.GetHashCode方法的具体用法?C# Uri.GetHashCode怎么用?C# Uri.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Uri
的用法示例。
在下文中一共展示了Uri.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test22URL
public virtual void Test22URL()
{
DeleteBase("test.url.odb");
var url1 = new Uri("http://google.com");
var url2 = new Uri("http://nprogramming.wordpress.com");
var h1 = url1.GetHashCode();
var h2 = url2.GetHashCode();
Println(h1 + " - " + h2);
Println(url1.Host + " - " + url1.Port);
Println(url2.Host + " - " + url2.Port);
var odb = Open("test.url.odb");
odb.Store(url1);
odb.Store(url2);
odb.Close();
odb = Open("test.url.odb");
var query = odb.Query<Uri>();
var l = query.Execute<Uri>();
var first = l.FirstOrDefault(x => x.AbsoluteUri == "http://google.com/");
Assert.That(first, Is.Not.Null);
var second = l.FirstOrDefault(x => x.AbsoluteUri == "http://nprogramming.wordpress.com/");
Assert.That(second, Is.Not.Null);
odb.Close();
AssertEquals("Same HashCode Problem", 2, l.Count());
}
示例2: Db4oHistoryService
public Db4oHistoryService(Uri baseUri, bool resume)
{
m_Resume = resume;
m_Db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),
"NCrawlerHist_{0}.Yap".FormatWith(baseUri.GetHashCode()));
ClearHistory();
}
示例3: EsentCrawlQueueService
public EsentCrawlQueueService(Uri baseUri, bool resume)
{
m_DatabaseFileName = Path.GetFullPath("NCrawlQueue{0}\\Queue.edb".FormatWith(baseUri.GetHashCode()));
if (!resume && File.Exists(m_DatabaseFileName))
{
ClearQueue();
}
m_EsentInstance = new EsentInstance(m_DatabaseFileName, (session, dbid) =>
{
EsentTableDefinitions.CreateGlobalsTable(session, dbid);
EsentTableDefinitions.CreateQueueTable(session, dbid);
});
// Get columns
m_EsentInstance.Cursor((session, dbid) =>
{
Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.GlobalsTableName,
EsentTableDefinitions.GlobalsCountColumnName,
out queueCountColumn);
Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.QueueTableName,
EsentTableDefinitions.QueueTableDataColumnName,
out dataColumn);
});
}
示例4: EsentCrawlerHistoryService
public EsentCrawlerHistoryService(Uri baseUri, bool resume)
{
m_Resume = resume;
m_DatabaseFileName = Path.GetFullPath("NCrawlHist{0}\\Hist.edb".FormatWith(baseUri.GetHashCode()));
if (!resume)
{
ClearHistory();
}
m_EsentInstance = new EsentInstance(m_DatabaseFileName, (session, dbid) =>
{
EsentTableDefinitions.CreateGlobalsTable(session, dbid);
EsentTableDefinitions.CreateHistoryTable(session, dbid);
});
// Get columns
m_EsentInstance.Cursor((session, dbid) =>
{
Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.GlobalsTableName,
EsentTableDefinitions.GlobalsCountColumnName, out historyCountColumn);
Api.JetGetColumnInfo(session, dbid, EsentTableDefinitions.HistoryTableName,
EsentTableDefinitions.HistoryTableUrlColumnName, out historyUrlColumn);
});
}
示例5: DbCrawlQueueService
public DbCrawlQueueService(Uri baseUri, bool resume)
{
m_GroupId = baseUri.GetHashCode();
if (!resume)
{
Clean();
}
}
示例6: SqLiteCrawlerHistoryService
public SqLiteCrawlerHistoryService(Uri uri, bool resume)
{
m_GroupId = uri.GetHashCode();
if (!resume)
{
Clean();
}
}
示例7: EfCrawlQueueService
/// <summary>
/// Initializes a new instance of the <see cref="EfCrawlQueueService"/> class.
/// </summary>
/// <param name="baseUri">Uri from which work is started.</param>
/// <param name="resume">True to resume work, false otherwise.</param>
public EfCrawlQueueService(Uri baseUri, bool resume)
{
this.groupId = baseUri.GetHashCode();
if (!resume)
{
this.CleanQueue();
}
}
示例8: Db4oHistoryService
public Db4oHistoryService(Uri baseUri, bool resume)
{
m_Db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),
"NCrawlerHist_{0}.Yap".FormatWith(baseUri.GetHashCode()));
if (!resume)
{
m_Db.Query<StringWrapper>().ForEach(entry => m_Db.Delete(entry));
}
}
示例9: EfCrawlerHistoryService
/// <summary>
/// Initializes a new instance of the <see cref="EfCrawlerHistoryService"/> class.
/// </summary>
/// <param name="uri">Uri from which work is started.</param>
/// <param name="resume">True to resume work, false otherwise.</param>
public EfCrawlerHistoryService(Uri uri, bool resume)
{
this.resume = resume;
this.groupId = uri.GetHashCode();
if (!this.resume)
{
this.CleanHistory();
}
}
示例10: Db4oQueueService
public Db4oQueueService(Uri baseUri, bool resume)
{
string fileName = Path.GetFullPath("NCrawlerQueue_{0}.Yap".FormatWith(baseUri.GetHashCode()));
m_Db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(), fileName);
if (!resume)
{
ClearQueue();
}
}
示例11: Db4oQueueService
public Db4oQueueService(Uri baseUri, bool resume)
{
m_Db = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),
"NCrawlerQueue_{0}.Yap".FormatWith(baseUri.GetHashCode()));
if (!resume)
{
m_Db.Query<CrawlerQueueEntry>().ForEach(entry => m_Db.Delete(entry));
}
}
示例12: Run
public static void Run()
{
Console.Out.WriteLine("Simple crawl demo using local database a storage");
var targetToCrawl = ConfigurationManager.AppSettings["CrawlTargetUrl"];
var maximumThreadCount = int.Parse(ConfigurationManager.AppSettings["MaximumThreadCount"]);
var maximumCrawlDepth = int.Parse(ConfigurationManager.AppSettings["MaximumCrawlDepth"]);
// Setup crawler to crawl http://ncrawler.codeplex.com
// with 1 thread adhering to robot rules, and maximum depth
// of 2 with 4 pipeline steps:
// * Step 1 - The Html Processor, parses and extracts links, text and more from html
// * Step 2 - Processes PDF files, extracting text
// * Step 3 - Try to determine language based on page, based on text extraction, using google language detection
// * Step 4 - Dump the information to the console, this is a custom step, see the DumperStep class
DbServicesModule.Setup(true);
using (Crawler c = new Crawler(new Uri(targetToCrawl),
new WholeHtmlProcessor(), // Process html
new DumperStep())
{
// Custom step to visualize crawl
MaximumThreadCount = maximumThreadCount,
MaximumCrawlDepth = maximumCrawlDepth,
ExcludeFilter = Program.ExtensionsToSkip,
})
{
AspectF.Define.Do<NCrawlerEntitiesDbServices>(e =>
{
if (e.CrawlQueue.Any())
{
var uri = new Uri(targetToCrawl);
var groupId = uri.GetHashCode();
Console.Out.WriteLine("GroupId=" + groupId);
e.ExecuteStoreCommand("Update CrawlQueue set Exclusion='false' where GroupId={0} and Exclusion='true'", groupId);
//var exclusion = e.CrawlQueue.Where(m => m.Exclusion && m.GroupId == groupId).ToList();
//if (exclusion.Any())
//{
// Console.Out.WriteLine("Count with Exclusion=" + exclusion.Count);
// exclusion.ForEach(m => m.Exclusion = false);
//}
////foreach (var crawlQueue in e.CrawlQueue)
////{
//// crawlQueue.Exclusion = false;
////}
//e.SaveChanges();
}
});
// Begin crawl
Console.Out.WriteLine(" Begin crawl");
c.Crawl();
}
}
示例13: CouchbaseNode
public CouchbaseNode(CouchbaseRestConfiguration config, Uri uri)
{
_config = config;
Id = uri.GetHashCode();
Uri = uri;
_builder = new UrlBuilder(uri);
ErrorAge = DateTime.UtcNow;
//The first time a request is made to a URI, the ServicePointManager
//will create a ServicePoint to manage connections to a particular host
ServicePointManager.FindServicePoint(Uri).SetTcpKeepAlive(true, 300, 30);
}
示例14: GetBackTXRequest
protected BackgroundTransferRequest GetBackTXRequest(string src,string tag)
{
Uri src_uri = new Uri(src, UriKind.Absolute);
Uri dst_uri = new Uri("shared\\transfers\\temp"+src_uri.GetHashCode()+".mp3", UriKind.Relative);
BackgroundTransferRequest back_req = new BackgroundTransferRequest(src_uri, dst_uri);
back_req.Tag = tag;
bool use_cellular = false;
IsolatedStorageSettings.ApplicationSettings.TryGetValue("use_cellular", out use_cellular);
if (use_cellular)
back_req.TransferPreferences = TransferPreferences.AllowCellularAndBattery;
else
back_req.TransferPreferences = TransferPreferences.AllowBattery;
return back_req;
}
示例15: GetImage
public void GetImage(Uri uri, Action<byte[]> callback)
{
var fileName = cachePath + "Smeedee_img" + uri.GetHashCode();
if (File.Exists(fileName))
{
var bytes = fileReader.ReadAllBytes(fileName);
if (IsMissingImagePlaceholder(bytes))
bytes = null;
callback(bytes);
} else
{
serviceToCache.GetImage(uri, bytes => SaveAndCallback(bytes, fileName, callback));
}
}