Code:
/ DotNET / DotNET / 8.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
- AttributeProviderAttribute.cs
- XmlCDATASection.cs
- DesignerView.Commands.cs
- EdmComplexPropertyAttribute.cs
- ProcessModule.cs
- Drawing.cs
- TextDocumentView.cs
- LogEntryHeaderDeserializer.cs
- QuaternionRotation3D.cs
- Operand.cs
- EncoderExceptionFallback.cs
- UrlPath.cs
- GZipDecoder.cs
- DeclaredTypeValidatorAttribute.cs
- HtmlTableRow.cs
- HTMLTextWriter.cs
- ParentUndoUnit.cs
- Regex.cs
- SqlClientPermission.cs
- Memoizer.cs
- Border.cs
- XmlSchemaDocumentation.cs
- FormViewDeleteEventArgs.cs
- SpnegoTokenAuthenticator.cs
- SiteMapHierarchicalDataSourceView.cs
- TextParentUndoUnit.cs
- CheckableControlBaseAdapter.cs
- AmbientValueAttribute.cs
- Mapping.cs
- validationstate.cs
- BevelBitmapEffect.cs
- TypeDescriptor.cs
- LogEntrySerializationException.cs
- StackBuilderSink.cs
- SqlTrackingQuery.cs
- ToolStripContainerActionList.cs
- TextEditor.cs
- InternalTransaction.cs
- AspNetHostingPermission.cs
- Point4DConverter.cs
- LineSegment.cs
- DataGridViewRowCollection.cs
- DesignerDeviceConfig.cs
- SizeChangedInfo.cs
- ConsoleKeyInfo.cs
- ListViewTableRow.cs
- WebConfigurationManager.cs
- WebCodeGenerator.cs
- ConstraintStruct.cs
- WebPartAuthorizationEventArgs.cs
- DesignerActionMethodItem.cs
- ActiveXContainer.cs
- ControlCollection.cs
- precedingsibling.cs
- QueryableFilterUserControl.cs
- AttachedPropertyBrowsableWhenAttributePresentAttribute.cs
- UnaryNode.cs
- LogReserveAndAppendState.cs
- EnumDataContract.cs
- COM2PropertyDescriptor.cs
- XamlVector3DCollectionSerializer.cs
- ViewLoader.cs
- LinqDataSourceDisposeEventArgs.cs
- WebZone.cs
- CodeBlockBuilder.cs
- DataControlImageButton.cs
- SortedSet.cs
- FormViewUpdateEventArgs.cs
- DataRowChangeEvent.cs
- AnnotationObservableCollection.cs
- SqlFacetAttribute.cs
- GACIdentityPermission.cs
- GPStream.cs
- GiveFeedbackEvent.cs
- WebPartsPersonalizationAuthorization.cs
- IRCollection.cs
- SystemResourceHost.cs
- GridViewUpdatedEventArgs.cs
- RTLAwareMessageBox.cs
- RubberbandSelector.cs
- QueryRewriter.cs
- TextDecorationUnitValidation.cs
- CodeMemberEvent.cs
- DoubleCollectionConverter.cs
- ConfigXmlText.cs
- _IPv6Address.cs
- Table.cs
- TransformCollection.cs
- Duration.cs
- DataSvcMapFile.cs
- RectConverter.cs
- StructuralCache.cs
- Expression.cs
- LocalizedNameDescriptionPair.cs
- Action.cs
- SmiContextFactory.cs
- SchemaImporterExtensionElement.cs
- PackageFilter.cs
- WsatConfiguration.cs
- ListViewDataItem.cs