Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Packaging / XpsResource.cs / 1 / XpsResource.cs
/*++
Copyright (C) 2004 - 2005 Microsoft Corporation
All rights reserved.
Module Name:
XpsResource.cs
Abstract:
This file contains the definition and implementation
for the XpsResource class. This class acts as the
base class for all resources that can be added to a
Xps package.
Author:
[....] ([....]) 1-November-2004
Revision History:
Brian Adleberg ([....] ) 12-July-2005 Reach -> Xps
--*/
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Packaging;
namespace System.Windows.Xps.Packaging
{
///
/// Base class for all Xps Resources
///
/// part is null.
public class XpsResource : XpsPartBase, INode, IDisposable
{
#region Constructors
internal
XpsResource(
XpsManager xpsManager,
INode parent,
PackagePart part
)
: base(xpsManager)
{
if (null == part)
{
throw new ArgumentNullException("part");
}
this.Uri = part.Uri;
_parentNode = parent;
_metroPart = part;
_partEditor = new PartEditor(_metroPart);
}
#endregion Constructors
#region Public methods
///
/// This method retrieves the relative Uri for this resource
/// based on a supplied absolute resource.
///
///
/// Absolute Uri used for conversion.
///
///
/// A Uri to this resource relative to the supplied resource.
///
public
Uri
RelativeUri(
Uri inUri
)
{
if( inUri == null )
{
throw new ArgumentNullException("inUri");
}
return new Uri(XpsManager.MakeRelativePath(this.Uri, inUri), UriKind.Relative);
}
///
/// This method retrieves a reference to the Stream that can
/// be used to read and/or write data to/from this resource
/// within the Metro package.
///
///
/// A reference to a writable/readable stream.
///
public
virtual
Stream
GetStream(
)
{
return _partEditor.DataStream;
}
///
/// This method commits all changes for this resource
///
public
void
Commit(
)
{
CommitInternal();
}
///
/// This method closes this resource part and frees all
/// associated memory.
///
internal
override
void
CommitInternal()
{
if (_partEditor != null)
{
_partEditor.Close();
_partEditor = null;
_metroPart = null;
_parentNode = null;
}
}
#endregion Public methods
#region Private data
private INode _parentNode;
private PackagePart _metroPart;
private PartEditor _partEditor;
#endregion Private data
#region INode implementation
void
INode.Flush(
)
{
if( _partEditor != null )
{
//
// Flush the part editor
//
_partEditor.Flush();
}
}
void
INode.CommitInternal()
{
CommitInternal();
}
PackagePart
INode.GetPart(
)
{
return _metroPart;
}
#endregion INode implementation
#region IDisposable implementation
void
IDisposable.Dispose()
{
if (_partEditor != null)
{
_partEditor.Close();
}
}
#endregion IDisposable implementation
}
}
// 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
- PathFigureCollection.cs
- DynamicPropertyHolder.cs
- KnownTypesProvider.cs
- ParseHttpDate.cs
- RuntimeHandles.cs
- CryptoApi.cs
- XamlStream.cs
- FunctionGenerator.cs
- StatusBarAutomationPeer.cs
- Asn1IntegerConverter.cs
- UnknownBitmapEncoder.cs
- SafePointer.cs
- TextProperties.cs
- TrackingServices.cs
- ProfileInfo.cs
- CdpEqualityComparer.cs
- TransformValueSerializer.cs
- SQLByte.cs
- TrustManagerPromptUI.cs
- Color.cs
- NotCondition.cs
- SingleObjectCollection.cs
- Errors.cs
- xmlfixedPageInfo.cs
- SafeNativeMethods.cs
- ExpressionConverter.cs
- UrlMappingCollection.cs
- OptimizedTemplateContent.cs
- ObjectTokenCategory.cs
- OracleParameterBinding.cs
- SetStoryboardSpeedRatio.cs
- Int32Converter.cs
- SocketStream.cs
- BoundPropertyEntry.cs
- RC2.cs
- ObjRef.cs
- DataKeyArray.cs
- DbExpressionVisitor.cs
- Clock.cs
- HttpException.cs
- DataStreamFromComStream.cs
- LocalizableResourceBuilder.cs
- URL.cs
- StyleCollection.cs
- ConnectionOrientedTransportChannelFactory.cs
- UTF8Encoding.cs
- PostBackTrigger.cs
- ConfigXmlAttribute.cs
- DictionaryContent.cs
- CodeNamespace.cs
- ComplexBindingPropertiesAttribute.cs
- bidPrivateBase.cs
- VisualBasicReference.cs
- SqlBooleanMismatchVisitor.cs
- RepeaterItemCollection.cs
- TableRow.cs
- ContextMenuStrip.cs
- WebPartManagerInternals.cs
- GridErrorDlg.cs
- IgnoreFileBuildProvider.cs
- Span.cs
- GroupPartitionExpr.cs
- DeploymentExceptionMapper.cs
- BitmapEffectInput.cs
- TextEffect.cs
- EntityDataSourceDesignerHelper.cs
- PersonalizablePropertyEntry.cs
- ProfileParameter.cs
- EntityException.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- SafeMILHandle.cs
- Point3DIndependentAnimationStorage.cs
- CommentAction.cs
- MULTI_QI.cs
- SourceFileInfo.cs
- XNodeNavigator.cs
- XPathSelectionIterator.cs
- EntityContainer.cs
- DoubleAnimationClockResource.cs
- HostProtectionException.cs
- SafeCoTaskMem.cs
- BitVector32.cs
- SubMenuStyleCollection.cs
- IpcClientChannel.cs
- EmptyElement.cs
- CellTreeNode.cs
- DataControlPagerLinkButton.cs
- DesignSurfaceEvent.cs
- DetailsViewUpdatedEventArgs.cs
- XmlReflectionImporter.cs
- DataGridViewTopRowAccessibleObject.cs
- AssemblyCollection.cs
- AnnotationService.cs
- BindingCollection.cs
- DateTimeValueSerializer.cs
- DetailsViewDeleteEventArgs.cs
- WebChannelFactory.cs
- clipboard.cs
- GeneralTransform3DCollection.cs
- UnknownBitmapEncoder.cs