mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Adding reference source for System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Entity.Design System.Data.Linq System.Data.SqlXml System.ServiceModel System.ServiceModel.Activation System.ServiceModel.Activities System.ServiceModel.Channels System.ServiceModel.Discovery System.ServiceModel.Internals System.ServiceModel.Routing System.ServiceModel.WasHosting System.ServiceModel.Web System.Web System.Web.ApplicationServices System.Web.DynamicData System.Web.Entity System.Web.Entity.Design System.Web.Extensions System.Web.Mobile System.Web.Routing System.Web.Services System.Xml System.Xml.Linq
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
//------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//------------------------------------------------------------
|
|
namespace System.ServiceModel.Channels
|
|
{
|
|
using System.IO;
|
|
using System.Runtime;
|
|
|
|
// Enforces an overall timeout based on the TimeoutHelper passed in
|
|
class TimeoutStream : DelegatingStream
|
|
{
|
|
TimeoutHelper timeoutHelper;
|
|
public TimeoutStream(Stream stream, ref TimeoutHelper timeoutHelper)
|
|
: base(stream)
|
|
{
|
|
if (!stream.CanTimeout)
|
|
{
|
|
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("stream", SR.GetString(SR.StreamDoesNotSupportTimeout));
|
|
}
|
|
|
|
this.timeoutHelper = timeoutHelper;
|
|
}
|
|
|
|
void UpdateReadTimeout()
|
|
{
|
|
this.ReadTimeout = TimeoutHelper.ToMilliseconds(this.timeoutHelper.RemainingTime());
|
|
}
|
|
|
|
void UpdateWriteTimeout()
|
|
{
|
|
this.WriteTimeout = TimeoutHelper.ToMilliseconds(this.timeoutHelper.RemainingTime());
|
|
}
|
|
|
|
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
|
{
|
|
UpdateReadTimeout();
|
|
return base.BeginRead(buffer, offset, count, callback, state);
|
|
}
|
|
|
|
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
|
|
{
|
|
UpdateWriteTimeout();
|
|
return base.BeginWrite(buffer, offset, count, callback, state);
|
|
}
|
|
|
|
public override int Read(byte[] buffer, int offset, int count)
|
|
{
|
|
UpdateReadTimeout();
|
|
return base.Read(buffer, offset, count);
|
|
}
|
|
|
|
public override int ReadByte()
|
|
{
|
|
UpdateReadTimeout();
|
|
return base.ReadByte();
|
|
}
|
|
|
|
public override void Write(byte[] buffer, int offset, int count)
|
|
{
|
|
UpdateWriteTimeout();
|
|
base.Write(buffer, offset, count);
|
|
}
|
|
|
|
public override void WriteByte(byte value)
|
|
{
|
|
UpdateWriteTimeout();
|
|
base.WriteByte(value);
|
|
}
|
|
}
|
|
}
|