Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / TrustUi / MS / Internal / documents / Application / StreamDocument.cs / 1 / StreamDocument.cs
//------------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Extends Document with a support for StreamProxy versus simply stream.
//
//
// History:
// 08/28/2005: [....]: Initial implementation.
//-----------------------------------------------------------------------------
using System.IO;
using System.Security;
namespace MS.Internal.Documents.Application
{
///
/// Extends Document with a support for StreamProxy versus simply stream.
///
/// The type of stream to back the document with.
///
internal class StreamDocument : Document where T : StreamProxy
{
#region Constructors
//-------------------------------------------------------------------------
// Constructors
//-------------------------------------------------------------------------
internal StreamDocument(Document dependency)
: base(dependency) { }
#endregion Constructors
#region Internal Properties
//--------------------------------------------------------------------------
// Internal Properties
//-------------------------------------------------------------------------
///
///
///
internal override Stream Destination
{
get { return _destination.Value; }
}
///
/// The T that is backing the Destination stream.
///
///
/// Critical:
/// - set critical field
/// - field is critical as security descisions are based on it
/// - audit only DocumentControllers & self should set
///
internal T DestinationProxy
{
get { return _destination.Value; }
[SecurityCritical]
set { _destination.Value = value; }
}
///
///
///
internal override Stream Source
{
get { return _source.Value; }
}
///
/// The T that is backing the Source stream.
///
///
/// Critical:
/// - set critical field
/// - field is critical as security descisions are based on it
/// - audit only DocumentControllers & self should set
///
internal T SourceProxy
{
get { return _source.Value; }
[SecurityCritical]
set { _source.Value = value; }
}
///
///
///
internal override Stream Workspace
{
get { return _workspace.Value; }
}
///
/// The T that is backing the Workspace stream.
///
///
/// Critical:
/// - set critical field
/// - field is critical as security descisions are based on it
/// - audit only DocumentControllers & self should set
///
internal T WorkspaceProxy
{
get { return _workspace.Value; }
[SecurityCritical]
set { _workspace.Value = value; }
}
#endregion Internal Properties
#region Protected Methods
//--------------------------------------------------------------------------
// Protected Methods
//--------------------------------------------------------------------------
///
/// Will close streams in the reverse order of intended creation.
///
///
/// Critical
/// 1) Calling critical property setters *Proxy.
/// TreatAsSafe
/// 1) Setting them to known safe value null.
///
[SecurityCritical, SecurityTreatAsSafe]
protected void ReleaseStreams()
{
try
{
// closing in revers order of creation
if (DestinationProxy != null)
{
if (DestinationProxy == SourceProxy)
{
SourceProxy = null;
}
DestinationProxy.Close();
DestinationProxy = null;
}
}
finally
{
try
{
if (WorkspaceProxy != null)
{
WorkspaceProxy.Close();
WorkspaceProxy = null;
}
}
finally
{
if (SourceProxy != null)
{
SourceProxy.Close();
SourceProxy = null;
}
}
}
}
#endregion Protected Methods
#region IDisposable Members
//-------------------------------------------------------------------------
// IDisposable Members
//--------------------------------------------------------------------------
///
///
///
protected override void Dispose(bool disposing)
{
try
{
if (disposing)
{
ReleaseStreams();
}
}
finally
{
base.Dispose(true);
}
}
#endregion IDisposable Members
#region Private Fields
//-------------------------------------------------------------------------
// Private Fields
//-------------------------------------------------------------------------
private SecurityCriticalDataForSet _destination =
new SecurityCriticalDataForSet();
private SecurityCriticalDataForSet _source =
new SecurityCriticalDataForSet();
private SecurityCriticalDataForSet _workspace =
new SecurityCriticalDataForSet();
#endregion Private Fields
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SelectionPatternIdentifiers.cs
- Signature.cs
- InputScopeManager.cs
- X509Certificate2.cs
- AssertUtility.cs
- AsnEncodedData.cs
- DashStyles.cs
- MostlySingletonList.cs
- ExpressionReplacer.cs
- TrustManager.cs
- PeerToPeerException.cs
- PageSettings.cs
- XmlDataLoader.cs
- PropertyBuilder.cs
- ParameterBuilder.cs
- HostedTransportConfigurationManager.cs
- TransactionScopeDesigner.cs
- MailWebEventProvider.cs
- CompatibleIComparer.cs
- ToolStripSeparator.cs
- ExpressionBuilderCollection.cs
- ClientSponsor.cs
- SchemaElement.cs
- UpdateCompiler.cs
- sqlstateclientmanager.cs
- ResolveDuplex11AsyncResult.cs
- SmtpReplyReaderFactory.cs
- HiddenFieldPageStatePersister.cs
- XPathSingletonIterator.cs
- OutputWindow.cs
- ListViewCancelEventArgs.cs
- ElementNotAvailableException.cs
- DbConnectionPoolGroup.cs
- EditingScope.cs
- DetailsViewPagerRow.cs
- BaseTransportHeaders.cs
- Baml2006ReaderSettings.cs
- CacheMode.cs
- DocumentXPathNavigator.cs
- RestHandler.cs
- KeyedHashAlgorithm.cs
- StructuralCache.cs
- StrokeSerializer.cs
- MarginsConverter.cs
- AssemblyName.cs
- WsdlInspector.cs
- InvalidateEvent.cs
- SyndicationLink.cs
- ClientBuildManagerCallback.cs
- DecoderReplacementFallback.cs
- EntityDesignerBuildProvider.cs
- HashMembershipCondition.cs
- SecurityBindingElementImporter.cs
- WmfPlaceableFileHeader.cs
- XmlSchemaChoice.cs
- DefaultProxySection.cs
- ChunkedMemoryStream.cs
- WsatServiceCertificate.cs
- Odbc32.cs
- ApplicationFileParser.cs
- SecurityTokenRequirement.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- OperationContractGenerationContext.cs
- SiteMapNodeCollection.cs
- linebase.cs
- HtmlInputPassword.cs
- InertiaTranslationBehavior.cs
- WebControl.cs
- EnterpriseServicesHelper.cs
- NavigationPropertyEmitter.cs
- RefType.cs
- HashCodeCombiner.cs
- FormViewPageEventArgs.cs
- ValidatorCompatibilityHelper.cs
- SymLanguageVendor.cs
- Transform3D.cs
- HttpValueCollection.cs
- HtmlObjectListAdapter.cs
- PopOutPanel.cs
- PropertyPath.cs
- UniqueConstraint.cs
- SettingsSection.cs
- HttpWebRequestElement.cs
- TreeNodeConverter.cs
- PresentationAppDomainManager.cs
- EdmTypeAttribute.cs
- unsafeIndexingFilterStream.cs
- ServiceOperationUIEditor.cs
- StringStorage.cs
- HttpInputStream.cs
- DataIdProcessor.cs
- PreApplicationStartMethodAttribute.cs
- PageSettings.cs
- WindowCollection.cs
- Exceptions.cs
- WindowsSpinner.cs
- ComponentDispatcher.cs
- UserControlParser.cs
- TextBoxView.cs
- FixedSOMPageConstructor.cs