Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Design / system / Data / EntityModel / LazyTextWriterCreator.cs / 1305376 / LazyTextWriterCreator.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.Diagnostics; using System.IO; namespace System.Data.Services.Design { ////// This class is responsible for abstracting the knowledge /// of whether the user provided a TextWriter or a FilePath. /// /// If the user gave us a filePath we try not to create the TextWriter /// till we absolutely need it in order to prevent the file from being created /// in error cases. /// internal class LazyTextWriterCreator : IDisposable { private bool _ownTextWriter; private TextWriter _writer; private string _targetFilePath; internal LazyTextWriterCreator(string targetFilePath) { Debug.Assert(targetFilePath != null, "targetFilePath parameter is null"); _ownTextWriter = true; _targetFilePath = targetFilePath; } internal LazyTextWriterCreator(TextWriter writer) { _writer = writer; } internal TextWriter GetOrCreateTextWriter() { if (_writer == null) { // lazy creating the writer _writer = new StreamWriter(_targetFilePath); } return _writer; } internal string TargetFilePath { get { return _targetFilePath; } } public void Dispose() { if (_ownTextWriter && _writer != null) { _writer.Dispose(); } GC.SuppressFinalize(this); } } } // 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
- Track.cs
- FormViewInsertEventArgs.cs
- EndpointAddressMessageFilter.cs
- FileChangesMonitor.cs
- HttpRuntime.cs
- ValueCollectionParameterReader.cs
- EntryIndex.cs
- AutomationPatternInfo.cs
- ArgumentDirectionHelper.cs
- BadImageFormatException.cs
- CodePropertyReferenceExpression.cs
- NavigateEvent.cs
- MimeMultiPart.cs
- SoapCodeExporter.cs
- WorkflowInvoker.cs
- SimpleRecyclingCache.cs
- HyperLink.cs
- HitTestParameters.cs
- ListViewDeleteEventArgs.cs
- RotateTransform3D.cs
- XNodeNavigator.cs
- XsdDuration.cs
- BuildResult.cs
- TypeInfo.cs
- DesignerGeometryHelper.cs
- XmlSchemaAnnotation.cs
- HandleCollector.cs
- CodeDelegateCreateExpression.cs
- HatchBrush.cs
- CodeMemberProperty.cs
- ComponentResourceKey.cs
- Image.cs
- HttpCapabilitiesBase.cs
- DBAsyncResult.cs
- xmlglyphRunInfo.cs
- UdpRetransmissionSettings.cs
- CallInfo.cs
- DesignerSerializerAttribute.cs
- Timer.cs
- TextBoxView.cs
- MessageQueueCriteria.cs
- DataRowCollection.cs
- ValidationHelpers.cs
- X500Name.cs
- HtmlHead.cs
- NativeMethods.cs
- CheckableControlBaseAdapter.cs
- DocumentPaginator.cs
- XPathMessageFilterElementCollection.cs
- StringSorter.cs
- DataReceivedEventArgs.cs
- FormViewModeEventArgs.cs
- ToolStripDropDownItem.cs
- FtpCachePolicyElement.cs
- CodeBlockBuilder.cs
- ILGenerator.cs
- SafeWaitHandle.cs
- NameValuePair.cs
- XmlWriterTraceListener.cs
- XPathQilFactory.cs
- TagPrefixCollection.cs
- DataRecordInfo.cs
- ListBindingHelper.cs
- TypeElement.cs
- PeerInputChannelListener.cs
- GeometryCombineModeValidation.cs
- PopupControlService.cs
- metadatamappinghashervisitor.cs
- URLIdentityPermission.cs
- EditorZoneBase.cs
- ViewBase.cs
- TopClause.cs
- UnaryNode.cs
- EventHandlingScope.cs
- DecoderExceptionFallback.cs
- DateTimeOffset.cs
- LogSwitch.cs
- ListViewSortEventArgs.cs
- BufferedGraphicsManager.cs
- PeerNearMe.cs
- SchemaExporter.cs
- ElementAtQueryOperator.cs
- PrimarySelectionGlyph.cs
- ExpressionBindings.cs
- DefaultCommandConverter.cs
- ApplicationSecurityInfo.cs
- XmlQueryCardinality.cs
- XmlSerializerFaultFormatter.cs
- MergeFailedEvent.cs
- DbgUtil.cs
- MediaScriptCommandRoutedEventArgs.cs
- COM2PropertyBuilderUITypeEditor.cs
- ToolZone.cs
- ProxyWebPart.cs
- SQLInt32.cs
- ReliableSession.cs
- DataRowView.cs
- ContextMenu.cs
- SystemDiagnosticsSection.cs
- ContainerAction.cs