Ejemplo n.º 1
0
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept)
        {
            // TODO:
            // After reviewing all the code path, oldStreamname shouldn't be Null or Empty.  It actually
            // doesnt' make much sense if we're asked to intercept an null or empty stream.
            // However, since we're shipping Whidbey RC soon it is too risky to remove that code.
            // But I'll add Debug.Assert(!String.IsNullOrEmpty(oldStreamname)) to make sure my
            // analysis is correct.
            Debug.Assert(!string.IsNullOrEmpty(oldStreamname));

            if (string.IsNullOrEmpty(oldStreamname))
            {
                return;
            }

            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname))
            {
                return;
            }

            if (_streams == null)
            {
                _streams = new HybridDictionary(true);
            }

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
Ejemplo n.º 2
0
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept)
        {
            //



            Debug.Assert(!String.IsNullOrEmpty(oldStreamname));

            if (String.IsNullOrEmpty(oldStreamname))
            {
                return;
            }

            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname))
            {
                return;
            }

            if (_streams == null)
            {
                _streams = new HybridDictionary(true);
            }

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
Ejemplo n.º 3
0
        public override Stream OpenStreamForRead(string streamName)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, false);

            return(streamUpdate != null
                ? InternalConfigHost.StaticOpenStreamForRead(streamUpdate.NewStreamname)
                : Host.OpenStreamForRead(streamName));
        }
Ejemplo n.º 4
0
        public override bool IsFile(string streamName)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, false);

            return(streamUpdate != null
                ? InternalConfigHost.StaticIsFile(streamUpdate.NewStreamname)
                : Host.IsFile(streamName));
        }
Ejemplo n.º 5
0
        public override object GetStreamVersion(string streamName)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, false);

            return(streamUpdate != null
                ? InternalConfigHost.StaticGetStreamVersion(streamUpdate.NewStreamname)
                : Host.GetStreamVersion(streamName));
        }
        public override Stream OpenStreamForRead(string streamName)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(streamName, false);

            if (streamUpdate != null)
            {
                return(InternalConfigHost.StaticOpenStreamForRead(streamUpdate.NewStreamname));
            }
            return(base.Host.OpenStreamForRead(streamName));
        }
        public override bool IsFile(string streamName)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(streamName, false);

            if (streamUpdate != null)
            {
                return(InternalConfigHost.StaticIsFile(streamUpdate.NewStreamname));
            }
            return(base.Host.IsFile(streamName));
        }
        public override object GetStreamVersion(string streamName)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(streamName, false);

            if (streamUpdate != null)
            {
                return(InternalConfigHost.StaticGetStreamVersion(streamUpdate.NewStreamname));
            }
            return(base.Host.GetStreamVersion(streamName));
        }
        internal string GetNewStreamname(string oldStreamname)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(oldStreamname, false);

            if (streamUpdate != null)
            {
                return(streamUpdate.NewStreamname);
            }
            return(oldStreamname);
        }
        public override Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(streamName, true);

            if (streamUpdate != null)
            {
                return(InternalConfigHost.StaticOpenStreamForWrite(streamUpdate.NewStreamname, templateStreamName, ref writeContext, false));
            }
            return(base.Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext));
        }
Ejemplo n.º 11
0
        public override Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext)
        {
            // Always attempt to write to the new stream name if it exists.
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, true);

            if (streamUpdate != null)
            {
                return(InternalConfigHost.StaticOpenStreamForWrite(
                           streamUpdate.NewStreamname, templateStreamName, ref writeContext));
            }
            return(Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext));
        }
Ejemplo n.º 12
0
        public override void DeleteStream(string streamName)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, false);

            if (streamUpdate != null)
            {
                InternalConfigHost.StaticDeleteStream(streamUpdate.NewStreamname);
            }
            else
            {
                Host.DeleteStream(streamName);
            }
        }
Ejemplo n.º 13
0
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept)
        {
            // After reviewing all the code paths, oldStreamname shouldn't be Null or Empty.
            // It actually doesn't make much sense if we're asked to intercept an null or empty stream.
            Debug.Assert(!string.IsNullOrEmpty(oldStreamname));

            if (string.IsNullOrEmpty(oldStreamname)) return;

            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname)) return;

            if (_streams == null) _streams = new HybridDictionary(true);

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
        private StreamUpdate GetStreamUpdate(string oldStreamname, bool alwaysIntercept)
        {
            if (this._streams == null)
            {
                return(null);
            }
            StreamUpdate update = (StreamUpdate)this._streams[oldStreamname];

            if (((update != null) && !alwaysIntercept) && !update.WriteCompleted)
            {
                update = null;
            }
            return(update);
        }
Ejemplo n.º 15
0
        //
        // Get the StreamUpdate for a stream.
        // If alwaysIntercept is true, then the StreamUpdate is
        // always returned if it exists.
        // If alwaysIntercept is false, then only return the StreamUpdate
        // if the new stream has been successfully written to.
        //
        private StreamUpdate GetStreamUpdate(string oldStreamname, bool alwaysIntercept)
        {
            if (_streams == null)
            {
                return(null);
            }

            StreamUpdate streamUpdate = (StreamUpdate)_streams[oldStreamname];

            if (streamUpdate != null && !alwaysIntercept && !streamUpdate.WriteCompleted)
            {
                streamUpdate = null;
            }

            return(streamUpdate);
        }
        public override void WriteCompleted(string streamName, bool success, object writeContext)
        {
            StreamUpdate streamUpdate = this.GetStreamUpdate(streamName, true);

            if (streamUpdate != null)
            {
                InternalConfigHost.StaticWriteCompleted(streamUpdate.NewStreamname, success, writeContext, false);
                if (success)
                {
                    streamUpdate.WriteCompleted = true;
                }
            }
            else
            {
                base.Host.WriteCompleted(streamName, success, writeContext);
            }
        }
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept) {
            Debug.Assert(!String.IsNullOrEmpty(oldStreamname));
            
            if (String.IsNullOrEmpty(oldStreamname)) {
                return;
            }
            
            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname)) {
                return;
            }

            if (_streams == null) {
                _streams = new HybridDictionary(true);
            }

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
Ejemplo n.º 18
0
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept)
        {
            // TODO:
            // After reviewing all the code path, oldStreamname shouldn't be Null or Empty.  It actually
            // doesnt' make much sense if we're asked to intercept an null or empty stream.
            // However, since we're shipping Whidbey RC soon it is too risky to remove that code.
            // But I'll add Debug.Assert(!String.IsNullOrEmpty(oldStreamname)) to make sure my
            // analysis is correct.
            Debug.Assert(!string.IsNullOrEmpty(oldStreamname));

            if (string.IsNullOrEmpty(oldStreamname)) return;

            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname)) return;

            if (_streams == null) _streams = new HybridDictionary(true);

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
Ejemplo n.º 19
0
        // Add a stream to the list of streams to intercept.
        //
        // Parameters:
        //  alwaysIntercept -   If true, then don't check whether the old stream and the new stream are the same.
        //                      SaveAs() will set this to true if oldStreamname is actually referring to a stream
        //                      on a remote machine.
        internal void AddStreamname(string oldStreamname, string newStreamname, bool alwaysIntercept)
        {
            // After reviewing all the code paths, oldStreamname shouldn't be Null or Empty.
            // It actually doesn't make much sense if we're asked to intercept an null or empty stream.
            Debug.Assert(!string.IsNullOrEmpty(oldStreamname));

            if (string.IsNullOrEmpty(oldStreamname))
            {
                return;
            }

            if (!alwaysIntercept && StringUtil.EqualsIgnoreCase(oldStreamname, newStreamname))
            {
                return;
            }

            _streams ??= new HybridDictionary(true);

            _streams[oldStreamname] = new StreamUpdate(newStreamname);
        }
Ejemplo n.º 20
0
        public override void WriteCompleted(string streamName, bool success, object writeContext)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(streamName, true);

            if (streamUpdate != null)
            {
                InternalConfigHost.StaticWriteCompleted(streamUpdate.NewStreamname, success, writeContext);

                // Mark the write as having successfully completed, so that subsequent calls
                // to Read() will use the new stream name.
                if (success)
                {
                    streamUpdate.WriteCompleted = true;
                }
            }
            else
            {
                Host.WriteCompleted(streamName, success, writeContext);
            }
        }
Ejemplo n.º 21
0
        // Get the new stream name for a stream if a new name exists, otherwise
        // return the original stream name.
        internal string GetNewStreamname(string oldStreamname)
        {
            StreamUpdate streamUpdate = GetStreamUpdate(oldStreamname, false);

            return(streamUpdate != null ? streamUpdate.NewStreamname : oldStreamname);
        }