Beispiel #1
0
        public virtual void InsertItemAtPipelineIndex(int index, PipelineItem <TDelegate> item, bool replaceInPlace = false)
        {
            var existingIndex = this.RemoveByName(item.Name);

            var newIndex = (replaceInPlace && existingIndex != -1) ? existingIndex : index;

            _pipelineItems.Insert(newIndex, item);
        }
Beispiel #2
0
        public virtual void InsertBefore(string name, PipelineItem <TDelegate> item)
        {
            var existingIndex = _pipelineItems.FindIndex(i => String.Equals(name, i.Name, StringComparison.Ordinal));

            if (existingIndex == -1)
            {
                existingIndex = 0;
            }

            this.InsertItemAtPipelineIndex(existingIndex, item);
        }
Beispiel #3
0
        public virtual void AddItemToEndOfPipeline(PipelineItem <TDelegate> item, bool replaceInPlace = false)
        {
            var existingIndex = this.RemoveByName(item.Name);

            if (replaceInPlace && existingIndex != -1)
            {
                this.InsertItemAtPipelineIndex(existingIndex, item);
            }
            else
            {
                _pipelineItems.Add(item);
            }
        }
Beispiel #4
0
        public virtual void InsertAfter(string name, PipelineItem <TDelegate> item)
        {
            var existingIndex = _pipelineItems.FindIndex(i => String.Equals(name, i.Name, StringComparison.Ordinal));

            if (existingIndex == -1)
            {
                existingIndex = _pipelineItems.Count;
            }

            existingIndex++;

            if (existingIndex > _pipelineItems.Count)
            {
                this.AddItemToEndOfPipeline(item);
            }
            else
            {
                this.InsertItemAtPipelineIndex(existingIndex, item);
            }
        }
Beispiel #5
0
 protected override PipelineItem <Func <Context, CancellationToken, Task <Response> > > Wrap(PipelineItem <Func <Context, Response> > pipelineItem)
 {
     return(new PipelineItem <Func <Context, CancellationToken, Task <Response> > >(pipelineItem.Name, (ctx, ct) => Task.FromResult(pipelineItem.Delegate(ctx))));
 }
Beispiel #6
0
 public virtual void AddItemToStartOfPipeline(PipelineItem <TDelegate> item, bool replaceInPlace = false)
 {
     this.InsertItemAtPipelineIndex(0, item, replaceInPlace);
 }
Beispiel #7
0
 public virtual void InsertItemAtPipelineIndex(int index, PipelineItem <TSyncDelegate> item, bool replaceInPlace = false)
 {
     this.InsertItemAtPipelineIndex(index, this.Wrap(item), replaceInPlace);
 }
Beispiel #8
0
 public virtual void AddItemToEndOfPipeline(PipelineItem <TSyncDelegate> item, bool replaceInPlace = false)
 {
     this.AddItemToEndOfPipeline(this.Wrap(item), replaceInPlace);
 }
Beispiel #9
0
 protected abstract PipelineItem <TAsyncDelegate> Wrap(PipelineItem <TSyncDelegate> syncDelegate);
Beispiel #10
0
 public virtual void InsertAfter(string name, PipelineItem <TSyncDelegate> item)
 {
     this.InsertAfter(name, this.Wrap(item));
 }
Beispiel #11
0
 protected override PipelineItem <Func <Context, CancellationToken, Task> > Wrap(PipelineItem <Action <Context> > pipelineItem)
 {
     return(new PipelineItem <Func <Context, CancellationToken, Task> >(pipelineItem.Name, (ctx, ct) =>
     {
         pipelineItem.Delegate(ctx);
         return Task.FromResult <object>(null);
     }));
 }