static ControlAccessor() { SafeField fldControls = null; MethodInfo fnClear = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnClear = GetMethod("Clear"); fldControls = new SafeField(typeof(ControlCollection).GetField("_controls", BindingFlags.Instance | BindingFlags.NonPublic)); }); s_miClear = fnClear; ControlsArrayField = fldControls; CreateControlCollectionDelegate fnBaseCreateControlCollection = null; AddedControlDelegate fnBaseAddedControl = null; RemovedControlDelegate fnBaseRemovedControl = null; VoidMethodDelegate fnBaseClearNamingContainer = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnBaseCreateControlCollection = (CreateControlCollectionDelegate)Delegate.CreateDelegate(typeof(CreateControlCollectionDelegate), GetMethod("CreateControlCollection")); fnBaseAddedControl = (AddedControlDelegate)Delegate.CreateDelegate(typeof(AddedControlDelegate), GetMethod("AddedControl")); fnBaseRemovedControl = (RemovedControlDelegate)Delegate.CreateDelegate(typeof(RemovedControlDelegate), GetMethod("RemovedControl")); fnBaseClearNamingContainer = (VoidMethodDelegate)Delegate.CreateDelegate(typeof(VoidMethodDelegate), GetMethod("ClearNamingContainer")); }); BaseCreateControlCollection = fnBaseCreateControlCollection; BaseAddedControl = fnBaseAddedControl; BaseRemovedControl = fnBaseRemovedControl; BaseClearNamingContainer = fnBaseClearNamingContainer; }
static ControlAccessor() { SafeField fldControls = null; MethodInfo fnClear = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnClear = GetMethod("Clear"); fldControls = new SafeField(typeof(ControlCollection).GetField("_controls", BindingFlags.Instance | BindingFlags.NonPublic)); }); s_miClear = fnClear; ControlsArrayField = fldControls; CreateControlCollectionDelegate fnBaseCreateControlCollection = null; AddedControlDelegate fnBaseAddedControl = null; RemovedControlDelegate fnBaseRemovedControl = null; VoidMethodDelegate fnBaseClearNamingContainer = null; SecurityCritical.ExecutePrivileged(new PermissionSet(PermissionState.Unrestricted), delegate { fnBaseCreateControlCollection = (CreateControlCollectionDelegate)Delegate.CreateDelegate(typeof(CreateControlCollectionDelegate), GetMethod("CreateControlCollection")); fnBaseAddedControl = (AddedControlDelegate)Delegate.CreateDelegate(typeof(AddedControlDelegate), GetMethod("AddedControl")); fnBaseRemovedControl = (RemovedControlDelegate)Delegate.CreateDelegate(typeof(RemovedControlDelegate), GetMethod("RemovedControl")); fnBaseClearNamingContainer = (VoidMethodDelegate)Delegate.CreateDelegate(typeof(VoidMethodDelegate), GetMethod("ClearNamingContainer")); }); BaseCreateControlCollection = fnBaseCreateControlCollection; BaseAddedControl = fnBaseAddedControl; BaseRemovedControl = fnBaseRemovedControl; BaseClearNamingContainer = fnBaseClearNamingContainer; }
public void OpenRootDirectory() { VoidMethodDelegate v = delegate { Process.Start(@"explorer.exe", m_ServerPhysicalPath); }; v.BeginInvoke(null, null); }
private static void LaunchServerLight() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); s_ServerLightInstance = new ServerLight(); s_ServerLightInstance.StartWebServer(); //starting remotint API Uri baseAddress = new Uri(GetAppSettingbasePipeRecorderService()); //m_serviceHost = new ServiceHost(s_ServerLightInstance, baseAddress); //m_serviceHost.AddServiceEndpoint(typeof(IServerLight), new NetNamedPipeBinding(NetNamedPipeSecurityMode.None), baseAddress); //m_serviceHost.Open(); VoidMethodDelegate v = delegate { NotifyIconForm.Instance.NotifyIcon.ShowBalloonTip(1000, "ServerLight", s_ServerLightInstance.WebServerUri.ToString(), ToolTipIcon.Info); string path = s_ServerLightInstance.ServerPhysicalPath; if (path.Length >= 60) { path = path.Substring(s_ServerLightInstance.ServerPhysicalPath.Length - 60, 60); } NotifyIconForm.Instance.NotifyIcon.Text = path; s_serviceContainerHelper.AddService <IMenuService>(NotifyIconForm.Instance); s_serviceContainerHelper.AddService <IServerLight>(s_ServerLightInstance); PluginLoader pluginLoader = new PluginLoader(AppDomain.CurrentDomain.BaseDirectory); pluginLoader.LoadPluginAssemblies(s_serviceContainerHelper); ServerLightInstance.LaunchDefaultWebBrowser(); Application.Run(NotifyIconForm.Instance); }; v.BeginInvoke(delegate(IAsyncResult result) { VoidMethodDelegate vv = (VoidMethodDelegate)result.AsyncState; vv.EndInvoke(result); s_Event.Set(); }, v); s_Event.WaitOne(); s_Event.Close(); s_ServerLightInstance.StopWebServer(); //if (m_serviceHost != null) //{ // m_serviceHost.Close(); //} }
public void LaunchDefaultWebBrowser() { VoidMethodDelegate v = delegate { Uri homePageUri = GetWebServerHomePageUri(); if (homePageUri == null) { return; } Process.Start(homePageUri.ToString()); }; v.BeginInvoke(null, null); }