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
- TransformGroup.cs
- ToolStripItemDesigner.cs
- ChangeBlockUndoRecord.cs
- IIS7ConfigurationLoader.cs
- BuildResultCache.cs
- EdgeModeValidation.cs
- UriScheme.cs
- LinqDataSourceContextData.cs
- XmlHierarchyData.cs
- RuntimeConfigLKG.cs
- BrowserDefinition.cs
- ClientRolePrincipal.cs
- RowUpdatedEventArgs.cs
- hresults.cs
- OleDbFactory.cs
- LoginCancelEventArgs.cs
- Bezier.cs
- ToolStripItemDesigner.cs
- ComboBox.cs
- ToolStripItemTextRenderEventArgs.cs
- ModelItemCollection.cs
- HorizontalAlignConverter.cs
- PropertyGridEditorPart.cs
- AssemblyName.cs
- DetailsView.cs
- SecurityElement.cs
- ItemMap.cs
- XmlUnspecifiedAttribute.cs
- ImageCollectionEditor.cs
- SecurityElement.cs
- DbSetClause.cs
- Application.cs
- EntitySqlException.cs
- ThreadExceptionDialog.cs
- PriorityQueue.cs
- WebBrowserDocumentCompletedEventHandler.cs
- BitmapSourceSafeMILHandle.cs
- VirtualPath.cs
- BitmapSizeOptions.cs
- SystemResourceHost.cs
- NamedPipeAppDomainProtocolHandler.cs
- WebServiceEnumData.cs
- DataTableMapping.cs
- ProxySimple.cs
- XmlSchemaGroup.cs
- XmlSchemaAppInfo.cs
- ToolStripItemRenderEventArgs.cs
- Wow64ConfigurationLoader.cs
- SessionEndingEventArgs.cs
- DataGridViewRowConverter.cs
- WorkflowDesigner.cs
- PeerCollaborationPermission.cs
- ValuePatternIdentifiers.cs
- AuthorizationRule.cs
- XsltArgumentList.cs
- EndPoint.cs
- iisPickupDirectory.cs
- XmlSerializerVersionAttribute.cs
- TypeInitializationException.cs
- Win32PrintDialog.cs
- HtmlTableRow.cs
- TraceSection.cs
- DoubleKeyFrameCollection.cs
- TagMapCollection.cs
- Tokenizer.cs
- _OverlappedAsyncResult.cs
- ThreadAttributes.cs
- SiteOfOriginPart.cs
- CharAnimationUsingKeyFrames.cs
- WebPartCatalogCloseVerb.cs
- ComponentDispatcher.cs
- HttpCachePolicyElement.cs
- CompiledELinqQueryState.cs
- SamlAttributeStatement.cs
- Maps.cs
- NotifyCollectionChangedEventArgs.cs
- XmlCompatibilityReader.cs
- MaterialGroup.cs
- PartialCachingControl.cs
- BitmapDecoder.cs
- GenerateScriptTypeAttribute.cs
- TextPenaltyModule.cs
- WsatProxy.cs
- RegexGroupCollection.cs
- StorageAssociationSetMapping.cs
- HttpConfigurationSystem.cs
- RectangleHotSpot.cs
- TextEditorParagraphs.cs
- FrugalMap.cs
- HwndHost.cs
- MessageFault.cs
- ClassDataContract.cs
- PolyQuadraticBezierSegment.cs
- InkCollectionBehavior.cs
- CacheEntry.cs
- LassoSelectionBehavior.cs
- PermissionRequestEvidence.cs
- XmlDocumentFieldSchema.cs
- SchemaMerger.cs
- DataGridViewComboBoxColumn.cs