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
- ApplicationContext.cs
- WSHttpBinding.cs
- ServiceRoute.cs
- ThemeInfoAttribute.cs
- PagesSection.cs
- BindingList.cs
- AppSettingsExpressionBuilder.cs
- Polyline.cs
- XamlBuildTaskServices.cs
- ProcessHostFactoryHelper.cs
- TriggerAction.cs
- VectorCollection.cs
- ObjectDataSourceChooseMethodsPanel.cs
- DataListComponentEditor.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- regiisutil.cs
- ProtocolsConfigurationHandler.cs
- DesignTimeTemplateParser.cs
- ObjectDataSourceSelectingEventArgs.cs
- DataSourceUtil.cs
- WebPartDescription.cs
- Slider.cs
- EditingScopeUndoUnit.cs
- DataGridItemAutomationPeer.cs
- NoneExcludedImageIndexConverter.cs
- EntityConnectionStringBuilder.cs
- CommandBindingCollection.cs
- OracleFactory.cs
- TextTreeNode.cs
- RoutedPropertyChangedEventArgs.cs
- BaseServiceProvider.cs
- ToolboxItemCollection.cs
- CodeNamespaceImportCollection.cs
- FileDetails.cs
- DelimitedListTraceListener.cs
- BinaryReader.cs
- StoreItemCollection.cs
- IsolatedStorageFilePermission.cs
- JsonFormatGeneratorStatics.cs
- Function.cs
- shaper.cs
- SoapDocumentMethodAttribute.cs
- NullableDoubleSumAggregationOperator.cs
- TypeSystemProvider.cs
- UICuesEvent.cs
- TextTreeDeleteContentUndoUnit.cs
- RegexBoyerMoore.cs
- ListViewTableCell.cs
- DbConnectionOptions.cs
- OracleParameterBinding.cs
- CapabilitiesRule.cs
- ParameterReplacerVisitor.cs
- Rectangle.cs
- ReplyChannel.cs
- InheritanceContextChangedEventManager.cs
- DirectionalLight.cs
- ImageField.cs
- RsaSecurityKey.cs
- CodeGenerator.cs
- PersianCalendar.cs
- ListControl.cs
- RouteTable.cs
- Operand.cs
- WebPartDisplayModeEventArgs.cs
- ContextMarshalException.cs
- GridViewColumnHeaderAutomationPeer.cs
- LeftCellWrapper.cs
- TextTreeDeleteContentUndoUnit.cs
- EnumerationRangeValidationUtil.cs
- TreeWalkHelper.cs
- Marshal.cs
- DoubleAnimationClockResource.cs
- StylesEditorDialog.cs
- SqlGatherProducedAliases.cs
- RelationshipManager.cs
- JournalNavigationScope.cs
- OdbcError.cs
- DependencyObjectPropertyDescriptor.cs
- shaper.cs
- OnOperation.cs
- XmlTextWriter.cs
- BinaryReader.cs
- WCFModelStrings.Designer.cs
- TextSelectionHelper.cs
- PostBackTrigger.cs
- SyndicationItem.cs
- ListSourceHelper.cs
- ListViewCancelEventArgs.cs
- AssignDesigner.xaml.cs
- DbMetaDataColumnNames.cs
- AsymmetricSignatureFormatter.cs
- AccessKeyManager.cs
- SingleAnimationUsingKeyFrames.cs
- RuleSettings.cs
- HttpDictionary.cs
- VectorKeyFrameCollection.cs
- CryptoKeySecurity.cs
- ErrorWrapper.cs
- DbProviderConfigurationHandler.cs
- WebPartDisplayModeCancelEventArgs.cs