Exemplo n.º 1
0
 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();
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
        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; });
        }