Exemplo n.º 1
0
        /// <inheritdoc />
        public bool MoveNext()
        {
            var next = _current.Next;

            _current = next is IPredecessor <TPayload> predecessor
                ? predecessor
                : LinkPredecessorDecorator <TPayload> .Decorate(next, new EndLink <TPayload>(next));

            return(!(next is EndLink <TPayload>));
        }
Exemplo n.º 2
0
        public PrimerLink(ILink <TPayload> firstValue)
        {
            var predecessor   = firstValue as IPredecessor <TPayload>;
            var isPredecessor = predecessor != null;

            var successor   = firstValue as ISuccessor <TPayload>;
            var isSuccessor = successor != null;

            if (isPredecessor && isSuccessor)
            {
                Previous = predecessor;
                Next     = successor;
            }
            else if (isSuccessor)
            {
                var endLink = new EndLink <TPayload>(new LazySuccessorProxy <TPayload>(() => Next));
                var primer  = LinkPredecessorDecorator <TPayload> .Decorate(successor, endLink);

                Previous = primer;
                Next     = primer;
            }
            else if (isPredecessor)
            {
                var startLink = new StartLink <TPayload>(new LazyPredecessorProxy <TPayload>(() => Previous));
                var primer    = LinkSuccessorDecorator <TPayload> .Decorate(predecessor, startLink);

                Previous = primer;
                Next     = primer;
            }
            else
            {
                var startLink = new StartLink <TPayload>(new LazyPredecessorProxy <TPayload>(() => Previous));
                var endLink   = new EndLink <TPayload>(new LazySuccessorProxy <TPayload>(() => Next));

                Previous = LinkPredecessorDecorator <TPayload> .Decorate(firstValue, endLink);

                Next = LinkSuccessorDecorator <TPayload> .Decorate(firstValue, startLink);
            }
        }
Exemplo n.º 3
0
 public EndLink(ISuccessor <TPayload> previous)
 {
     Previous = LinkPredecessorDecorator <TPayload> .Decorate(previous, this);
 }