/// <summary>
        /// Registers custom handler.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <param name="implementation">
        /// The implementation.
        /// </param>
        /// <returns>
        /// The <see cref="ChromelyConfiguration"/> object.
        /// </returns>
        public virtual ChromelyConfiguration RegisterCustomHandler(CefHandlerKey key, Type implementation)
        {
            var service = CefHandlerFakeTypes.GetHandlerType(key);
            var keyStr  = key.EnumToString();

            IoC.RegisterPerRequest(service, keyStr, implementation);

            return(this);
        }
Example #2
0
        /// <summary>
        /// The register custom handler.
        /// The custom handler must be registered before calling "Run".
        /// Alternatively this can be done before window is created during ChromelyConfiguration instantiation.
        /// Only one type of custom handler can be registered. The first one is valid, consequent registrations will be ignored.
        /// </summary>
        /// <param name="key">
        /// The key.
        /// </param>
        /// <param name="implementation">
        /// The implementation.
        /// </param>
        public void RegisterCustomHandler(CefHandlerKey key, Type implementation)
        {
            if (_windowCreated)
            {
                throw new Exception("\"RegisterCustomHandler\" method must be called before \"Run\" method.");
            }

            HostConfig?.RegisterCustomHandler(key, implementation);
        }
Example #3
0
        public static Type GetHandlerType(CefHandlerKey key)
        {
            switch (key)
            {
            case CefHandlerKey.LifeSpanHandler:
                return(typeof(ILifeSpanHandler));

            case CefHandlerKey.LoadHandler:
                return(typeof(ILoadHandler));

            case CefHandlerKey.RequestHandler:
                return(typeof(IRequestHandler));

            case CefHandlerKey.DisplayHandler:
                return(typeof(IDisplayHandler));

            case CefHandlerKey.ContextMenuHandler:
                return(typeof(IContextMenuHandler));

            case CefHandlerKey.FocusHandler:
                return(typeof(IFocusHandler));

            case CefHandlerKey.KeyboardHandler:
                return(typeof(IKeyboardHandler));

            case CefHandlerKey.JSDialogHandler:
                return(typeof(IJSDialogHandler));

            case CefHandlerKey.DialogHandler:
                return(typeof(IDialogHandler));

            case CefHandlerKey.DragHandler:
                return(typeof(IDragHandler));

            case CefHandlerKey.GeolocationHandler:
                return(typeof(IGeolocationHandler));

            case CefHandlerKey.DownloadHandler:
                return(typeof(IDownloadHandler));

            case CefHandlerKey.FindHandler:
                return(typeof(IFindHandler));
            }

            return(null);
        }
Example #4
0
 public static string EnumToString(this CefHandlerKey key)
 {
     return(Enum.GetName(key.GetType(), key));
 }