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
- KerberosRequestorSecurityToken.cs
- CodeObjectCreateExpression.cs
- CommandLibraryHelper.cs
- TranslateTransform.cs
- ITextView.cs
- StrokeNodeOperations2.cs
- Matrix.cs
- SafePEFileHandle.cs
- MethodBuilderInstantiation.cs
- SqlTypeConverter.cs
- NullReferenceException.cs
- CallSiteHelpers.cs
- ToolStripStatusLabel.cs
- ObjectDesignerDataSourceView.cs
- _SpnDictionary.cs
- AutoResetEvent.cs
- ObjectSecurity.cs
- UrlPath.cs
- AutomationEvent.cs
- WebControlAdapter.cs
- HtmlTableCellCollection.cs
- TemplateLookupAction.cs
- StringFunctions.cs
- GridEntry.cs
- HttpStreamFormatter.cs
- SqlProviderManifest.cs
- UnauthorizedAccessException.cs
- BitVec.cs
- CodeAttributeDeclaration.cs
- GlobalizationSection.cs
- WindowsFormsHost.cs
- PenThread.cs
- TypeLibConverter.cs
- Crc32.cs
- SkewTransform.cs
- ThreadNeutralSemaphore.cs
- CellTreeNode.cs
- SqlCachedBuffer.cs
- Effect.cs
- Splitter.cs
- UpdateProgress.cs
- TimersDescriptionAttribute.cs
- ListViewHitTestInfo.cs
- OuterGlowBitmapEffect.cs
- AxDesigner.cs
- PersonalizationProvider.cs
- MenuItem.cs
- SelectedGridItemChangedEvent.cs
- MessageVersionConverter.cs
- SqlClientMetaDataCollectionNames.cs
- DataSourceXmlAttributeAttribute.cs
- GeneralTransform.cs
- MetaData.cs
- CultureSpecificStringDictionary.cs
- RtfFormatStack.cs
- SemaphoreSecurity.cs
- SByteStorage.cs
- Span.cs
- VirtualPath.cs
- MimeTypeMapper.cs
- CodeCommentStatementCollection.cs
- SimplePropertyEntry.cs
- DataObjectEventArgs.cs
- SourceFilter.cs
- ToolStripPanel.cs
- SendMessageRecord.cs
- SequentialUshortCollection.cs
- Crc32.cs
- ComponentManagerBroker.cs
- CodeArrayIndexerExpression.cs
- RealProxy.cs
- AutoResetEvent.cs
- ConnectorRouter.cs
- Registry.cs
- SharedConnectionWorkflowTransactionService.cs
- Relationship.cs
- RegisteredExpandoAttribute.cs
- ByteStack.cs
- MetabaseServerConfig.cs
- PreApplicationStartMethodAttribute.cs
- SqlBooleanMismatchVisitor.cs
- XmlDataImplementation.cs
- XamlToRtfParser.cs
- Table.cs
- ToolConsole.cs
- CommandPlan.cs
- OrderByBuilder.cs
- CodeDOMProvider.cs
- RequestContext.cs
- StringComparer.cs
- DbProviderSpecificTypePropertyAttribute.cs
- XmlEnumAttribute.cs
- EntitySqlQueryCacheKey.cs
- ContentValidator.cs
- VisualTreeUtils.cs
- TextServicesPropertyRanges.cs
- HMACSHA384.cs
- LogRecordSequence.cs
- WindowsFormsHostPropertyMap.cs
- CodePrimitiveExpression.cs