Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- InstallerTypeAttribute.cs
- TraceContextEventArgs.cs
- X509Extension.cs
- InstancePersistenceCommandException.cs
- CodeSubDirectory.cs
- DbMetaDataCollectionNames.cs
- Wildcard.cs
- DropDownButton.cs
- SemanticResolver.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- RectangleHotSpot.cs
- RichTextBoxAutomationPeer.cs
- DataControlPagerLinkButton.cs
- PersistChildrenAttribute.cs
- TextElementEnumerator.cs
- DockPattern.cs
- UnsafeNativeMethods.cs
- PersistChildrenAttribute.cs
- ListItemViewAttribute.cs
- BooleanToVisibilityConverter.cs
- CombinedGeometry.cs
- RtfToXamlLexer.cs
- ResourceReader.cs
- CookielessData.cs
- DocumentXmlWriter.cs
- DocumentViewer.cs
- DbConnectionStringCommon.cs
- DataGridViewCellStyleConverter.cs
- DataGridViewCellConverter.cs
- InternalConfigHost.cs
- CategoryNameCollection.cs
- SqlCommandSet.cs
- HorizontalAlignConverter.cs
- BitmapCacheBrush.cs
- ExpressionBuilderContext.cs
- ValidationRuleCollection.cs
- BinaryObjectInfo.cs
- StreamSecurityUpgradeInitiator.cs
- UnsafeNativeMethods.cs
- LogSwitch.cs
- ImageField.cs
- Int32KeyFrameCollection.cs
- Executor.cs
- QualificationDataAttribute.cs
- XhtmlBasicPhoneCallAdapter.cs
- InputGestureCollection.cs
- WSTrustFeb2005.cs
- OutputBuffer.cs
- RequestCacheEntry.cs
- DefaultAssemblyResolver.cs
- CodeTypeParameter.cs
- CultureMapper.cs
- RegionIterator.cs
- DBSchemaRow.cs
- CharAnimationUsingKeyFrames.cs
- AliasedSlot.cs
- Stacktrace.cs
- AssociationSetEnd.cs
- DataBindingValueUIHandler.cs
- WmpBitmapEncoder.cs
- TreeNodeCollection.cs
- ReferenceList.cs
- HtmlWindow.cs
- HtmlTableRowCollection.cs
- LineBreak.cs
- sitestring.cs
- PageRouteHandler.cs
- ProfileSection.cs
- SetUserLanguageRequest.cs
- InheritablePropertyChangeInfo.cs
- RepeatEnumerable.cs
- NavigatorInput.cs
- OuterGlowBitmapEffect.cs
- ClientProxyGenerator.cs
- EditingMode.cs
- GridViewCellAutomationPeer.cs
- ToolStripSystemRenderer.cs
- XmlResolver.cs
- WebPartMovingEventArgs.cs
- SqlNotificationEventArgs.cs
- ScriptingProfileServiceSection.cs
- WriteTimeStream.cs
- Comparer.cs
- WindowProviderWrapper.cs
- FrameworkElementAutomationPeer.cs
- RoleGroupCollectionEditor.cs
- GeometryModel3D.cs
- FormsIdentity.cs
- SettingsBindableAttribute.cs
- SqlBuffer.cs
- EventLogPermissionAttribute.cs
- DataGridViewTextBoxEditingControl.cs
- ProgramPublisher.cs
- ToolStripArrowRenderEventArgs.cs
- FlowLayoutPanel.cs
- SerialErrors.cs
- ListBoxItemAutomationPeer.cs
- DataColumnMappingCollection.cs
- NavigationExpr.cs
- EventLogEntryCollection.cs