public void SetSuccessor(IRegistrationLinkHandler handler)
 {
     if (handler == null)
     {
         throw new ArgumentNullException(nameof(handler));
     }
     _successor = handler;
 }
Exemplo n.º 2
0
 public LinkFactory(
     ILinkBuilderFactory linkBuilderFactory,
     IAuthorizationProvider authorizationProvider,
     IArgumentProcessor idFromExpressionProcessor,
     IArgumentProcessor argumentsDefinitionsProcessor,
     IArgumentProcessor templateArgumentsProcessor,
     params IRegistrationLinkHandler[] handlers)
 {
     _linkBuilderFactory            = linkBuilderFactory;
     _authorizationProvider         = authorizationProvider;
     _idFromExpressionProcessor     = idFromExpressionProcessor;
     _argumentsDefinitionsProcessor = argumentsDefinitionsProcessor;
     _templateArgumentsProcessor    = templateArgumentsProcessor;
     _handlerChain = (handlers.Length > 0 ? handlers : DefaultHandlers).CreateChain();
 }
        public static IRegistrationLinkHandler CreateChain(this System.Collections.Generic.IEnumerable <IRegistrationLinkHandler> source)
        {
            IRegistrationLinkHandler root        = null;
            IRegistrationLinkHandler predecessor = null;

            foreach (var handler in source)
            {
                // set root
                if (root == null)
                {
                    root = handler;
                }

                // set successor (if predecessor)
                predecessor?.SetSuccessor(handler);

                // set next predecessor
                predecessor = handler;
            }

            return(root);
        }