internal void RegisterHandler(IPrefixHandler handler) { if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var prefix = handler.Prefix; if (!prefix.StartsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("Invalid prefix; must start with /"); } if (!prefix.EndsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("Invalid prefix; must end with /"); } if (FindHandler(prefix) != null) { throw new ArgumentException("Invalid prefix; already taken"); } if (!prefixes.TryAdd(prefix, handler)) { throw new ArgumentException("Invalid preifx; already taken"); } DebugFormat("Registered Handler for {0}", prefix); }
internal void UnregisterHandler(IPrefixHandler handler) { IPrefixHandler ignored; if (prefixes.TryRemove(handler.Prefix, out ignored)) { DebugFormat("Unregistered Handler for {0}", handler.Prefix); } }
internal void UnregisterHandler(IPrefixHandler handler) { IPrefixHandler ignored; if (prefixes.TryRemove(handler.Prefix, out ignored)) { Logger.LogTrace($"Unregistered Handler for {handler.Prefix}"); } }
internal void RegisterHandler(IPrefixHandler handler) { if (handler == null) { throw new ArgumentNullException("handler"); } var prefix = handler.Prefix; if (!prefix.StartsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("Invalid prefix; must start with /"); } if (!prefix.EndsWith("/", StringComparison.Ordinal)) { throw new ArgumentException("Invalid prefix; must end with /"); } if (FindHandler(prefix) != null) { throw new ArgumentException("Invalid prefix; already taken"); } if (!prefixes.TryAdd(prefix, handler)) { throw new ArgumentException("Invalid preifx; already taken"); } DebugFormat("Registered Handler for {0}", prefix); }
public void PushPrefixHandler(IPrefixHandler prefixHandler) => m_PrefixHandlers.AddLast(prefixHandler ?? throw new ArgumentNullException(nameof(prefixHandler)));