Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / Mail / BufferBuilder.cs / 1 / BufferBuilder.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net { using System; using System.IO; using System.Globalization; internal class BufferBuilder { byte[] buffer; int offset; internal BufferBuilder() : this(256) { } internal BufferBuilder(int initialSize) { this.buffer = new byte[initialSize]; } void EnsureBuffer(int count) { if (count > this.buffer.Length - this.offset) { byte[] newBuffer = new byte[((buffer.Length * 2)>(buffer.Length + count))?(buffer.Length*2):(buffer.Length + count)]; Buffer.BlockCopy(this.buffer, 0, newBuffer, 0, this.offset); this.buffer = newBuffer; } } internal void Append(byte value) { EnsureBuffer(1); this.buffer[this.offset++] = value; } internal void Append(byte[] value) { Append(value, 0, value.Length); } internal void Append(byte[] value, int offset, int count) { EnsureBuffer(count); Buffer.BlockCopy(value, offset, this.buffer, this.offset, count); this.offset += count; } internal void Append(string value) { Append(value, 0, value.Length); } internal void Append(string value, int offset, int count) { EnsureBuffer(count); for (int i = 0; i < count; i++) { char c = value[offset+i]; if ((ushort)c > 0xFF) throw new FormatException(SR.GetString(SR.MailHeaderFieldInvalidCharacter)); this.buffer[this.offset + i] = (byte)c; } this.offset += count; } internal int Length { get { return this.offset; } } internal byte[] GetBuffer() { return this.buffer; } internal void Reset() { this.offset = 0; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RoleBoolean.cs
- XmlDownloadManager.cs
- WorkflowServiceNamespace.cs
- DbConnectionPoolIdentity.cs
- DetailsViewInsertedEventArgs.cs
- InternalConfigConfigurationFactory.cs
- PropertyMappingExceptionEventArgs.cs
- WebPartZoneDesigner.cs
- EmptyControlCollection.cs
- TypeElement.cs
- UrlEncodedParameterWriter.cs
- DuplexChannel.cs
- AutomationElement.cs
- CodeDirectionExpression.cs
- StrongNameIdentityPermission.cs
- TreeView.cs
- FocusWithinProperty.cs
- ToolStripDesignerAvailabilityAttribute.cs
- GridToolTip.cs
- TreeIterator.cs
- SystemIPv6InterfaceProperties.cs
- CodeVariableDeclarationStatement.cs
- SafePointer.cs
- SafeNativeMethods.cs
- ClientData.cs
- SessionStateModule.cs
- CompositionTarget.cs
- BackStopAuthenticationModule.cs
- WsiProfilesElementCollection.cs
- AttributeInfo.cs
- WorkflowQueueInfo.cs
- TraceSource.cs
- WebHttpSecurityModeHelper.cs
- PrintPageEvent.cs
- MetadataArtifactLoaderComposite.cs
- AccessDataSourceDesigner.cs
- InputBinder.cs
- HttpContext.cs
- SwitchLevelAttribute.cs
- OperationInvokerTrace.cs
- TypefaceMap.cs
- TypedColumnHandler.cs
- CheckBoxBaseAdapter.cs
- FontStretchConverter.cs
- FileRecordSequence.cs
- MailWebEventProvider.cs
- RegexEditorDialog.cs
- Panel.cs
- PictureBoxDesigner.cs
- DocumentGridContextMenu.cs
- HMACMD5.cs
- DataGridViewSortCompareEventArgs.cs
- LogStream.cs
- SelectedGridItemChangedEvent.cs
- NGCSerializationManager.cs
- SafeEventLogReadHandle.cs
- StyleHelper.cs
- RoleManagerEventArgs.cs
- TypeSystem.cs
- FileNameEditor.cs
- Behavior.cs
- SpeechRecognizer.cs
- GZipStream.cs
- BaseParser.cs
- SoapSchemaMember.cs
- UidManager.cs
- _Events.cs
- XmlTextReaderImpl.cs
- ConstraintStruct.cs
- dataprotectionpermissionattribute.cs
- DocumentSchemaValidator.cs
- Geometry3D.cs
- LinearGradientBrush.cs
- ListBindableAttribute.cs
- IIS7WorkerRequest.cs
- HighlightVisual.cs
- FormsAuthenticationConfiguration.cs
- WaitForChangedResult.cs
- BufferedGenericXmlSecurityToken.cs
- PeerNameRegistration.cs
- DirectoryRootQuery.cs
- NativeDirectoryServicesQueryAPIs.cs
- NamespaceMapping.cs
- SelectingProviderEventArgs.cs
- Types.cs
- SplitContainer.cs
- StructuredTypeEmitter.cs
- CodeMemberMethod.cs
- StringFormat.cs
- DescendantBaseQuery.cs
- EntityDataSourceChangedEventArgs.cs
- Transform3D.cs
- Funcletizer.cs
- DurationConverter.cs
- XmlSchemaAppInfo.cs
- SerialPort.cs
- SystemIPGlobalStatistics.cs
- HandlerBase.cs
- TextBreakpoint.cs
- CompressedStack.cs