예제 #1
0
        public async Task <TRes> Process(TMessage1 message, IBackbone <TRes, TProgress> backbone, IProgress <TProgress> progress, CancellationToken cancelationToken)
        {
            cancelationToken.ThrowIfCancellationRequested();
            var message2 = await _Transformer.Transform(message, progress, cancelationToken);

            cancelationToken.ThrowIfCancellationRequested();
            return(await backbone.Process(message2, progress, cancelationToken));
        }
예제 #2
0
        public CreatingPipeline()
        {
            var builder = new BackBoneBuilder <bool, int>();

            builder.Register(new Transformer());
            builder.Register(new Parser());
            builder.Register(new Counter());
            _BackBone = builder.GetBackBone();
        }
        /// <inheritdoc />
        public NetworkEntity AddBackbone(IBackbone backbone)
        {
            if (this.backbones.Values.Contains (backbone))
                throw new NetworkContainsBackboneException (backbone.Name);

            var id = this.id_backbones.GetNext ();
            this.backbones.Add (id, backbone);
            return new NetworkEntity (id);
        }
예제 #4
0
            public async Task <bool> Process(string message, IBackbone <bool, int> backbone, IProgress <int> progress, CancellationToken cancelationToken)
            {
                if (!int.TryParse(message, out var res))
                {
                    return(false);
                }

                return(await backbone.Process(res, progress, cancelationToken));
            }
예제 #5
0
 public NetworkEntity AddBackbone(IBackbone backbone)
 {
     Contract.Requires <ArgumentNullException> (backbone != null);
     Contract.Ensures (Contract.Result <NetworkEntity> () != null);
     Contract.Ensures (Contract.Exists (this.Backbones, b => b == backbone));
     Contract.EnsuresOnThrow <NetworkContainsBackboneException> (Contract.Exists (this.Backbones,
                                                                                  b => b == backbone));
     return default (NetworkEntity);
 }
 public TransformerProcessorAdapterTest()
 {
     _Transform = Substitute.For <ITransformProcessor <double, string, int> >();
     _Transform.Transform(Arg.Any <double>(), Arg.Any <IProgress <int> >(), Arg.Any <CancellationToken>())
     .Returns(x => Task.FromResult(string.Format("{0}", (double)x[0])));
     _BackBone = Substitute.For <IBackbone <bool, int> >();
     _Progess  = Substitute.For <IProgress <int> >();
     _CancellationTokenSource     = new CancellationTokenSource();
     _TransformerProcessorAdapter = new TransformerProcessorAdapter <bool, double, string, int>(_Transform);
 }
 public TransformerProcessorAdapterTest()
 {
     _Transform = Substitute.For<ITransformProcessor<double, string, int>>();
     _Transform.Transform(Arg.Any<double>(), Arg.Any<IProgress<int>>(), Arg.Any<CancellationToken>())
               .Returns(x => Task.FromResult(string.Format("{0}", (double)x[0])));
     _BackBone = Substitute.For<IBackbone<bool, int>>();
     _Progess = Substitute.For<IProgress<int>>();
     _CancellationTokenSource = new CancellationTokenSource();
     _TransformerProcessorAdapter = new TransformerProcessorAdapter<bool, double, string, int>(_Transform);
 }
 public BackBoneBuilderTest()
 {
     _Processors = new Dictionary<Type, object>();
     _Processor = Substitute.For<IProcessor<bool, string, int>>();
     _Transformer = Substitute.For<ITransformProcessor<bool, string, int>>();
     _IProcessorFinalizer = Substitute.For<IProcessorFinalizer<bool, int, int>> ();
     _BackBone = Substitute.For<IBackbone<bool, int>>();
     _Progress = Substitute.For<IProgress<int>>();
     _Builder = new BackBoneBuilder<bool, int>(dic =>
     {
         _Processors = dic;
         return null;
     });
 }
예제 #9
0
 public BackBoneBuilderTest()
 {
     _Processors          = new Dictionary <Type, object>();
     _Processor           = Substitute.For <IProcessor <bool, string, int> >();
     _Transformer         = Substitute.For <ITransformProcessor <bool, string, int> >();
     _IProcessorFinalizer = Substitute.For <IProcessorFinalizer <bool, int, int> > ();
     _BackBone            = Substitute.For <IBackbone <bool, int> >();
     _Progress            = Substitute.For <IProgress <int> >();
     _Builder             = new BackBoneBuilder <bool, int>(dic =>
     {
         _Processors = dic;
         return(null);
     });
 }
예제 #10
0
 public BackBoneTest()
 {
     _CancellationToken = new CancellationToken();
     _StringProcessor   = Substitute.For <IProcessor <bool, string, int> >();
     _IntProcessor      = Substitute.For <IProcessor <bool, int, int> >();
     _Progess           = Substitute.For <IProgress <int> >();
     _ObservableHelper  = new ObservableHelper();
     _Processors        = new Dictionary <Type, object>()
     {
         { typeof(string), _StringProcessor },
         { typeof(int), _IntProcessor }
     };
     _BackBone    = new BackBone <bool, int>(_Processors);
     _SingleValue = Observable.Return("Value");
 }
예제 #11
0
        public void AttachBackbone(string iface_name, IBackbone backbone)
        {
            if (iface_name == null || backbone == null)
                throw new ArgumentNullException ();

            // todo
        }
예제 #12
0
        /// <inheritdoc />
        public void AttachBackbone(string iface_name, IBackbone backbone)
        {
            if (!this.interfaces.ContainsKey (iface_name))
                throw new InterfaceNotFoundException (iface_name, this.Name);

            var iface = this.interfaces [iface_name];
            if (iface.Backbone != null)
                throw new InterfaceAlreadyAttachedToBackboneException (iface_name);

            iface.SetBackbone (backbone);
        }
예제 #13
0
 public void AttachBackbone(string iface_name, IBackbone backbone)
 {
     Contract.Requires <ArgumentNullException> (iface_name != null && backbone != null);
     Contract.EnsuresOnThrow <InterfaceNotFoundException> (Contract.ForAll (this.Interfaces,
                                                                            i => i.Name != iface_name));
 }
예제 #14
0
 public void AttachBackbone(string iface_name, IBackbone backbone)
 {
 }
예제 #15
0
        /// <inheritdoc />
        public virtual void SetBackbone(IBackbone backbone)
        {
            if (this.Backbone != null)
                throw new InterfaceAlreadyAttachedToBackboneException (this.Name);

            if (! this.IsCompatibleWith (backbone))
                throw new InterfaceNotCompatibleWithBackboneException (this.Name, backbone.Name);

            if (this.OnBeforeAttachBackbone != null) {
                try {
                    this.OnBeforeAttachBackbone.Invoke (this, backbone);
                }
                catch {}
            }

            backbone.AttachEndPoint (this);
            this._backbone = backbone;
        }
예제 #16
0
        /// <inheritdoc />
        public virtual void ReleaseBackbone()
        {
            if (this._backbone == null)
                throw new InterfaceNotAttachedToBackboneException (this.Name);

            if (this.OnBeforeDetachBackbone != null) {
                try {
                    this.OnBeforeDetachBackbone.Invoke (this);
                }
                catch {}
            }

            this._backbone.DetachEndPoint (this);
            this._backbone = null;
        }
예제 #17
0
 public void SetBackbone(IBackbone backbone)
 {
 }
예제 #18
0
 public Task <TRes> Process(TMessage message, IBackbone <TRes, TTProgress> backbone, IProgress <TTProgress> progress, CancellationToken cancellationToken)
 {
     cancellationToken.ThrowIfCancellationRequested();
     return(_Finalizer.Process(message, progress, cancellationToken));
 }
예제 #19
0
        public void SetBackbone(IBackbone backbone)
        {
            if (backbone == null)
                throw new ArgumentNullException ();

            if (this.Backbone != null)
                throw new ArgumentException ();

            if (this.OnBeforeAttachBackbone != null)
                this.OnBeforeAttachBackbone.Invoke (this, backbone);

            backbone.AttachEndPoint (this);
            this.Backbone = backbone;
        }
예제 #20
0
 public void SetBackbone(IBackbone backbone)
 {
     Contract.Requires <ArgumentNullException> (backbone != null);
     Contract.Ensures (this.Backbone == backbone);
     Contract.Ensures (Contract.Exists (this.Backbone.EndPoints, i => i == this));
     Contract.EnsuresOnThrow <InterfaceAlreadyAttachedToBackboneException> (this.Backbone != null);
 }