예제 #1
0
파일: Stream.cs 프로젝트: ArtiDi/HTM.Net
 public Stream(IEnumerable <TModel> source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     _id              = StreamIdentifier.GeneralId++;
     _baseStream      = new StreamCollection <TModel>(_id, source, IncrementCurrentlyRead);
     _localEnumerator = _baseStream.GetEnumerator();
     _streamState     = new StreamState();
 }
예제 #2
0
파일: Stream.cs 프로젝트: ArtiDi/HTM.Net
 private Stream(IEnumerable <TModel> source, IStream parentStream)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     _parentStream = parentStream;
     _id           = StreamIdentifier.GeneralId++;
     if (source is StreamCollection <TModel> )
     {
         _baseStream = source as StreamCollection <TModel>;
         _baseStream.SetAfterReadAction(IncrementCurrentlyRead); // Update to right level
     }
     else
     {
         _baseStream = new StreamCollection <TModel>(_id, source, IncrementCurrentlyRead);
     }
     _localEnumerator = _baseStream.GetEnumerator();
     _streamState     = new StreamState();
 }
예제 #3
0
파일: Stream.cs 프로젝트: ArtiDi/HTM.Net
        public Stream(IObservable <TModel> input)
        {
            _id = StreamIdentifier.GeneralId++;
            LinkedList <TModel> obsContent = new LinkedList <TModel>();

            _baseStream      = new StreamCollection <TModel>(_id, obsContent, IncrementCurrentlyRead);
            _localEnumerator = _baseStream.GetEnumerator();
            _streamState     = new StreamState();
            _observableMode  = true;
            _streamState.ObservableSource = true;
            input.Subscribe(item =>
            {
                //Debug.WriteLine(String.Format("> {2} Adding item to local cache in stream: {0} - currently read: {1}",
                //    item, _currentlyRead, _id));
                lock (_streamState.SyncRoot)
                {
                    obsContent.AddLast(item);
                }
            }, () => { _streamState.IsTerminated = true; });
        }