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.
///
/// 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 [....]
// @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.
///
/// 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
- WorkflowServiceNamespace.cs
- ReturnType.cs
- ClientUrlResolverWrapper.cs
- FullTextBreakpoint.cs
- ByteStreamGeometryContext.cs
- SystemTcpStatistics.cs
- EventMemberCodeDomSerializer.cs
- WebBrowserContainer.cs
- WebControl.cs
- FamilyTypefaceCollection.cs
- CodeNamespace.cs
- DbProviderConfigurationHandler.cs
- CodeCatchClauseCollection.cs
- DoubleLink.cs
- RSAPKCS1SignatureFormatter.cs
- PassportIdentity.cs
- SiblingIterators.cs
- XmlSchemaParticle.cs
- HMACSHA512.cs
- EntityDataSourceView.cs
- WeakEventTable.cs
- Pkcs9Attribute.cs
- SemanticKeyElement.cs
- SchemaImporterExtension.cs
- RolePrincipal.cs
- DiffuseMaterial.cs
- PropertyNames.cs
- ClientRolePrincipal.cs
- ILGen.cs
- HiddenField.cs
- DeferredTextReference.cs
- ResXFileRef.cs
- ScrollItemProviderWrapper.cs
- UIInitializationException.cs
- RenderCapability.cs
- ApplicationBuildProvider.cs
- EnumConverter.cs
- DecoderExceptionFallback.cs
- Border.cs
- Executor.cs
- DisplayNameAttribute.cs
- TypeElementCollection.cs
- PointCollectionConverter.cs
- KnownBoxes.cs
- InputReferenceExpression.cs
- PeerCollaboration.cs
- URLString.cs
- JournalEntryStack.cs
- SqlDataSourceQuery.cs
- ToolStripArrowRenderEventArgs.cs
- TransactionManager.cs
- TreeViewImageIndexConverter.cs
- streamingZipPartStream.cs
- DataGridAddNewRow.cs
- AsymmetricSignatureFormatter.cs
- ListViewGroupItemCollection.cs
- Helpers.cs
- RenderContext.cs
- ChangePassword.cs
- AmbientLight.cs
- OpenTypeMethods.cs
- util.cs
- NameScopePropertyAttribute.cs
- DaylightTime.cs
- CustomError.cs
- HtmlPanelAdapter.cs
- DictionaryEntry.cs
- Variant.cs
- ImageMap.cs
- OleDbParameter.cs
- RootNamespaceAttribute.cs
- ScrollProviderWrapper.cs
- ZoneMembershipCondition.cs
- BufferCache.cs
- DescendantOverDescendantQuery.cs
- FolderBrowserDialogDesigner.cs
- _SslSessionsCache.cs
- Constraint.cs
- ParameterDataSourceExpression.cs
- XmlSerializer.cs
- RTTrackingProfile.cs
- ScriptingRoleServiceSection.cs
- IndependentAnimationStorage.cs
- InheritanceRules.cs
- GeneralTransform2DTo3DTo2D.cs
- BuilderElements.cs
- CodeCompiler.cs
- WebPartHeaderCloseVerb.cs
- BitStack.cs
- __FastResourceComparer.cs
- LoaderAllocator.cs
- RegexCode.cs
- ApplicationId.cs
- DragCompletedEventArgs.cs
- Graphics.cs
- XPathPatternParser.cs
- ListViewPagedDataSource.cs
- Propagator.JoinPropagator.cs
- SafeHandles.cs
- ArcSegment.cs