Пример #1
0
        public Node(String address, Link link, dynamic controller = null)
        {
            _link = link;
            var config = new IniFile("nw.cfg");

            myaddress = config.GetValue("node", "name");
            myid      = config.GetValue("node", "id");
            if (myaddress == null)
            {
                myaddress = address;
                config.SetValue("node", "name", myaddress);
                config.SetValue("node", "id", "none");
                config.Save("nw.cfg");
            }

            if (controller != null)
            {
                MethodInfo[] methodInfos = controller.GetType()
                                           .GetMethods(BindingFlags.Public | BindingFlags.Instance);
                var getmethods = from method in methodInfos where method.Name.StartsWith("Get_") select method;
                var setmethods = from method in methodInfos where method.Name.StartsWith("On_") select method;
                foreach (var g in getmethods)
                {
                    getfns.Add(g.Name.Substring(4), g.CreateDelegate(typeof(get_delegate), controller));
                }
                foreach (var s in setmethods)
                {
                    setfns.Add(s.Name.Substring(3), s.CreateDelegate(typeof(set_delegate), controller));
                }

                var fncon = from method in methodInfos where method.Name == "Connected" select method;
                if (fncon.Count() != 0)
                {
                    fn_connected = fncon.First().CreateDelegate(typeof(dlg_connected), controller);
                }
                var fndiscon = from method in methodInfos where method.Name == "Disconnected" select method;
                if (fndiscon.Count() != 0)
                {
                    fn_disconnected = fndiscon.First().CreateDelegate(typeof(dlg_connected), controller);
                }
                var fnnode = from method in methodInfos where method.Name == "GotNode" select method;
                if (fnnode.Count() != 0)
                {
                    fn_got_node = fnnode.First().CreateDelegate(typeof(set_delegate), controller);
                }
            }
        }
Пример #2
0
        public static void set(cef_request_t *self, cef_string_t *url, cef_string_t *method, cef_post_data_t *postData, cef_string_multimap *headerMap)
        {
            set_delegate d;
            var          p = self->_set;

            if (p == _pc)
            {
                d = _dc;
            }
            else
            {
                d = (set_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_delegate));
                if (_pc == IntPtr.Zero)
                {
                    _dc = d; _pc = p;
                }
            }
            d(self, url, method, postData, headerMap);
        }
Пример #3
0
 public static void set(cef_request_t* self, cef_string_t* url, cef_string_t* method, cef_post_data_t* postData, cef_string_multimap* headerMap)
 {
     set_delegate d;
     var p = self->_set;
     if (p == _pc) { d = _dc; }
     else
     {
         d = (set_delegate)Marshal.GetDelegateForFunctionPointer(p, typeof(set_delegate));
         if (_pc == IntPtr.Zero) { _dc = d; _pc = p; }
     }
     d(self, url, method, postData, headerMap);
 }