- HttpDataClientLibrary.zip
- HttpDataClientLibrary
- Http
- DB4Object
- Db4objects.Db4o.dll
- Db4objects.Db4o.NativeQueries.dll
- HttpData.Client.MsHtmlToXml
- HttpData.Client.Pdf
- HttpData.Client
- HttpData.HtmlAgilityPack
- HtmlAgilityPack
- HttpDataClientLibrary.sln
- Sample
- HttpDataClientSample
|
using System;
using System.Windows.Forms;
using System.Threading;
namespace HttpData.Client.MsHtmlToXml
{
public class WebHost : ApplicationContext
{
#region Private Variables
private AutoResetEvent resultEvent;
private HtmlLoader loader;
private Thread loaderThread;
#endregion
#region Public Variables
public delegate void ProcessingCompleted(string value);
#endregion
#region .ctor
public WebHost(string htmlContent, bool disableScripting, HtmlFixOption options, ProcessingCompleted completed, AutoResetEvent resultEvent)
{
try
{
this.resultEvent = resultEvent;
this.DisableScripting = disableScripting;
loaderThread = new Thread(new ThreadStart(
delegate
{
Process(htmlContent, options, completed);
Application.Run(this);
}));
loaderThread.SetApartmentState(ApartmentState.STA);
loaderThread.Start();
}
catch (Exception ex)
{
//Helpers.ExceptionHelper.DebugException(Helpers.ExceptionHelper.GetExceptionMessage(ex, "Web Host"), ex);
}
}
#endregion
#region Properties
public bool DisableScripting { get; set; }
#endregion
#region Protected Methods
protected override void Dispose(bool disposing)
{
if (loaderThread != null)
{
try
{
loaderThread.Abort();
}
// ReSharper disable EmptyGeneralCatchClause
catch
// ReSharper restore EmptyGeneralCatchClause
{
}
finally
{
loaderThread = null;
}
}
base.Dispose(disposing);
}
#endregion
#region Private Methods
private void Process(string htmlContent, HtmlFixOption options, ProcessingCompleted completed)
{
loader = new HtmlLoader
{
DisableScripting = this.DisableScripting
};
string value = loader.GenerateXmlEx(htmlContent, options);
completed(value);
resultEvent.Set();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am a senior software engineer with over 8 years experience. Have worked for different international software companies using different technologies and programming languages like: C/C++, lotus script, lotus API, C#, ASP.NET, WCF, MS-SQL, Oracle, Domino Server, JavaScript.