/// <summary> /// Registers new URL protocol handler. /// </summary> /// <param name="protocol">URL protocol.</param> /// <param name="friendlyName">Friendly name of URL protocol.</param> /// <param name="handler">Delegate that uses as protocol handler for processing requested urls.</param> /// <param name="makeDefaultHandler">Delegate that is invoked when protocol is set as default.</param> public void RegisterProtocolHandler(string protocol, string friendlyName, ProtocolHandlerCallback handler, MethodInvoker makeDefaultHandler) { RegisterProtocolHandler(protocol, friendlyName, handler); Guard.NullArgument(makeDefaultHandler, "makeDefaultHandler"); lock ( _makeDefaultHandler ) { _makeDefaultHandler[protocol] = makeDefaultHandler; } }
/// <summary> /// Registers new URL protocol handler. /// </summary> /// <param name="protocol">URL protocol.</param> /// <param name="friendlyName">Friendly name of URL protocol.</param> /// <param name="handler">Delegate that uses as protocol handler for processing requested urls.</param> public void RegisterProtocolHandler(string protocol, string friendlyName, ProtocolHandlerCallback handler) { CheckParameters(protocol, friendlyName, handler); lock ( _handlers ) { _handlers[protocol] = new ProtocolHandler(protocol, friendlyName, handler); SaveProtocolSettings(protocol, friendlyName, Default.NoChanges); } }
private static void CheckParameters(string protocol, string friendlyName, ProtocolHandlerCallback handler) { Guard.NullArgument(protocol, "protocol"); Guard.NullArgument(friendlyName, "friendlyName"); Guard.NullArgument(handler, "handler"); if (protocol.Length == 0) { throw new ArgumentException("Zero length for protocol name", "protocol"); } if (protocol.IndexOf(':') != -1) { throw new ArgumentException("Protocol name must not include ':' symbol", "protocol"); } }
public MockPlugin() { Callback = ProtocolHandler; MakeDefaultCallback = MakeDefault; CallbackWithException = ProtocolHandlerWithException; }
public ProtocolHandler(string protocol, string friendlyName, ProtocolHandlerCallback handler) { _protocol = protocol; _friendlyName = friendlyName; _handler = handler; }