Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataWeb / Server / System / Data / Services / Serializers / IndentedTextWriter.cs / 1 / IndentedTextWriter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a writer implementation for Json format // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; ///Writes the Json text in indented format. ////// There are many more methods implemented in previous versions /// of this file to handle more type and newline cases. /// internal sealed class IndentedTextWriter : TextWriter { ///writer to which Json text needs to be written private TextWriter writer; ///keeps track of the indentLevel private int indentLevel; ///keeps track of pending tabs private bool tabsPending; ///string representation of tab private string tabString; ////// Creates a new instance of IndentedTextWriter over the given text writer /// /// writer which IndentedTextWriter wraps public IndentedTextWriter(TextWriter writer) : base(CultureInfo.InvariantCulture) { this.writer = writer; this.tabString = " "; } ///Returns the Encoding for the given writer public override Encoding Encoding { get { return this.writer.Encoding; } } ///Returns the new line character public override string NewLine { get { return this.writer.NewLine; } } ///returns the current indent level public int Indent { get { return this.indentLevel; } set { Debug.Assert(value >= 0, "value >= 0"); if (value < 0) { value = 0; } this.indentLevel = value; } } ///Closes the underlying writer public override void Close() { this.writer.Close(); } ///Clears all the buffer of the current writer public override void Flush() { this.writer.Flush(); } ////// Writes the given string value to the underlying writer /// /// string value to be written public override void Write(string s) { this.OutputTabs(); this.writer.Write(s); } ////// Writes the given char value to the underlying writer /// /// char value to be written public override void Write(char value) { this.OutputTabs(); this.writer.Write(value); } ////// Writes the trimmed text if minimizeWhiteSpeace is set to true /// /// string value to be written public void WriteTrimmed(string text) { this.Write(text); } ///Writes the tabs depending on the indent level private void OutputTabs() { if (this.tabsPending) { for (int i = 0; i < this.indentLevel; i++) { this.writer.Write(this.tabString); } this.tabsPending = false; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a writer implementation for Json format // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services.Serializers { using System; using System.Diagnostics; using System.Globalization; using System.IO; using System.Text; ///Writes the Json text in indented format. ////// There are many more methods implemented in previous versions /// of this file to handle more type and newline cases. /// internal sealed class IndentedTextWriter : TextWriter { ///writer to which Json text needs to be written private TextWriter writer; ///keeps track of the indentLevel private int indentLevel; ///keeps track of pending tabs private bool tabsPending; ///string representation of tab private string tabString; ////// Creates a new instance of IndentedTextWriter over the given text writer /// /// writer which IndentedTextWriter wraps public IndentedTextWriter(TextWriter writer) : base(CultureInfo.InvariantCulture) { this.writer = writer; this.tabString = " "; } ///Returns the Encoding for the given writer public override Encoding Encoding { get { return this.writer.Encoding; } } ///Returns the new line character public override string NewLine { get { return this.writer.NewLine; } } ///returns the current indent level public int Indent { get { return this.indentLevel; } set { Debug.Assert(value >= 0, "value >= 0"); if (value < 0) { value = 0; } this.indentLevel = value; } } ///Closes the underlying writer public override void Close() { this.writer.Close(); } ///Clears all the buffer of the current writer public override void Flush() { this.writer.Flush(); } ////// Writes the given string value to the underlying writer /// /// string value to be written public override void Write(string s) { this.OutputTabs(); this.writer.Write(s); } ////// Writes the given char value to the underlying writer /// /// char value to be written public override void Write(char value) { this.OutputTabs(); this.writer.Write(value); } ////// Writes the trimmed text if minimizeWhiteSpeace is set to true /// /// string value to be written public void WriteTrimmed(string text) { this.Write(text); } ///Writes the tabs depending on the indent level private void OutputTabs() { if (this.tabsPending) { for (int i = 0; i < this.indentLevel; i++) { this.writer.Write(this.tabString); } this.tabsPending = false; } } } } // 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
- ErrorEventArgs.cs
- InternalConfigHost.cs
- LocalizabilityAttribute.cs
- CheckBoxRenderer.cs
- GeometryHitTestResult.cs
- BinaryParser.cs
- XslException.cs
- cryptoapiTransform.cs
- XmlFormatExtensionAttribute.cs
- HttpValueCollection.cs
- DesigntimeLicenseContext.cs
- XmlMemberMapping.cs
- RC2CryptoServiceProvider.cs
- XmlReaderDelegator.cs
- Clipboard.cs
- ISFTagAndGuidCache.cs
- Pair.cs
- Visual3D.cs
- Win32MouseDevice.cs
- ArrayHelper.cs
- XamlToRtfParser.cs
- KeyValueConfigurationCollection.cs
- ColumnHeader.cs
- ExtensionSurface.cs
- HostedTransportConfigurationManager.cs
- PixelFormats.cs
- TextShapeableCharacters.cs
- Enum.cs
- Control.cs
- ItemMap.cs
- OdbcReferenceCollection.cs
- SqlDataSourceSelectingEventArgs.cs
- ActiveXHelper.cs
- GridViewAutoFormat.cs
- TypefaceCollection.cs
- WindowsListViewGroupHelper.cs
- ChildChangedEventArgs.cs
- Parsers.cs
- EntryIndex.cs
- QueueProcessor.cs
- PolicyLevel.cs
- MouseGestureConverter.cs
- PrintingPermissionAttribute.cs
- MsmqBindingBase.cs
- SqlEnums.cs
- SafeNativeMethods.cs
- WindowsSysHeader.cs
- HierarchicalDataBoundControlAdapter.cs
- Operand.cs
- ASCIIEncoding.cs
- ConsumerConnectionPointCollection.cs
- Action.cs
- TemplatePropertyEntry.cs
- DPCustomTypeDescriptor.cs
- NonPrimarySelectionGlyph.cs
- ShutDownListener.cs
- DBAsyncResult.cs
- KeyValueInternalCollection.cs
- SAPICategories.cs
- RequestQueryProcessor.cs
- streamingZipPartStream.cs
- ListViewDeleteEventArgs.cs
- CodeMethodReturnStatement.cs
- RequestTimeoutManager.cs
- HashMembershipCondition.cs
- AnalyzedTree.cs
- HtmlForm.cs
- PanelStyle.cs
- ScriptManager.cs
- Socket.cs
- mediaeventshelper.cs
- InternalSafeNativeMethods.cs
- ListViewCommandEventArgs.cs
- CompilationLock.cs
- MergeFilterQuery.cs
- ValueTypeFieldReference.cs
- XamlWriter.cs
- ObjectMaterializedEventArgs.cs
- SoapIgnoreAttribute.cs
- NameValuePermission.cs
- HierarchicalDataBoundControlAdapter.cs
- NativeCppClassAttribute.cs
- UIElement3DAutomationPeer.cs
- LocatorGroup.cs
- XmlNotation.cs
- RequestDescription.cs
- SharedConnectionWorkflowTransactionService.cs
- RouteParametersHelper.cs
- QilStrConcat.cs
- AnnotationAdorner.cs
- SchemaCollectionCompiler.cs
- XmlSerializerNamespaces.cs
- RenderingEventArgs.cs
- Symbol.cs
- HttpProtocolReflector.cs
- DiscreteKeyFrames.cs
- AxHost.cs
- TimelineCollection.cs
- FtpWebRequest.cs
- SessionEndedEventArgs.cs