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
- EnumDataContract.cs
- TransformedBitmap.cs
- Imaging.cs
- MenuCommand.cs
- ColorTranslator.cs
- ButtonFlatAdapter.cs
- ConfigurationLockCollection.cs
- VBIdentifierDesigner.xaml.cs
- GridViewHeaderRowPresenter.cs
- Splitter.cs
- CodeSubDirectory.cs
- WebHttpElement.cs
- ResourceExpressionBuilder.cs
- HttpHandlerAction.cs
- FileRegion.cs
- LogicalExpr.cs
- Freezable.cs
- HttpConfigurationSystem.cs
- Cursors.cs
- MenuItemCollection.cs
- Calendar.cs
- BitmapFrame.cs
- OSEnvironmentHelper.cs
- HtmlDocument.cs
- DocumentManager.cs
- AttributeExtensions.cs
- GeneralTransform.cs
- DataTemplate.cs
- DynamicResourceExtension.cs
- CryptoKeySecurity.cs
- CookielessHelper.cs
- TextDecorationLocationValidation.cs
- TreeNodeBinding.cs
- StylusSystemGestureEventArgs.cs
- DataRow.cs
- HttpCapabilitiesEvaluator.cs
- lengthconverter.cs
- HtmlTextArea.cs
- BooleanAnimationBase.cs
- SqlParameter.cs
- DBAsyncResult.cs
- XmlElementAttributes.cs
- WebBaseEventKeyComparer.cs
- HttpPostClientProtocol.cs
- DiscoveryExceptionDictionary.cs
- DynamicScriptObject.cs
- ToolStripDropDownItem.cs
- FirstMatchCodeGroup.cs
- InteropAutomationProvider.cs
- BitFlagsGenerator.cs
- DynamicMethod.cs
- ThrowOnMultipleAssignment.cs
- GridViewDeleteEventArgs.cs
- CookieParameter.cs
- PageThemeParser.cs
- CacheOutputQuery.cs
- NodeInfo.cs
- WindowsContainer.cs
- SafeNativeMethods.cs
- FormViewUpdatedEventArgs.cs
- InvokeGenerator.cs
- CreateUserWizard.cs
- ProgressPage.cs
- TreeIterators.cs
- AuthenticationManager.cs
- CodeAttributeDeclaration.cs
- Enum.cs
- ImageDrawing.cs
- XmlDocumentFragment.cs
- SymbolMethod.cs
- RootBrowserWindowProxy.cs
- CodeAccessSecurityEngine.cs
- RowBinding.cs
- WindowsUpDown.cs
- SpotLight.cs
- ObjectStorage.cs
- StatusBarItem.cs
- SplitContainer.cs
- XmlCharCheckingWriter.cs
- KeyEvent.cs
- IgnorePropertiesAttribute.cs
- RegexMatchCollection.cs
- AgileSafeNativeMemoryHandle.cs
- ProcessModelSection.cs
- ClearTypeHintValidation.cs
- ResourceProviderFactory.cs
- XamlTypeMapper.cs
- PagerSettings.cs
- SchemaSetCompiler.cs
- CodeAttributeArgument.cs
- SymLanguageVendor.cs
- __TransparentProxy.cs
- ListViewDeleteEventArgs.cs
- HtmlToClrEventProxy.cs
- EntityTransaction.cs
- SystemDropShadowChrome.cs
- XmlWhitespace.cs
- CharacterBuffer.cs
- IItemContainerGenerator.cs
- XamlSerializerUtil.cs