Пример #1
0
 /// <summary>
 /// Create An Engine
 /// </summary>
 /// <param name="recordCopierFactory">Factory to create copiers</param>
 /// <param name="inputPropertyFactory">Factory to create input properties</param>
 internal Engine(IRecordCopierFactory recordCopierFactory, IInputPropertyFactory inputPropertyFactory)
     : base(recordCopierFactory)
 {
     this.Input               = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
     this.Input.InitCalled   += (sender, args) => args.Success = this.InitFunc(this.Input.RecordInfo);
     this.Input.RecordPushed += (sender, args) => args.Success = this.PushFunc(args.RecordData);
     this.Input.Closed       += (sender, args) => this.ClosedAction();
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NumberParserEngine"/> class.
 /// Create An NumberParserEngine for unit testing.
 /// </summary>
 /// <param name="recordCopierFactory">Factory to create copiers</param>
 /// <param name="inputPropertyFactory">Factory to create input properties</param>
 /// <param name="outputHelperFactory">Factory to create output helpers</param>
 internal NumberParserEngine(
     IRecordCopierFactory recordCopierFactory,
     IInputPropertyFactory inputPropertyFactory,
     IOutputHelperFactory outputHelperFactory)
     : base(recordCopierFactory, outputHelperFactory)
 {
     this.Input                  = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
     this.Input.InitCalled      += this.OnInit;
     this.Input.ProgressUpdated += (sender, args) => this.Output?.UpdateProgress(args.Progress, true);
     this.Input.RecordPushed    += this.OnRecordPushed;
     this.Input.Closed          += sender => this.Output?.Close(true);
 }
Пример #3
0
 /// <summary>
 /// Create An Engine
 /// </summary>
 /// <param name="recordCopierFactory">Factory to create copiers</param>
 /// <param name="inputPropertyFactory">Factory to create input properties</param>
 internal Engine(IRecordCopierFactory recordCopierFactory, IInputPropertyFactory inputPropertyFactory)
     : base(recordCopierFactory)
 {
     this.Input                  = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
     this.Input.InitCalled      += (sender, args) => args.Success = this.InitFunc(this.Input.RecordInfo);
     this.Input.ProgressUpdated += (sender, args) => this.Output?.UpdateProgress(args.Progress, true);
     this.Input.RecordPushed    += (sender, args) => args.Success = this.PushFunc(args.RecordData);
     this.Input.Closed          += (sender, args) =>
     {
         this.Output?.Close(true);
         this._nextValue = null;
     };
 }
Пример #4
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="CircuitBreakerEngine" /> class.
        ///     Create An Engine for unit testing.
        /// </summary>
        /// <param name="recordCopierFactory">Factory to create copiers</param>
        /// <param name="inputPropertyFactory">Factory to create input properties</param>
        /// <param name="outputHelperFactory">Factory to create output helpers</param>
        internal CircuitBreakerEngine(
            IRecordCopierFactory recordCopierFactory,
            IInputPropertyFactory inputPropertyFactory,
            IOutputHelperFactory outputHelperFactory)
            : base(recordCopierFactory, outputHelperFactory)
        {
            // Handle Breaker Connection
            this.Breaker               = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
            this.Breaker.InitCalled   += (property, args) => this._failed = false;
            this.Breaker.RecordPushed += this.BreakerOnRecordPushed;
            this.Breaker.Closed       += this.BreakerOnClosed;

            // Handle Input Connection
            this.Input                  = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
            this.Input.InitCalled      += this.InputOnInitCalled;
            this.Input.RecordPushed    += this.InputOnRecordPushed;
            this.Input.ProgressUpdated += (sender, args) => this.Output?.UpdateProgress(
                this._failed ? 1.0 : args.Progress,
                true);
            this.Input.Closed += this.InputOnClosed;
        }
Пример #5
0
            /// <summary>
            /// Create An Engine
            /// </summary>
            /// <param name="recordCopierFactory">Factory to create copiers</param>
            /// <param name="inputPropertyFactory">Factory to create input properties</param>
            internal Engine(IRecordCopierFactory recordCopierFactory, IInputPropertyFactory inputPropertyFactory)
                : base(recordCopierFactory)
            {
                this.Breaker               = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
                this.Breaker.InitCalled   += (property, args) => this._failed = false;
                this.Breaker.RecordPushed += (sender, args) =>
                {
                    if (this._failed)
                    {
                        args.Success = false;
                        return;
                    }

                    this._failed = true;
                    this.ExecutionComplete();
                };
                this.Breaker.Closed += (sender, args) =>
                {
                    if (!this._failed)
                    {
                        while ((this._inputRecords?.Count ?? 0) > 0)
                        {
                            var record = this._inputRecords?.Dequeue();
                            this.Output?.Push(record);
                        }
                    }

                    if (this.Input.State == ConnectionState.Closed)
                    {
                        this.Output?.Close(true);
                    }
                };

                this.Input             = inputPropertyFactory.Build(recordCopierFactory, this.ShowDebugMessages);
                this.Input.InitCalled += (property, args) =>
                {
                    this._inputRecords = new Queue <AlteryxRecordInfoNet.Record>();
                    this.Output?.Init(this.Input.RecordInfo);
                };
                this.Input.ProgressUpdated += (sender, args) => this.Output?.UpdateProgress(this._failed ? 1.0 : args.Progress, true);
                this.Input.RecordPushed    += (sender, args) =>
                {
                    if (this._failed)
                    {
                        args.Success = false;
                        return;
                    }

                    var record = this.Input.RecordInfo.CreateRecord();
                    this.Input.Copier.Copy(record, args.RecordData);

                    if (this.Breaker.State == ConnectionState.Closed)
                    {
                        this.Output?.Push(record);
                    }
                    else
                    {
                        this._inputRecords.Enqueue(record);
                    }
                };
                this.Input.Closed += (sender, args) =>
                {
                    if (this.Breaker.State == ConnectionState.Closed)
                    {
                        this.Output?.Close(true);
                    }
                };
            }