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
- ArgumentNullException.cs
- BitmapMetadataEnumerator.cs
- ConfigXmlCDataSection.cs
- Mapping.cs
- ServiceEndpointElementCollection.cs
- TreeViewHitTestInfo.cs
- MediaTimeline.cs
- Html32TextWriter.cs
- Win32KeyboardDevice.cs
- SQLCharsStorage.cs
- IDictionary.cs
- ErrorFormatterPage.cs
- ClientConfigurationHost.cs
- CodeIndexerExpression.cs
- ActiveXContainer.cs
- DelegatingTypeDescriptionProvider.cs
- TcpClientChannel.cs
- ReaderWriterLock.cs
- StorageMappingFragment.cs
- SymbolTable.cs
- CodeArgumentReferenceExpression.cs
- UserValidatedEventArgs.cs
- ModelTypeConverter.cs
- HealthMonitoringSection.cs
- PassportAuthenticationEventArgs.cs
- WindowsProgressbar.cs
- BitmapEffectOutputConnector.cs
- assemblycache.cs
- SymbolMethod.cs
- HttpWebRequestElement.cs
- NativeWrapper.cs
- DiscriminatorMap.cs
- safex509handles.cs
- FileEnumerator.cs
- ReadWriteSpinLock.cs
- BadImageFormatException.cs
- FixedSOMImage.cs
- SecurityChannelFactory.cs
- ResolveDuplexCD1AsyncResult.cs
- CodeAttributeArgument.cs
- ContentElement.cs
- ClonableStack.cs
- GeometryConverter.cs
- RegexWriter.cs
- NavigationPropertyEmitter.cs
- X509CertificateClaimSet.cs
- URL.cs
- XmlSerializableServices.cs
- TabPanel.cs
- BinaryUtilClasses.cs
- ToolStripItemTextRenderEventArgs.cs
- SiblingIterators.cs
- ApplySecurityAndSendAsyncResult.cs
- XmlEnumAttribute.cs
- ModelItemImpl.cs
- ThreadStateException.cs
- XmlRootAttribute.cs
- LinqDataSource.cs
- UInt64.cs
- HtmlInputFile.cs
- recordstatescratchpad.cs
- ReaderContextStackData.cs
- ResourceManager.cs
- UIPermission.cs
- IdentityNotMappedException.cs
- LinqDataSourceDeleteEventArgs.cs
- FontStretchConverter.cs
- CfgArc.cs
- backend.cs
- ParallelDesigner.cs
- EncryptedData.cs
- CompModHelpers.cs
- TextRangeEdit.cs
- BitArray.cs
- VariableQuery.cs
- WebPartTracker.cs
- ResourceWriter.cs
- CodeChecksumPragma.cs
- HttpChannelBindingToken.cs
- IntranetCredentialPolicy.cs
- XmlComment.cs
- XmlLangPropertyAttribute.cs
- PolicyChain.cs
- CreateUserErrorEventArgs.cs
- HttpHandlerActionCollection.cs
- SerializationInfo.cs
- TcpChannelHelper.cs
- SchemaElementDecl.cs
- XmlNavigatorFilter.cs
- ContextStaticAttribute.cs
- StubHelpers.cs
- ByteStreamGeometryContext.cs
- CodeTypeReferenceExpression.cs
- EncoderExceptionFallback.cs
- XmlResolver.cs
- WebPartZoneBase.cs
- TextBox.cs
- WorkingDirectoryEditor.cs
- Validator.cs
- TemplateFactory.cs