本文整理汇总了C#中IRequestCallback类的典型用法代码示例。如果您正苦于以下问题:C# IRequestCallback类的具体用法?C# IRequestCallback怎么用?C# IRequestCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRequestCallback类属于命名空间,在下文中一共展示了IRequestCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: using
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
return CefReturnValue.Continue;
}
示例2: Uri
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame,
IRequest request, IRequestCallback callback) {
if (CommonUrls.IsWithSixUrl(request.Url)) {
var headers = request.Headers;
headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString();
headers[Common.ClientHeaderV] = Common.App.ProductVersion;
request.Headers = headers;
}
return CefReturnValue.Continue;
//Example of how to set Referer
// Same should work when setting any header
// For this example only set Referer when using our custom scheme
var url = new Uri(request.Url);
if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName
{
var headers = request.Headers;
headers["Referer"] = "http://google.com";
request.Headers = headers;
}
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed) {
using (callback) {
if (request.Method == "POST") {
using (var postData = request.PostData) {
if (postData != null) {
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements) {
if (element.Type == PostDataElementType.Bytes) {
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
示例3: using
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
//To allow certificate
//callback.Continue(true);
//return true;
}
}
return false;
}
示例4:
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
try
{
//To allow certificate
//callback.Continue(true);
//return true;
return false;
}
finally
{
callback.Dispose();
}
}
示例5: using
bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode,
string requestUrl, ISslInfo sslInfo, IRequestCallback callback) {
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed) {
using (callback) {
//To allow certificate
//callback.Continue(true);
//return true;
}
}
return false;
}
示例6: using
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
if(postData != null)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
示例7: DeleteAllCookiesVisitor
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
// For some reason, in order to set cookies manually using a hdeader you need to clear the real cookies every time :/
Cef.GetGlobalCookieManager().VisitAllCookies(new DeleteAllCookiesVisitor());
if (request.Url.StartsWith("steammobile://"))
{
// Cancel all steammobile:// requests (for the app)
return CefReturnValue.Cancel;
}
else
{
var headers = request.Headers;
headers.Add("Cookie", Cookies);
headers.Add("X-Requested-With", "com.valvesoftware.android.steam.community");
request.Headers = headers;
return CefReturnValue.Continue;
}
}
示例8:
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
try
{
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
finally
{
callback.Dispose();
}
return CefReturnValue.Continue;
}
示例9: make_call
public new void make_call( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb )
{
Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'");
onServerResponse(responses[apicall] as String, apicall, cb);
}
示例10: OnQuotaRequest
public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
{
return false;
}
示例11: OnCertificateError
public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
{
return false;
}
示例12: OnBeforeResourceLoad
public CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
return CefReturnValue.Continue;
}
示例13: MakeCall
public new void MakeCall( string apicall, Hashtable args, IRequestCallback cb, bool requires_auth_token )
{
Assert.IsTrue(responses.ContainsKey(apicall), "no mock response setup for api path '" + apicall + "'");
OnServerResponse(responses[apicall] as String, apicall, cb);
}
示例14: Uri
CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
//Example of how to set Referer
// Same should work when setting any header
// For this example only set Referer when using our custom scheme
var url = new Uri(request.Url);
if (url.Scheme == CefSharpSchemeHandlerFactory.SchemeName)
{
//Referrer is now set using it's own method (was previously set in headers before)
request.SetReferrer("http://google.com", ReferrerPolicy.Default);
}
//Example of setting User-Agent in every request.
//var headers = request.Headers;
//var userAgent = headers["User-Agent"];
//headers["User-Agent"] = userAgent + " CefSharp";
//request.Headers = headers;
//NOTE: If you do not wish to implement this method returning false is the default behaviour
// We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//callback.Dispose();
//return false;
//NOTE: When executing the callback in an async fashion need to check to see if it's disposed
if (!callback.IsDisposed)
{
using (callback)
{
if (request.Method == "POST")
{
using (var postData = request.PostData)
{
if(postData != null)
{
var elements = postData.Elements;
var charSet = request.GetCharSet();
foreach (var element in elements)
{
if (element.Type == PostDataElementType.Bytes)
{
var body = element.GetBody(charSet);
}
}
}
}
}
//Note to Redirect simply set the request Url
//if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
//{
// request.Url = "https://github.com/";
//}
//Callback in async fashion
//callback.Continue(true);
//return CefReturnValue.ContinueAsync;
}
}
return CefReturnValue.Continue;
}
示例15: MakeCall
public void MakeCall( string apicall, Hashtable args, IRequestCallback<IXMLNode> cb )
{
unityObject.DoCoroutine( SendCore( apicall, args, cb ) );
}