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
- PersistChildrenAttribute.cs
- XamlNamespaceHelper.cs
- IPAddress.cs
- DataTableTypeConverter.cs
- CorruptStoreException.cs
- StartUpEventArgs.cs
- ScrollChrome.cs
- TextOutput.cs
- RectConverter.cs
- PaintValueEventArgs.cs
- SwitchLevelAttribute.cs
- ResourceExpressionBuilder.cs
- FaultFormatter.cs
- DateTimeOffset.cs
- DbException.cs
- OperandQuery.cs
- SymmetricCryptoHandle.cs
- FileDialog_Vista_Interop.cs
- EntitySqlQueryCacheKey.cs
- Ticks.cs
- TextParaClient.cs
- SizeFConverter.cs
- HttpHeaderCollection.cs
- PerfService.cs
- MonitorWrapper.cs
- AdapterUtil.cs
- DomainLiteralReader.cs
- CodeIdentifiers.cs
- ConfigurationSettings.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- StateMachineWorkflowDesigner.cs
- HtmlUtf8RawTextWriter.cs
- CommonDialog.cs
- ErrorEventArgs.cs
- iisPickupDirectory.cs
- MetadataCache.cs
- SizeConverter.cs
- RequestQueue.cs
- WindowsServiceElement.cs
- ProfileGroupSettings.cs
- SymbolType.cs
- ValidationResult.cs
- EntitySqlQueryCacheEntry.cs
- ExpressionBuilderCollection.cs
- PaintEvent.cs
- ResXFileRef.cs
- ColumnBinding.cs
- NullableDoubleSumAggregationOperator.cs
- ellipse.cs
- log.cs
- COM2ColorConverter.cs
- CustomWebEventKey.cs
- MenuItemBindingCollection.cs
- VisualBrush.cs
- BamlBinaryReader.cs
- WorkflowRuntimeServiceElement.cs
- BitmapEffectState.cs
- Int64Storage.cs
- DocumentReferenceCollection.cs
- ComAdminWrapper.cs
- OleDbSchemaGuid.cs
- CryptoConfig.cs
- PageContent.cs
- SqlError.cs
- AccessibleObject.cs
- DataBoundControlAdapter.cs
- WmfPlaceableFileHeader.cs
- DataGridViewAutoSizeColumnsModeEventArgs.cs
- NativeMethods.cs
- ReadOnlyDataSource.cs
- GridItemPattern.cs
- EnterpriseServicesHelper.cs
- RecommendedAsConfigurableAttribute.cs
- FileIOPermission.cs
- MouseButtonEventArgs.cs
- SocketPermission.cs
- DocComment.cs
- DesignObjectWrapper.cs
- X509UI.cs
- ResolveNameEventArgs.cs
- PrivilegeNotHeldException.cs
- WSAddressing10ProblemHeaderQNameFault.cs
- MultitargetingHelpers.cs
- SectionVisual.cs
- CustomAssemblyResolver.cs
- DeadCharTextComposition.cs
- PagesChangedEventArgs.cs
- DateTimePicker.cs
- NetStream.cs
- TagMapCollection.cs
- SqlClientWrapperSmiStream.cs
- CommandEventArgs.cs
- DefaultPropertyAttribute.cs
- ToolStripOverflow.cs
- ToolStripComboBox.cs
- Ref.cs
- EdmComplexPropertyAttribute.cs
- ThumbButtonInfoCollection.cs
- StyleConverter.cs
- XmlSerializationReader.cs