Exemplo n.º 1
0
        public void Dispose()
        {
            var source = _source;
            var target = _target;

            _source = null;
            _target = null;
            source?.Dispose();
            target?.Dispose();
        }
Exemplo n.º 2
0
 public static IPipeElement <TContext, TInputForNextStep, TReturn> DoNext <TContext, TInput, TInputForNextStep, TReturn>(
     this IPipeElement <TContext, TInput, TInputForNextStep> element,
     ISyncStepProvider <TContext, TInputForNextStep, TReturn> provider)
     where TContext : PipeContext
 {
     return(new Element <TContext, TInputForNextStep, TReturn>(
                element.Context,
                element.PreviousElements.Append(element),
                provider));
 }
Exemplo n.º 3
0
        public static async Task CompleteWithAsync <TInput, TInputForNextStep>(
            this IPipeElement <TimerPipeContext, TInput, TInputForNextStep> element,
            IAsyncTimerStepProvider <TInputForNextStep?, bool> provider)
        {
            var finalStep = new FinalElement <TimerPipeContext, TInputForNextStep, bool>(
                element.Context,
                element.PreviousElements.Append(element),
                provider);

            await finalStep.CompletePipeAsync();
        }
Exemplo n.º 4
0
        public static async Task <IActionResult> CompleteWithAsync <TInput, TInputForNextStep>(
            this IPipeElement <HttpPipeContext, TInput, TInputForNextStep> element,
            IAsyncHttpStepProvider <TInputForNextStep?, IActionResult> provider)
        {
            var finalStep = new FinalElement <HttpPipeContext, TInputForNextStep, IActionResult>(
                element.Context,
                element.PreviousElements.Append(element),
                provider);

            return(await finalStep.CompletePipeAsync());
        }
Exemplo n.º 5
0
        public static async Task <TReturn> CompleteWithAsync <TInput, TInputForNextStep, TReturn>(
            this IPipeElement <PipeContext, TInput, TInputForNextStep> element,
            IAsyncActivityStepProvider <TInputForNextStep?, TReturn> provider)
        {
            var finalStep = new FinalElement <PipeContext, TInputForNextStep, TReturn>(
                element.Context,
                element.PreviousElements.Append(element),
                provider);

            return(await finalStep.CompletePipeAsync());
        }
Exemplo n.º 6
0
        public virtual void Dispose()
        {
            var source = _source;
            var sinks  = _sinks.ToArray();

            _source = null;
            _sinks.Clear();

            source?.Dispose();
            sinks.ForEach(s => s.Dispose());
        }
Exemplo n.º 7
0
        internal static async Task <TReturn> InternalCompleteWithAsync <TStepProvider, TContext, TInput, TInputForNextStep, TReturn>(
            this IPipeElement <TContext, TInput, TInputForNextStep> element)
            where TStepProvider : IAsyncStepProvider <TContext, TInputForNextStep, TReturn>
            where TContext : PipeContext
        {
            var finalStep = new FinalElement <TContext, TInputForNextStep, TReturn>(
                element.Context,
                element.PreviousElements.Append(element),
                element.Context.ServiceProvider.GetRequiredService <TStepProvider>());

            return(await finalStep.CompletePipeAsync());
        }
Exemplo n.º 8
0
 public static IPipeElement <TContext, TInputForNextStep, TReturn> DoNext <TContext, TInput, TInputForNextStep, TReturn>(
     this IPipeElement <TContext, TInput, TInputForNextStep> element,
     Func <TContext, TInputForNextStep, TReturn> inlineMethod)
     where TContext : PipeContext
 => element.DoNext(new SyncLambdaStepProvider <TContext, TInputForNextStep, TReturn>(inlineMethod));
Exemplo n.º 9
0
 public void Detach()
 {
     _source = null;
     _sinks.Clear();
 }
Exemplo n.º 10
0
 public void SetSource(IPipeElement source)
 {
     _source = source;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Grants given pipe to this achievement.
        /// </summary>
        /// <param name="pipe">The pipe to count achievement for.</param>
        public void Grant(IPipeElement pipe)
        {
            if (pipe != null)
            {
                /* get level service because achieved points are calculated on a per level basis. */
                ILevelService levels = this.GetLevelService();

                if (levels != null)
                {
                    /* add pipe */
                    this.Pipes++;

                    /* add points */
                    this.Points += levels.Current.GetAchievementPoints(this.Pipes, pipe.Type);
                }
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// Adds a pipe in queue.
 /// </summary>
 /// <param name="pipe">The pipe to add to queue.</param>
 public void Enqueue(IPipeElement pipe)
 {
     if (this.pipes.Count < this.capacity)
     {
         this.pipes.Enqueue(pipe);
         this.ExecuteCommand(PresentationCommands.PipeQueue.Enqueue, new PresentSquareParameter(pipe.Id, pipe.Type));
     }
 }