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
- SqlMethodCallConverter.cs
- GridItemPattern.cs
- XmlC14NWriter.cs
- FloaterBaseParagraph.cs
- AutoSizeComboBox.cs
- ValidatorCollection.cs
- ValidationErrorInfo.cs
- WorkItem.cs
- Condition.cs
- CommonDialog.cs
- BreakRecordTable.cs
- wmiprovider.cs
- EditorZoneBase.cs
- LOSFormatter.cs
- SaveFileDialog.cs
- PasswordTextNavigator.cs
- ReachSerializableProperties.cs
- StringBuilder.cs
- Transform3D.cs
- ControlAdapter.cs
- PhysicalAddress.cs
- Adorner.cs
- SafeTimerHandle.cs
- PrivilegeNotHeldException.cs
- FamilyTypeface.cs
- MulticastNotSupportedException.cs
- AttributeEmitter.cs
- MonthChangedEventArgs.cs
- Assign.cs
- GridEntryCollection.cs
- DataSourceCacheDurationConverter.cs
- ThreadAbortException.cs
- ConnectionManagementSection.cs
- ProtectedConfigurationProviderCollection.cs
- TreeChangeInfo.cs
- SubpageParagraph.cs
- EntityParameter.cs
- ISAPIWorkerRequest.cs
- WinFormsUtils.cs
- InternalResources.cs
- StateValidator.cs
- FreezableCollection.cs
- PerformanceCounterPermissionEntryCollection.cs
- MetadataArtifactLoaderXmlReaderWrapper.cs
- SystemColorTracker.cs
- AdRotator.cs
- ElementHostPropertyMap.cs
- EventProxy.cs
- Helpers.cs
- WebPartEditVerb.cs
- NativeMethods.cs
- PublisherMembershipCondition.cs
- GeneralTransform3DCollection.cs
- KeyInfo.cs
- GridEntryCollection.cs
- EpmContentSerializer.cs
- EnumerableRowCollectionExtensions.cs
- PaperSource.cs
- XmlBinaryReaderSession.cs
- SoapMessage.cs
- NumberAction.cs
- StrictAndMessageFilter.cs
- AssociationEndMember.cs
- CompilationLock.cs
- ListItemsPage.cs
- ConfigXmlDocument.cs
- CodeTypeParameter.cs
- RepeaterCommandEventArgs.cs
- BulletDecorator.cs
- AsymmetricKeyExchangeDeformatter.cs
- HtmlInputFile.cs
- DelegateTypeInfo.cs
- HistoryEventArgs.cs
- IdentityHolder.cs
- MethodRental.cs
- CalculatedColumn.cs
- CssClassPropertyAttribute.cs
- UnmanagedHandle.cs
- EastAsianLunisolarCalendar.cs
- DataGridCellItemAutomationPeer.cs
- SmtpMail.cs
- LineInfo.cs
- FilteredXmlReader.cs
- NativeMethods.cs
- ClonableStack.cs
- NamespaceDecl.cs
- ConfigurationFileMap.cs
- EmptyStringExpandableObjectConverter.cs
- ChtmlTextWriter.cs
- Literal.cs
- CatalogZone.cs
- ExpressionEditorAttribute.cs
- VisualStyleElement.cs
- ExistsInCollection.cs
- ListBase.cs
- MasterPage.cs
- ping.cs
- DynamicILGenerator.cs
- SqlCacheDependencyDatabaseCollection.cs
- VarRemapper.cs