private static void InitializeHostHtmlDocumentServiceProvider(DynamicScriptObject scriptObject)
        {
            // The service provider is used for Internet Explorer IDispatchEx use.
            if (IsHostedInIEorWebOC &&
                scriptObject.ScriptObject is UnsafeNativeMethods.IHTMLWindow4 &&
                _hostHtmlDocumentServiceProvider.Value == null)
            {
                // We use the IDispatch infrastructure to gain access to the document DOM node where
                // the IServiceProvider lives that was recommended to us by IE people. Notice during
                // this call the HostHtmlDocumentServiceProvider property here is still null, so this
                // first request is made (and succeeds properly) without the service provider in place.
                object document;
                bool   foundDoc = scriptObject.TryFindMemberAndInvokeNonWrapped("document",
                                                                                NativeMethods.DISPATCH_PROPERTYGET,
                                                                                true /* cache DISPID, why not? */,
                                                                                null, /* arguments */
                                                                                out document);

                // The fact the host script is required to be a IHTMLWindow4 here ensures there is
                // document property and because we're dealing with IE, we know it has a service
                // provider on it.
                Invariant.Assert(foundDoc);
                _hostHtmlDocumentServiceProvider.Value = (UnsafeNativeMethods.IServiceProvider)document;

                // See HostHtmlDocumentServiceProvider property get accessor for more information on the use of
                // this field to ensure we got a valid service provider.
                _initializedHostScript.Value = true;
            }
        }
 private static void InitializeHostHtmlDocumentServiceProvider(DynamicScriptObject scriptObject)
 {
     if (BrowserInteropHelper.IsHostedInIEorWebOC && scriptObject.ScriptObject is UnsafeNativeMethods.IHTMLWindow4 && BrowserInteropHelper._hostHtmlDocumentServiceProvider.Value == null)
     {
         object obj;
         bool   condition = scriptObject.TryFindMemberAndInvokeNonWrapped("document", 2, true, null, out obj);
         Invariant.Assert(condition);
         BrowserInteropHelper._hostHtmlDocumentServiceProvider.Value = (UnsafeNativeMethods.IServiceProvider)obj;
         BrowserInteropHelper._initializedHostScript.Value           = true;
     }
 }
예제 #3
0
        private static void InitializeHostHtmlDocumentServiceProvider(DynamicScriptObject scriptObject) 
        { 
            // The service provider is used for Internet Explorer IDispatchEx use.
            if (   IsHostedInIEorWebOC 
                && scriptObject.ScriptObject is UnsafeNativeMethods.IHTMLWindow4
                && _hostHtmlDocumentServiceProvider.Value == null)
            {
                // We use the IDispatch infrastructure to gain access to the document DOM node where 
                // the IServiceProvider lives that was recommended to us by IE people. Notice during
                // this call the HostHtmlDocumentServiceProvider property here is still null, so this 
                // first request is made (and succeeds properly) without the service provider in place. 
                object document;
                bool foundDoc = scriptObject.TryFindMemberAndInvokeNonWrapped("document", 
                                                                              NativeMethods.DISPATCH_PROPERTYGET,
                                                                              true  /* cache DISPID, why not? */,
                                                                              null, /* arguments */
                                                                              out document); 

                // The fact the host script is required to be a IHTMLWindow4 here ensures there is 
                // document property and because we're dealing with IE, we know it has a service 
                // provider on it.
                Invariant.Assert(foundDoc); 
                _hostHtmlDocumentServiceProvider.Value = (UnsafeNativeMethods.IServiceProvider)document;

                // See HostHtmlDocumentServiceProvider property get accessor for more information on the use of
                // this field to ensure we got a valid service provider. 
                _initializedHostScript.Value = true;
            } 
        }