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
- HtmlTextArea.cs
- ToolStripTextBox.cs
- Point4D.cs
- ConfigWriter.cs
- Version.cs
- HostedNamedPipeTransportManager.cs
- EffectiveValueEntry.cs
- FileStream.cs
- ComAdminWrapper.cs
- WpfXamlLoader.cs
- FileSystemInfo.cs
- DataErrorValidationRule.cs
- AdRotator.cs
- CellTreeNode.cs
- TypeConverterHelper.cs
- MutexSecurity.cs
- ImpersonationContext.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- ReferencedType.cs
- XmlEventCache.cs
- DaylightTime.cs
- SmiEventSink.cs
- CalendarDataBindingHandler.cs
- OpenTypeLayoutCache.cs
- FileEnumerator.cs
- SetterBaseCollection.cs
- AccessViolationException.cs
- DelegatingMessage.cs
- SqlProvider.cs
- ResourceExpression.cs
- SignalGate.cs
- EmptyReadOnlyDictionaryInternal.cs
- BufferedGraphics.cs
- ServiceModelDictionary.cs
- ServiceBusyException.cs
- CollaborationHelperFunctions.cs
- FreezableOperations.cs
- DefaultMemberAttribute.cs
- WorkflowMarkupSerializationProvider.cs
- ScrollViewerAutomationPeer.cs
- DbConnectionStringCommon.cs
- ImageAnimator.cs
- RoleManagerSection.cs
- Helpers.cs
- DataFormats.cs
- ComplexLine.cs
- ServiceHostingEnvironmentSection.cs
- EntitySet.cs
- KnownBoxes.cs
- DrawingGroup.cs
- ObjectStorage.cs
- SecurityKeyType.cs
- ForAllOperator.cs
- CodeChecksumPragma.cs
- TileBrush.cs
- LineProperties.cs
- LocatorPartList.cs
- ToolBarTray.cs
- MethodRental.cs
- ComPlusAuthorization.cs
- DebugViewWriter.cs
- ControlBuilderAttribute.cs
- SystemGatewayIPAddressInformation.cs
- LinqDataSourceSelectEventArgs.cs
- BinHexDecoder.cs
- UdpReplyToBehavior.cs
- DescendentsWalker.cs
- ToolStripTemplateNode.cs
- WorkflowRuntimeSection.cs
- RsaKeyGen.cs
- HostingEnvironmentException.cs
- FieldToken.cs
- RadioButtonRenderer.cs
- BufferedWebEventProvider.cs
- WebWorkflowRole.cs
- TargetParameterCountException.cs
- Util.cs
- ToolbarAUtomationPeer.cs
- FlowPosition.cs
- Visitor.cs
- GeometryGroup.cs
- WorkBatch.cs
- ForeignKeyFactory.cs
- ItemCollectionEditor.cs
- BrowserDefinition.cs
- ModelItemCollection.cs
- SoapInteropTypes.cs
- WebPartZone.cs
- ResourceDictionaryCollection.cs
- ErrorTolerantObjectWriter.cs
- DoubleConverter.cs
- UsernameTokenFactoryCredential.cs
- DataBindingExpressionBuilder.cs
- ModelItemDictionary.cs
- MobileControlsSection.cs
- SafePEFileHandle.cs
- SmiEventStream.cs
- XamlDesignerSerializationManager.cs
- codemethodreferenceexpression.cs
- DbConnectionClosed.cs