C# 클래스 CefSharp.ResourceHandler

Default implementation of IResourceHandler. This latest implementation provides some simplification, at a minimum you only need to override ProcessRequestAsync. See the project source on GitHub for working examples. used to implement a custom request handler interface. The methods of this class will always be called on the IO thread. Static helper methods are included like FromStream and FromString that make dealing with fixed resources easy.
상속: IResourceHandler
파일 보기 프로젝트 열기: cefsharp/CefSharp 1 사용 예제들

공개 메소드들

메소드 설명
Cancel ( ) : void

Called if the request is cancelled

Dispose ( ) : void

Dispose of resources here

FromFilePath ( string fileName, string mimeType = null ) : ResourceHandler

Gets the resource from the file path specified. Use the ResourceHandler.GetMimeType helper method to lookup the mimeType if required.

FromStream ( Stream stream, string mimeType = DefaultMimeType ) : ResourceHandler

Gets the resource from a stream.

FromString ( string text, Encoding encoding = null, bool includePreamble = true, string mimeType = DefaultMimeType ) : ResourceHandler

Gets a ResourceHandler that represents a string. Without a Preamble, Cef will use BrowserSettings.DefaultEncoding to load the html.

FromString ( string text, string fileExtension ) : ResourceHandler

Gets the resource from the string.

GetMimeType ( string extension ) : string

Gets the MIME type of the content.

GetResponse ( IResponse response, long &responseLength, string &redirectUrl ) : Stream

Populate the response stream, response length. When this method is called the response should be fully populated with data. It is possible to redirect to another url at this point in time. NOTE: It's no longer manditory to implement this method, you can simply populate the properties of this instance and they will be set by the default implementation.

IResourceHandler ( ) : void
IResourceHandler ( IResponse response, long &responseLength, string &redirectUrl ) : void
ProcessRequestAsync ( IRequest request, ICallback callback ) : bool

Begin processing the request. If you have the data in memory you can execute the callback immediately and return true. For Async processing you would typically spawn a Task to perform processing, then return true. When the processing is complete execute callback.Continue(); In your processing Task, simply set the StatusCode, StatusText, MimeType, ResponseLength and Stream

ResourceHandler ( ) : System

Default Constructor

비공개 메소드들

메소드 설명
FromFileName ( string filePath, string fileExtension = null ) : ResourceHandler
GetStream ( string text, Encoding encoding, bool includePreamble ) : MemoryStream
IResourceHandler ( CefSharp.Cookie cookie ) : bool
IResourceHandler ( IRequest request, ICallback callback ) : bool
IResourceHandler ( Stream dataOut, int &bytesRead, ICallback callback ) : bool
ResourceHandler ( string mimeType, ResourceHandlerType type ) : System

Initializes a new instance of the ResourceHandler class.

메소드 상세

Cancel() 공개 메소드

Called if the request is cancelled
public Cancel ( ) : void
리턴 void

Dispose() 공개 메소드

Dispose of resources here
public Dispose ( ) : void
리턴 void

FromFilePath() 공개 정적인 메소드

Gets the resource from the file path specified. Use the ResourceHandler.GetMimeType helper method to lookup the mimeType if required.
public static FromFilePath ( string fileName, string mimeType = null ) : ResourceHandler
fileName string Location of the file.
mimeType string The mimeType if null then text/html is used.
리턴 ResourceHandler

FromStream() 공개 정적인 메소드

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.
리턴 ResourceHandler

FromString() 공개 정적인 메소드

Gets a ResourceHandler that represents a string. Without a Preamble, Cef will use BrowserSettings.DefaultEncoding to load the html.
public static FromString ( string text, Encoding encoding = null, bool includePreamble = true, string mimeType = DefaultMimeType ) : ResourceHandler
text string The html string
encoding System.Text.Encoding Character Encoding
includePreamble bool Include encoding preamble
mimeType string Mime Type
리턴 ResourceHandler

FromString() 공개 정적인 메소드

Gets the resource from the string.
public static FromString ( string text, string fileExtension ) : ResourceHandler
text string The text.
fileExtension string The file extension.
리턴 ResourceHandler

GetMimeType() 공개 정적인 메소드

Gets the MIME type of the content.
extension
public static GetMimeType ( string extension ) : string
extension string The extension.
리턴 string

GetResponse() 공개 메소드

Populate the response stream, response length. When this method is called the response should be fully populated with data. It is possible to redirect to another url at this point in time. NOTE: It's no longer manditory to implement this method, you can simply populate the properties of this instance and they will be set by the default implementation.
public GetResponse ( IResponse response, long &responseLength, string &redirectUrl ) : Stream
response IResponse The response object used to set Headers, StatusCode, etc
responseLength long length of the response
redirectUrl string If set the request will be redirect to specified Url
리턴 Stream

IResourceHandler() 공개 메소드

public IResourceHandler ( ) : void
리턴 void

IResourceHandler() 공개 메소드

public IResourceHandler ( IResponse response, long &responseLength, string &redirectUrl ) : void
response IResponse
responseLength long
redirectUrl string
리턴 void

ProcessRequestAsync() 공개 메소드

Begin processing the request. If you have the data in memory you can execute the callback immediately and return true. For Async processing you would typically spawn a Task to perform processing, then return true. When the processing is complete execute callback.Continue(); In your processing Task, simply set the StatusCode, StatusText, MimeType, ResponseLength and Stream
public ProcessRequestAsync ( IRequest request, ICallback callback ) : bool
request IRequest The request object.
callback ICallback The callback used to Continue or Cancel the request (async).
리턴 bool

ResourceHandler() 공개 메소드

Default Constructor
public ResourceHandler ( ) : System
리턴 System