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)); }
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); }
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)); }
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; }); }
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); }); }
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"); }
public void AttachBackbone(string iface_name, IBackbone backbone) { if (iface_name == null || backbone == null) throw new ArgumentNullException (); // todo }
/// <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); }
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)); }
public void AttachBackbone(string iface_name, IBackbone backbone) { }
/// <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; }
/// <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; }
public void SetBackbone(IBackbone backbone) { }
public Task <TRes> Process(TMessage message, IBackbone <TRes, TTProgress> backbone, IProgress <TTProgress> progress, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); return(_Finalizer.Process(message, progress, cancellationToken)); }
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; }
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); }