// Copyright © 2010-2017 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Text; namespace CefSharp { /// /// ByteArrayResourceHandler is used as a placeholder class which uses native CEF implementations. /// CefStreamReader::CreateForData(); reads the byte array that is passed to a new instance /// of CefStreamResourceHandler /// TODO: Move this class into Handler namespace /// public class ByteArrayResourceHandler : IResourceHandler { /// /// Underlying byte array that represents the data /// public byte[] Data { get; private set; } /// /// Gets or sets the Mime Type. /// public string MimeType { get; set; } /// /// Initializes a new instance of the class. /// /// mimeType /// filePath public ByteArrayResourceHandler(string mimeType, byte[] data) { if(string.IsNullOrEmpty(mimeType)) { throw new ArgumentNullException("mimeType", "Please provide a valid mimeType"); } if(data == null) { throw new ArgumentNullException("data", "Please provide a valid array"); } MimeType = mimeType; Data = data; } bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback) { //Should never be called throw new NotImplementedException("This method should never be called"); } void IResourceHandler.GetResponseHeaders(IResponse response, out long responseLength, out string redirectUrl) { //Should never be called throw new NotImplementedException("This method should never be called"); } bool IResourceHandler.ReadResponse(Stream dataOut, out int bytesRead, ICallback callback) { //Should never be called throw new NotImplementedException("This method should never be called"); } bool IResourceHandler.CanGetCookie(Cookie cookie) { //Should never be called throw new NotImplementedException("This method should never be called"); } bool IResourceHandler.CanSetCookie(Cookie cookie) { //Should never be called throw new NotImplementedException("This method should never be called"); } void IResourceHandler.Cancel() { //Should never be called throw new NotImplementedException("This method should never be called"); } void IDisposable.Dispose() { //NOOP } } }