Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWeb / Client / System / Data / Services / Client / WebUtil.cs / 2 / WebUtil.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// static utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System.Collections.Generic; using System.Diagnostics; using System.IO; #if !ASTORIA_LIGHT // Data.Services http stack using System.Net; #else using System.Data.Services.Http; #endif ///web utility functions internal static partial class WebUtil { ///copy from one stream to another /// input stream /// output stream /// reusable buffer ///count of copied bytes internal static long CopyStream(Stream input, Stream output, ref byte[] refBuffer) { Debug.Assert(null != input, "null input stream"); Debug.Assert(null != output, "null output stream"); long total = 0; byte[] buffer = refBuffer; if (null == buffer) { refBuffer = buffer = new byte[1000]; } int count = 0; while (input.CanRead && (0 < (count = input.Read(buffer, 0, buffer.Length)))) { output.Write(buffer, 0, count); total += count; } return total; } ///get response object from possible WebException /// exception to probe /// http web respose object from exception internal static void GetHttpWebResponse(InvalidOperationException exception, ref HttpWebResponse response) { if (null == response) { WebException webexception = (exception as WebException); if (null != webexception) { response = (HttpWebResponse)webexception.Response; } } } ///is this a success status code /// status code ///true if status is between 200-299 internal static bool SuccessStatusCode(HttpStatusCode status) { return (200 <= (int)status && (int)status < 300); } ////// turn the response object headers into a dictionary /// /// response ///dictionary internal static DictionaryWrapResponseHeaders(HttpWebResponse response) { Dictionary headers = new Dictionary (); if (null != response) { foreach (string name in response.Headers.AllKeys) { headers.Add(name, response.Headers[name]); } } return headers; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // //// static utility functions // //--------------------------------------------------------------------- namespace System.Data.Services.Client { using System.Collections.Generic; using System.Diagnostics; using System.IO; #if !ASTORIA_LIGHT // Data.Services http stack using System.Net; #else using System.Data.Services.Http; #endif ///web utility functions internal static partial class WebUtil { ///copy from one stream to another /// input stream /// output stream /// reusable buffer ///count of copied bytes internal static long CopyStream(Stream input, Stream output, ref byte[] refBuffer) { Debug.Assert(null != input, "null input stream"); Debug.Assert(null != output, "null output stream"); long total = 0; byte[] buffer = refBuffer; if (null == buffer) { refBuffer = buffer = new byte[1000]; } int count = 0; while (input.CanRead && (0 < (count = input.Read(buffer, 0, buffer.Length)))) { output.Write(buffer, 0, count); total += count; } return total; } ///get response object from possible WebException /// exception to probe /// http web respose object from exception internal static void GetHttpWebResponse(InvalidOperationException exception, ref HttpWebResponse response) { if (null == response) { WebException webexception = (exception as WebException); if (null != webexception) { response = (HttpWebResponse)webexception.Response; } } } ///is this a success status code /// status code ///true if status is between 200-299 internal static bool SuccessStatusCode(HttpStatusCode status) { return (200 <= (int)status && (int)status < 300); } ////// turn the response object headers into a dictionary /// /// response ///dictionary internal static DictionaryWrapResponseHeaders(HttpWebResponse response) { Dictionary headers = new Dictionary (); if (null != response) { foreach (string name in response.Headers.AllKeys) { headers.Add(name, response.Headers[name]); } } return headers; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- MemberHolder.cs
- Pair.cs
- NetCodeGroup.cs
- DateTimeParse.cs
- DataReaderContainer.cs
- SingleAnimationUsingKeyFrames.cs
- Privilege.cs
- EntityWithKeyStrategy.cs
- IISMapPath.cs
- BuildProviderCollection.cs
- EntityDataSourceContextDisposingEventArgs.cs
- XmlSchemaObjectTable.cs
- AnimatedTypeHelpers.cs
- ActivityCodeDomSerializer.cs
- RadioButtonList.cs
- RightsManagementEncryptionTransform.cs
- TranslateTransform.cs
- TextLine.cs
- LinkClickEvent.cs
- WindowsFormsHostAutomationPeer.cs
- UnsafeNativeMethods.cs
- ProfileSettingsCollection.cs
- SourceItem.cs
- UIElement3D.cs
- ReadWriteObjectLock.cs
- OperationParameterInfoCollection.cs
- WebServiceBindingAttribute.cs
- ADRole.cs
- StringAnimationBase.cs
- FileLevelControlBuilderAttribute.cs
- DataGridColumnCollection.cs
- Size3DConverter.cs
- IFormattable.cs
- IERequestCache.cs
- EntityTypeEmitter.cs
- TextOutput.cs
- ClientApiGenerator.cs
- ReflectionUtil.cs
- SqlBinder.cs
- RepeaterItemEventArgs.cs
- SecurityToken.cs
- MatrixCamera.cs
- TypeToken.cs
- SaveFileDialog.cs
- ChannelProtectionRequirements.cs
- ToolCreatedEventArgs.cs
- FreezableCollection.cs
- EntityDataSourceDesignerHelper.cs
- ScaleTransform.cs
- Types.cs
- NoPersistProperty.cs
- PointLightBase.cs
- Calendar.cs
- FormViewDeleteEventArgs.cs
- Root.cs
- configsystem.cs
- DesignColumnCollection.cs
- StylusEditingBehavior.cs
- PaginationProgressEventArgs.cs
- WorkflowOperationBehavior.cs
- PointAnimation.cs
- OutputChannel.cs
- FormViewPagerRow.cs
- CachedBitmap.cs
- ImageBrush.cs
- SqlBooleanizer.cs
- SectionUpdates.cs
- StateDesigner.Helpers.cs
- AppSettingsSection.cs
- ToolStripScrollButton.cs
- AccessorTable.cs
- DrawListViewColumnHeaderEventArgs.cs
- TemplateComponentConnector.cs
- DataGridViewButtonColumn.cs
- DependencyObjectType.cs
- FixedNode.cs
- DescendantOverDescendantQuery.cs
- Type.cs
- FactoryGenerator.cs
- StringFreezingAttribute.cs
- TypePropertyEditor.cs
- GuidelineSet.cs
- Command.cs
- KeyboardNavigation.cs
- DataProtection.cs
- ToolStripCustomTypeDescriptor.cs
- ReadContentAsBinaryHelper.cs
- InputLanguageEventArgs.cs
- MeasurementDCInfo.cs
- HttpRuntimeSection.cs
- System.Data_BID.cs
- WebContext.cs
- Vector3DAnimationUsingKeyFrames.cs
- TraceHelpers.cs
- SqlCacheDependency.cs
- DelegateCompletionCallbackWrapper.cs
- MobileControlsSection.cs
- ColumnMapProcessor.cs
- ValueConversionAttribute.cs
- DocumentSequenceHighlightLayer.cs