hello, so i have sample code for windows for c#:
using CefSharp;
using CefSharp.Handler;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace FlymerLite
{
public class frmFlymerLite : Form
{
private IContainer components = null;
private ChromiumWebBrowser browser;
public frmFlymerLite()
{
CefSharpSettings.set_WcfEnabled(true);
CefSettings cefSetting = new CefSettings();
cefSetting.set_CachePath(Path.GetFullPath("cache"));
Cef.Initialize(cefSetting);
this.InitializeComponent();
}
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
{
}
protected override void Dispose(bool disposing)
{
if ((!disposing ? false : this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void frmFlymerLite_Load(object sender, EventArgs e)
{
frmFlymerLite.RedirectionRequestHandler handler = new frmFlymerLite.RedirectionRequestHandler();
handler.AddRedirection("http://www.flyordie.com/games/online/c/game5.html?664", "js\\online\\c\\game5[664].html");
handler.AddRedirection("http://www.flyordie.com/games/deploy/pool/180910/code.jz", "js\\deploy\\pool\\180910\\code.jz");
handler.AddRedirection("http://www.flyordie.com/games/deploy/snooker/180910/code.jz", "js\\deploy\\snooker\\180910\\code.jz");
this.browser.set_RequestHandler(handler);
this.browser.Load("http://www.flyordie.com/games/online/games.html?game=8Ball");
}
private void InitializeComponent()
{
this.browser = new ChromiumWebBrowser();
base.SuspendLayout();
this.browser.set_ActivateBrowserOnCreation(false);
this.browser.Dock = DockStyle.Fill;
this.browser.Location = new Point(0, 0);
this.browser.Name = "browser";
this.browser.Size = new System.Drawing.Size(1140, 600);
this.browser.TabIndex = 0;
this.browser.add_LoadingStateChanged(new EventHandler<LoadingStateChangedEventArgs>(this.browser_LoadingStateChanged));
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(1140, 600);
base.Controls.Add(this.browser);
base.Name = "frmFlymerLite";
this.Text = "Flymer Lite";
base.Load += new EventHandler(this.frmFlymerLite_Load);
base.ResumeLayout(false);
}
private class FilePathResourceRequestHandler : ResourceRequestHandler
{
private string filePath;
public FilePathResourceRequestHandler(string filePath)
{
this.filePath = filePath;
}
protected override IResourceHandler GetResourceHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request)
{
return ResourceHandler.FromFilePath(this.filePath, null, false);
}
}
public class MyCustomLifeSpanHandler : ILifeSpanHandler
{
public MyCustomLifeSpanHandler()
{
}
public bool DoClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
return true;
}
public void OnAfterCreated(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
public void OnBeforeClose(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
}
public bool OnBeforePopup(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
{
browser.get_MainFrame().LoadUrl(targetUrl);
newBrowser = null;
return true;
}
}
public class RedirectionRequestHandler : RequestHandler
{
private Dictionary<string, string> redirections;
public RedirectionRequestHandler()
{
this.redirections = new Dictionary<string, string>();
}
public void AddRedirection(string url, string filePath)
{
this.redirections.Add(url, filePath);
}
public void ClearRedirections()
{
this.redirections.Clear();
}
public bool ContainsUrl(string url)
{
return this.redirections.ContainsKey(url);
}
public string GetFilePath(string url)
{
return this.redirections[url];
}
protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
{
IResourceRequestHandler filePathResourceRequestHandler;
if (!this.redirections.ContainsKey(request.get_Url()))
{
filePathResourceRequestHandler = null;
}
else
{
filePathResourceRequestHandler = new frmFlymerLite.FilePathResourceRequestHandler(this.redirections[request.get_Url()]);
}
return filePathResourceRequestHandler;
}
public bool RemoveUrl(string url)
{
return this.redirections.Remove(url);
}
}
}
}
my question is how would i make this for mac os via xcode or visual studio?
keep getting errors im trying to simply make a web site load my editied modified file instead of there own file on the server?