本文整理汇总了C#中WebView.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# WebView.Dispose方法的具体用法?C# WebView.Dispose怎么用?C# WebView.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebView
的用法示例。
在下文中一共展示了WebView.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
bool help = false;
bool screens = false;
string user = null, pass = null;
string chatUrl = null, scriptUrl = null;
string sessionPath = null;
// http://geekswithblogs.net/robz/archive/2009/11/22/command-line-parsing-with-mono.options.aspx
OptionSet options = new OptionSet()
.Add("?|h|help", "Print this message", option => help = option != null)
.Add("u=|user=|username=", "Required: StackExchange username or email", option => user = option)
.Add("p=|pass=|password=", "Required: StackExchange password", option => pass = option)
.Add("c=|chat-url=", "Required: Chatroom URL", option => chatUrl = option)
.Add("b=|bot-script=|script-url=", "Required: The URL of a bot script", option => scriptUrl = option)
.Add("s|screens|screenshot", "Display screenshots at checkpoints", option => screens = option != null)
.Add("session-path=", "Path to browser session (profile), where settings are saved", option => sessionPath = option);
#if DEBUG
string[] lines = File.ReadAllLines("account.txt");
user = lines[0];
pass = lines[1];
chatUrl = "http://chat.stackexchange.com/rooms/118/root-access";
scriptUrl = "https://raw.github.com/allquixotic/SO-ChatBot/master/master.js";
screens = true;
sessionPath = "session";
#else
try
{
options.Parse(args);
}
catch (OptionException)
{
ShowHelp(options, "Error - usage is:");
}
if (help)
{
ShowHelp(options, "Usage:");
}
if (user == null)
{
ShowHelp(options, "Error: A username is required");
}
if (pass == null)
{
ShowHelp(options, "Error: A password is required");
}
if (chatUrl == null)
{
ShowHelp(options, "Error: A chat URL is required");
}
if (scriptUrl == null)
{
ShowHelp(options, "Error: A bot script is required");
}
if (sessionPath == null)
{
sessionPath = "session";
}
#endif
try
{
WebConfig config = new WebConfig();
WebCore.Initialize(config);
WebPreferences prefs = new WebPreferences();
prefs.LoadImagesAutomatically = true;
prefs.RemoteFonts = false;
prefs.WebAudio = false;
prefs.Dart = false;
prefs.CanScriptsCloseWindows = false;
prefs.CanScriptsOpenWindows = false;
prefs.WebSecurity = false;
prefs.Javascript = true;
prefs.LocalStorage = true;
prefs.Databases = false; // ?
aweSession = WebCore.CreateWebSession(sessionPath, prefs);
aweSession.ClearCookies();
aweView = WebCore.CreateWebView(1024, 768, aweSession);
aweView.ResponsiveChanged += aweView_ResponsiveChanged;
aweView.Crashed += aweView_Crashed;
aweView.ConsoleMessage += aweView_ConsoleMessage;
eView.WebView = aweView;
eView.AutoScreenshot = true;
eView.ScreenshotsEnabled = screens;
go(user, pass, scriptUrl, chatUrl);
}
finally
{
if (aweView != null && aweView.IsResponsive)
aweView.Dispose();
WebCore.Shutdown();
//.........这里部分代码省略.........