Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / SqlClient / SqlGen / SqlWriter.cs / 1305376 / SqlWriter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using System.Data.SqlClient; using System.Data.Metadata.Edm; using System.Data.Common.CommandTrees; namespace System.Data.SqlClient.SqlGen { ////// This extends StringWriter primarily to add the ability to add an indent /// to each line that is written out. /// class SqlWriter : StringWriter { // We start at -1, since the first select statement will increment it to 0. int indent = -1; ////// The number of tabs to be added at the beginning of each new line. /// internal int Indent { get { return indent; } set { indent = value; } } bool atBeginningOfLine = true; ////// /// /// public SqlWriter(StringBuilder b) : base(b, System.Globalization.CultureInfo.InvariantCulture) // I don't think the culture matters, but FxCop wants something { } ////// Reset atBeginningofLine if we detect the newline string. /// /// public override void Write(string value) { if (value == "\r\n") { base.WriteLine(); atBeginningOfLine = true; } else { if (atBeginningOfLine) { if (indent > 0) { base.Write(new string('\t', indent)); } atBeginningOfLine = false; } base.Write(value); } } ////// Add as many tabs as the value of indent if we are at the /// beginning of a line. /// /// /// public override void WriteLine() { base.WriteLine(); atBeginningOfLine = true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using System.Data.SqlClient; using System.Data.Metadata.Edm; using System.Data.Common.CommandTrees; namespace System.Data.SqlClient.SqlGen { ////// This extends StringWriter primarily to add the ability to add an indent /// to each line that is written out. /// class SqlWriter : StringWriter { // We start at -1, since the first select statement will increment it to 0. int indent = -1; ////// The number of tabs to be added at the beginning of each new line. /// internal int Indent { get { return indent; } set { indent = value; } } bool atBeginningOfLine = true; ////// /// /// public SqlWriter(StringBuilder b) : base(b, System.Globalization.CultureInfo.InvariantCulture) // I don't think the culture matters, but FxCop wants something { } ////// Reset atBeginningofLine if we detect the newline string. /// /// public override void Write(string value) { if (value == "\r\n") { base.WriteLine(); atBeginningOfLine = true; } else { if (atBeginningOfLine) { if (indent > 0) { base.Write(new string('\t', indent)); } atBeginningOfLine = false; } base.Write(value); } } ////// Add as many tabs as the value of indent if we are at the /// beginning of a line. /// /// /// public override void WriteLine() { base.WriteLine(); atBeginningOfLine = true; } } } // 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
- SourceFilter.cs
- DataGridBeginningEditEventArgs.cs
- InterleavedZipPartStream.cs
- ObjectTag.cs
- Pair.cs
- ETagAttribute.cs
- XmlEncApr2001.cs
- SessionPageStatePersister.cs
- XmlMemberMapping.cs
- ConstrainedGroup.cs
- SimpleHandlerBuildProvider.cs
- TraceHandler.cs
- ApplicationId.cs
- BufferAllocator.cs
- UnsafeNativeMethods.cs
- CollectionViewGroup.cs
- WebHeaderCollection.cs
- GuidelineCollection.cs
- CodePageUtils.cs
- StringUtil.cs
- ExpressionLexer.cs
- HashJoinQueryOperatorEnumerator.cs
- ParameterBuilder.cs
- HttpChannelBindingToken.cs
- ZipArchive.cs
- CancellableEnumerable.cs
- WrappedReader.cs
- CaseStatementProjectedSlot.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- ApplicationManager.cs
- ScrollBar.cs
- SizeLimitedCache.cs
- TraceUtility.cs
- SoapHeaderAttribute.cs
- DbConnectionPool.cs
- MemberHolder.cs
- MessageQueueTransaction.cs
- EventPrivateKey.cs
- AssociationEndMember.cs
- ThicknessAnimationUsingKeyFrames.cs
- DecimalAnimationBase.cs
- HtmlControlPersistable.cs
- EllipticalNodeOperations.cs
- TextPatternIdentifiers.cs
- XmlChildEnumerator.cs
- DesignerAttribute.cs
- DBConnectionString.cs
- EnvelopedSignatureTransform.cs
- VisualTreeHelper.cs
- RowToParametersTransformer.cs
- ConfigurationProperty.cs
- HebrewNumber.cs
- SafeRightsManagementSessionHandle.cs
- ShapeTypeface.cs
- HashAlgorithm.cs
- DetailsViewInsertedEventArgs.cs
- MessageBox.cs
- HttpChannelFactory.cs
- ImageIndexConverter.cs
- WebPartDisplayModeCollection.cs
- SqlDataSourceDesigner.cs
- Label.cs
- TemplateControlBuildProvider.cs
- HtmlControl.cs
- SetterBaseCollection.cs
- ExecutionEngineException.cs
- SystemParameters.cs
- EventLogPermissionAttribute.cs
- HtmlElementEventArgs.cs
- AssemblyUtil.cs
- RoutedEventValueSerializer.cs
- SecurityResources.cs
- Char.cs
- AmbientValueAttribute.cs
- TabControlDesigner.cs
- AddingNewEventArgs.cs
- PenLineJoinValidation.cs
- AssemblyBuilder.cs
- DependencyPropertyKind.cs
- CqlParserHelpers.cs
- BindingOperations.cs
- InstancePersistenceContext.cs
- CachingHintValidation.cs
- HMACMD5.cs
- ModelTypeConverter.cs
- IISMapPath.cs
- PathSegmentCollection.cs
- AudioFileOut.cs
- TextLineBreak.cs
- SourceInterpreter.cs
- WindowsPen.cs
- EntityDataSourceMemberPath.cs
- JobInputBins.cs
- EventItfInfo.cs
- QuerySettings.cs
- SettingsPropertyValue.cs
- MouseEvent.cs
- Brush.cs
- PrinterResolution.cs
- EventManager.cs