Пример #1
0
        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);
        }
Пример #2
0
        internal void UnregisterHandler(IPrefixHandler handler)
        {
            IPrefixHandler ignored;

            if (prefixes.TryRemove(handler.Prefix, out ignored))
            {
                DebugFormat("Unregistered Handler for {0}", handler.Prefix);
            }
        }
Пример #3
0
        internal void UnregisterHandler(IPrefixHandler handler)
        {
            IPrefixHandler ignored;

            if (prefixes.TryRemove(handler.Prefix, out ignored))
            {
                Logger.LogTrace($"Unregistered Handler for {handler.Prefix}");
            }
        }
Пример #4
0
 internal void UnregisterHandler(IPrefixHandler handler)
 {
   IPrefixHandler ignored;
   if (prefixes.TryRemove(handler.Prefix, out ignored)) {
     DebugFormat("Unregistered Handler for {0}", handler.Prefix);
   }
 }
Пример #5
0
 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);
 }
Пример #6
0
 public void PushPrefixHandler(IPrefixHandler prefixHandler) => m_PrefixHandlers.AddLast(prefixHandler ?? throw new ArgumentNullException(nameof(prefixHandler)));