本文整理汇总了C#中Helpers.GetChild方法的典型用法代码示例。如果您正苦于以下问题:C# Helpers.GetChild方法的具体用法?C# Helpers.GetChild怎么用?C# Helpers.GetChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers.GetChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllImagesFromUrl
public static ParseImageResult[] GetAllImagesFromUrl(
string url,
System.Drawing.Size minSize,
bool collectIMGTags,
bool collectLINKTags,
bool collectMETATags,
int threadCount = 6,
Helpers.PercentageProgress prgItem = null,
bool downloadImages = false,
ParseRuleConnectionType type = ParseRuleConnectionType.Direct)
{
List<ParseImageResult> result = new List<ParseImageResult>();
try
{
Helpers.PercentageProgress prgItemPage = null;
Helpers.PercentageProgress prgItemImg = null;
if (prgItem != null)
{
prgItemPage = prgItem.GetChild();
prgItemImg = prgItem.GetChild();
}
HtmlAgilityPack.HtmlDocument document = SiteManager.GetContent(url, type, out url);
if (prgItemPage != null)
prgItemPage.Value = 100;
//threadCount = 6;
object lockAdd = new Object();
var allLinks = GetAllImagesUrlsFromUrl(document, url, collectIMGTags, collectLINKTags, collectMETATags, null);
int fullCnt = allLinks.Count();
int currLoaded = 0;
object currLoadedLock = new Object();
//threadCount = 1;
allLinks
.AsParallel()
.WithDegreeOfParallelism(threadCount)
.ForAll(node =>
{
Uri fileUrl = node.Url;// Helper.GetFullSourceLink(node.Url, document, url);
try
{
System.Drawing.Size imageSize;
if (Helper.CheckImageSize(fileUrl.AbsoluteUri, minSize, out imageSize, true, !downloadImages))
{
if (!imageSize.IsEmpty)
SetImageSize(node.Node, imageSize);
string fileName = fileUrl.AbsolutePath.Split(new[] { '/' }).Last();
string tempFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + System.IO.Path.GetExtension(fileName);
if (downloadImages)
{
SiteManager.GetFile(type, fileUrl, tempFileName);
bool isWebPArchive = false;
using (Stream inputStream = System.IO.File.Open(tempFileName, System.IO.FileMode.Open))
{
var webPcheck = new byte[4];
int btsRead;
if ((btsRead = inputStream.Read(webPcheck, 0, webPcheck.Length)) > 0)
{
var firstStr = Encoding.ASCII.GetString(webPcheck, 0, btsRead);
if (firstStr.ToUpper() == "RIFF")
isWebPArchive = true;
}
}
if (isWebPArchive)
{
Imazen.WebP.Extern.LoadLibrary.LoadWebPOrFail();
var decoder = new SimpleDecoder();
var outFile = tempFileName + ".jpg";
using (FileStream outStream = new FileStream(outFile, FileMode.Create))
using (Stream inputStream = System.IO.File.Open(tempFileName, System.IO.FileMode.Open))
{
var bytes = ReadFully(inputStream);
var outBitmap = decoder.DecodeFromBytes(bytes, bytes.LongLength);
outBitmap.Save(outStream, System.Drawing.Imaging.ImageFormat.Jpeg);
outStream.Close();
}
tempFileName = outFile;
}
}
System.Drawing.Image image = downloadImages ? System.Drawing.Image.FromFile(tempFileName) : null;
try
{
if (image != null)
{
imageSize = new System.Drawing.Size() { Height = image.Height, Width = image.Width };
if (!imageSize.IsEmpty)
//.........这里部分代码省略.........