DOTNETIDS.WebScanRunner.SetupBinding C# (CSharp) Method

SetupBinding() private method

private SetupBinding ( Type t, string method ) : void
t System.Type
method string
return void
        private void SetupBinding(Type t, string method)
        {
            MethodInfo mi = t.GetMethod(method);

            //Determine the binding method
            if (mi.IsStatic)
            {
                Delegate d = Delegate.CreateDelegate(typeof(IDSEvent), mi);
                OnIDSEvents += (IDSEvent)d;
            }
            else
            {
                if (t.IsSubclassOf(typeof(Page)))
                {
                    //Set up a callback to an instance method inside a Page
                    object o = HttpContext.Current.CurrentHandler;

                    //Determine if the current Handler is of a usable type
                    if (t.IsInstanceOfType(o))
                    {
                        if (_callScan == true)
                        {
                            ((Page)o).PreInit += new EventHandler(WebScanRunner_PreInit);
                        }

                        Delegate d = Delegate.CreateDelegate(typeof(IDSEvent), o, method);
                        OnIDSEvents += (IDSEvent)d;
                        
                        _callScan = false;
                    }
                }
                else
                {
                    //Set up a callback to an instance method not inside a Page
                    object o = Activator.CreateInstance(t);
                    Delegate d = Delegate.CreateDelegate(typeof(IDSEvent), o, method);
                    OnIDSEvents += (IDSEvent)d;
                }

            }
        }