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
- ObjectDataSource.cs
- BindableTemplateBuilder.cs
- ChoiceConverter.cs
- SqlFormatter.cs
- FaultDesigner.cs
- StandardBindingOptionalReliableSessionElement.cs
- SettingsSection.cs
- Bold.cs
- TextEditorTables.cs
- ScriptReferenceBase.cs
- DescendantBaseQuery.cs
- HybridDictionary.cs
- BindingExpressionBase.cs
- BinaryHeap.cs
- WebFaultException.cs
- Invariant.cs
- Transform3DCollection.cs
- EditorPartChrome.cs
- COM2ExtendedBrowsingHandler.cs
- DbProviderFactory.cs
- BreadCrumbTextConverter.cs
- DelegateSerializationHolder.cs
- XmlSerializerSection.cs
- ClosableStream.cs
- ProcessHostFactoryHelper.cs
- PersistenceTask.cs
- EmptyEnumerator.cs
- RuntimeConfig.cs
- PersonalizationStateQuery.cs
- AtomMaterializerLog.cs
- HttpRuntimeSection.cs
- HotCommands.cs
- TreeView.cs
- UrlRoutingModule.cs
- MenuCommand.cs
- HttpRequestTraceRecord.cs
- xmlfixedPageInfo.cs
- BypassElementCollection.cs
- ConstraintEnumerator.cs
- Profiler.cs
- RSAPKCS1SignatureDeformatter.cs
- EqualityComparer.cs
- XmlNotation.cs
- SqlDataSourceDesigner.cs
- FixedTextView.cs
- DbProviderFactories.cs
- XmlAttributeProperties.cs
- CollectionContainer.cs
- ColorDialog.cs
- CompiledRegexRunner.cs
- AnimationClock.cs
- AdPostCacheSubstitution.cs
- ConditionalWeakTable.cs
- DataColumnPropertyDescriptor.cs
- HttpGetProtocolReflector.cs
- SqlTrackingService.cs
- FixUpCollection.cs
- HttpRequest.cs
- Label.cs
- MetadataReference.cs
- TextProviderWrapper.cs
- DelayLoadType.cs
- WorkflowInstanceQuery.cs
- Validator.cs
- SafeRightsManagementPubHandle.cs
- Utils.cs
- FrameDimension.cs
- ModelPropertyCollectionImpl.cs
- XmlSchemaObjectTable.cs
- XmlNodeReader.cs
- LOSFormatter.cs
- ProgressChangedEventArgs.cs
- HitTestResult.cs
- Model3D.cs
- WebPartDeleteVerb.cs
- OrderedEnumerableRowCollection.cs
- MenuDesigner.cs
- XmlSchemaSubstitutionGroup.cs
- BindingUtils.cs
- DataGrid.cs
- CssStyleCollection.cs
- Collection.cs
- GlobalizationAssembly.cs
- Base64Encoding.cs
- ObjectSet.cs
- CompositeControl.cs
- IsolatedStorage.cs
- Bidi.cs
- Ports.cs
- InputElement.cs
- TextRenderer.cs
- ContentPresenter.cs
- PointAnimationClockResource.cs
- Site.cs
- HttpWebResponse.cs
- AttributeEmitter.cs
- Control.cs
- MethodCallTranslator.cs
- DbProviderFactoriesConfigurationHandler.cs
- KeyFrames.cs