Giter Club home page Giter Club logo

raindrops.ui.webview's Introduction

Welcome to Raindrops.UI.WebView

miniblink vip版本封装

使用它你可以很轻松将miniblink引入你的任何C#项目
所有的P/Invoke代码位于NativeMethods内部
所有的事件位于 Miniblink/Event目录下

已封装好常用功能以及WebSocket接口,详细使用方法请看Raindrops.UI.WebView.TestWinForm

使用前需要

1、来自miniblink的 mb.dll node.dll

2、引入

    using Raindrops.UI.WebView.Miniblink;
    using Raindrops.UI.WebView.Miniblink.Event;
    using Raindrops.UI.WebView.Miniblink.PInvoke;
    using Raindrops.UI.WebView.Miniblink.PInvoke.Handle;

3、继承IMiniblinkProxy接口

使用EventAdapter<TEventArgs, TCallback> 它将自动寻找TCallback回调和TEventArgs属性、字段之间的对应关系,自动转换类型,并自动封装成事件。

EventAdapter<TEventArgs, TCallback> 内部使用ILEmit构造代码,无需担心性能问题。

例子:

 public class LoadUrlBeginEventArgs : EventArgs
 {
     [Map(Name = "url")]
     public string Url { get; set; }
     [Map(Name = "job")]
     public mbNetJob Job { get; set; }
     [Map(IsRet = true)]
     public bool Result { get; set; }
 }

public partial class Browser : UserControl, IMiniblinkProxy
{
    public EventAdapter<LoadUrlBeginEventArgs, mbLoadUrlBeginCallback> LoadUrlBegin;
    public Browser()
    {
        LoadUrlBegin = new EventAdapter<LoadUrlBeginEventArgs, mbLoadUrlBeginCallback>(this, NativeMethods.mbOnLoadUrlBegin);
        LoadUrlBegin.EventHandler += LoadUrlBegin_EventHandler;
    }
    private void LoadUrlBegin_EventHandler(object sender, Miniblink.Event.LoadUrlBeginEventArgs eventArgs)
    {
        if (eventArgs.Url.Contains("aaaaaa")) eventArgs.Job.ChangeRequestUrl("www.baidu.com");

        var postBody = eventArgs.Job.GetPostBody();
        if (postBody.elementSize.ToUInt32() > 0)
        {
            foreach (var body in postBody.GetElements())
            {
                var buffer = body.GetData().ToArray();
                string value = Encoding.UTF8.GetString(buffer);
                AppendLog($"Post {eventArgs.Url} -> StringLength:{value.Length}");
            }
        }
    }
}

QQ:744257911 So Easy

raindrops.ui.webview's People

Contributors

duwenjie15 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.