FromStream() public static method

Gets the resource from a stream.
public static FromStream ( Stream stream, string mimeType = DefaultMimeType ) : ResourceHandler
stream Stream A stream of the resource.
mimeType string Type of MIME.
return ResourceHandler
Example #1
0
        /// <summary>
        /// Register a ResourceHandler. Can only be used when browser.ResourceHandlerFactory is an instance of DefaultResourceHandlerFactory
        /// </summary>
        /// <param name="browser">The ChromiumWebBrowser instance this method extends</param>
        /// <param name="url">the url of the resource to unregister</param>
        /// <param name="stream">Stream to be registered, the stream should not be shared with any other instances of DefaultResourceHandlerFactory</param>
        /// <param name="mimeType">the mimeType</param>
        public static void RegisterResourceHandler(this IWebBrowser browser, string url, Stream stream, string mimeType = ResourceHandler.DefaultMimeType)
        {
            var handler = browser.ResourceHandlerFactory as DefaultResourceHandlerFactory;

            if (handler == null)
            {
                throw new Exception("RegisterResourceHandler can only be used with the default IResourceHandlerFactory(DefaultResourceHandlerFactory) implementation");
            }

            handler.RegisterHandler(url, ResourceHandler.FromStream(stream, mimeType));
        }