コード例 #1
0
        private object _RunDelegate(object args)
        {
            ApplicationProxyInternal.InitData initData = (ApplicationProxyInternal.InitData)args;
            Application application = Application.Current;

            if (application != null && !(application is XappLauncherApp))
            {
                string text = initData.Fragment;
                if (!string.IsNullOrEmpty(text) && application.StartupUri != null)
                {
                    Uri uri = application.StartupUri;
                    if (!application.StartupUri.IsAbsoluteUri)
                    {
                        uri = new Uri(BindUriHelper.BaseUri, application.StartupUri);
                    }
                    UriBuilder uriBuilder = new UriBuilder(uri);
                    if (text.StartsWith("#", StringComparison.Ordinal))
                    {
                        text = text.Substring("#".Length);
                    }
                    uriBuilder.Fragment    = text;
                    application.StartupUri = uriBuilder.Uri;
                }
                this.CreateRootBrowserWindow();
            }
            if (initData.UcomLoadIStream != null && initData.HandleHistoryLoad)
            {
                this.LoadHistoryStream(DocObjHost.ExtractComStream(initData.UcomLoadIStream), true);
            }
            return(null);
        }
コード例 #2
0
        internal int Run(ApplicationProxyInternal.InitData initData)
        {
            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_AppProxyRunStart);
            if (!AppDomain.CurrentDomain.IsDefaultAppDomain())
            {
                IntPtr iunknownForObject = Marshal.GetIUnknownForObject(initData.HostBrowser);
                try
                {
                    initData.HostBrowser = (IHostBrowser)Marshal.GetObjectForIUnknown(iunknownForObject);
                }
                finally
                {
                    Marshal.Release(iunknownForObject);
                }
            }
            BrowserInteropHelper.HostBrowser = initData.HostBrowser;
            MimeType value = initData.MimeType.Value;

            this._mimeType.Value = value;
            this.Uri             = initData.ActivationUri.Value;
            WpfWebRequestHelper.DefaultUserAgent = initData.UserAgentString;
            BrowserInteropHelper.HostingFlags    = initData.HostingFlags;
            this.Move(initData.WindowRect);
            this.Show(initData.ShowWindow);
            switch (value)
            {
            case MimeType.Document:
                throw new NotImplementedException();

            case MimeType.Application:
                goto IL_F6;

            case MimeType.Markup:
            {
                Invariant.Assert(AppDomain.CurrentDomain.FriendlyName == "XamlViewer");
                Application application = new Application();
                application.StartupUri = this.Uri;
                goto IL_F6;
            }
            }
            throw new InvalidOperationException();
IL_F6:
            Application.Current.MimeType = value;
            this.ServiceProvider         = initData.ServiceProvider;
            Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, new DispatcherOperationCallback(this._RunDelegate), initData);
            int result = Application.Current.RunInternal(null);

            EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordPerf | EventTrace.Keyword.KeywordHosting, EventTrace.Level.Verbose, EventTrace.Event.WpfHost_AppProxyRunEnd);
            return(result);
        }