Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / SqlClient / SqlGen / SqlWriter.cs / 2 / SqlWriter.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//---------------------------------------------------------------------
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.
///
/// Add as many tabs as the value of indent if we are at the
/// beginning of a line.
///
///
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);
}
}
///
///
///
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 [....], [....]
//---------------------------------------------------------------------
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.
///
/// Add as many tabs as the value of indent if we are at the
/// beginning of a line.
///
///
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);
}
}
///
///
///
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
- XpsFontSubsetter.cs
- LoadedEvent.cs
- AsynchronousChannelMergeEnumerator.cs
- BamlMapTable.cs
- BindingMAnagerBase.cs
- ReflectionPermission.cs
- FragmentQueryProcessor.cs
- TransactionBehavior.cs
- Evidence.cs
- XmlTextEncoder.cs
- IsolatedStoragePermission.cs
- PresentationSource.cs
- JsonDataContract.cs
- FontSource.cs
- TouchFrameEventArgs.cs
- QueuedDeliveryRequirementsMode.cs
- PeerNameRecord.cs
- Html32TextWriter.cs
- ActionMessageFilter.cs
- ChangeInterceptorAttribute.cs
- DynamicMetaObject.cs
- OutKeywords.cs
- PropertyInformationCollection.cs
- DeclaredTypeElement.cs
- ConstraintStruct.cs
- ReliabilityContractAttribute.cs
- ConfigXmlDocument.cs
- ObjectAssociationEndMapping.cs
- ToolStripSeparator.cs
- VectorAnimation.cs
- GridViewRowPresenterBase.cs
- DrawingAttributes.cs
- IList.cs
- CapabilitiesUse.cs
- VideoDrawing.cs
- TextShapeableCharacters.cs
- ResourceDefaultValueAttribute.cs
- DigitalSignatureProvider.cs
- ColumnResizeAdorner.cs
- WebPartConnection.cs
- TrackBar.cs
- SystemNetworkInterface.cs
- ExpressionNormalizer.cs
- MissingSatelliteAssemblyException.cs
- connectionpool.cs
- MergePropertyDescriptor.cs
- DirectionalLight.cs
- TagMapCollection.cs
- HorizontalAlignConverter.cs
- XmlDocument.cs
- ApplicationServiceManager.cs
- TextEditorTyping.cs
- HtmlInputSubmit.cs
- SelectedPathEditor.cs
- UnhandledExceptionEventArgs.cs
- TextLineBreak.cs
- DeferredReference.cs
- CodeValidator.cs
- Transform3DCollection.cs
- IgnoreFileBuildProvider.cs
- GlyphingCache.cs
- WebPartVerb.cs
- Columns.cs
- _ConnectionGroup.cs
- WorkflowFormatterBehavior.cs
- Exceptions.cs
- ThemeDirectoryCompiler.cs
- SymbolDocumentGenerator.cs
- DockProviderWrapper.cs
- columnmapkeybuilder.cs
- SqlNodeAnnotation.cs
- PeerCustomResolverBindingElement.cs
- WhitespaceSignificantCollectionAttribute.cs
- ModuleConfigurationInfo.cs
- CodeValidator.cs
- ContainerActivationHelper.cs
- EngineSiteSapi.cs
- X509Certificate.cs
- _BasicClient.cs
- DataGridDetailsPresenterAutomationPeer.cs
- SmiGettersStream.cs
- XmlSerializationWriter.cs
- EnglishPluralizationService.cs
- DisplayInformation.cs
- MouseButtonEventArgs.cs
- FastEncoderWindow.cs
- AutoGeneratedFieldProperties.cs
- Facet.cs
- loginstatus.cs
- Util.cs
- BamlRecordHelper.cs
- XmlSchemaAnnotated.cs
- ScriptServiceAttribute.cs
- DtrList.cs
- BuildProvidersCompiler.cs
- ManagementScope.cs
- DesignBindingValueUIHandler.cs
- EventHandlers.cs
- GeometryModel3D.cs
- ThreadStaticAttribute.cs