Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Packaging / XpsResourcePolicy.cs / 1 / XpsResourcePolicy.cs
/*++
Copyright (C) 2004 - 2005 Microsoft Corporation
All rights reserved.
Module Name:
XpsResourcePolicy.cs
Abstract:
This file contains the definition and implementation
for the XpsResourcePolicy class. This class controls
how resources are shared and serialized within the Xps
package.
Author:
[....] ([....]) 1-December-2004
Revision History:
07/12/2005: [....]: Reach -> Xps
--*/
using System;
using System.Collections.Generic;
using System.Windows.Xps.Serialization;
namespace System.Windows.Xps.Packaging
{
///
///
///
internal class XpsResourcePolicy : IServiceProvider
{
#region Constructors
///
/// Constructs an instance of a XpsResourcePolicy used to
/// determine how Xps resources are shared/stores/converted
/// when being added to the Xps package.
///
public
XpsResourcePolicy(
XpsResourceSharing sharingMode
)
{
_sharingMode = sharingMode;
_imageCrcTable = null;
_imageUriHashTable = null;
_currentPageImageTable = null;
_colorContextTable = null;
_currentPageColorContextTable = null;
_resourceDictionaryTable = null;
_currentPageResourceDictionaryTable = null;
}
#endregion Constructors
#region Public properties
///
/// Gets the current sharing mode for this resource policy.
///
public XpsResourceSharing ResourceSharingMode
{
get
{
return _sharingMode;
}
}
#endregion Public properties
#region Public methods
///
/// This method registers a resource service with this resource
/// policy for use by the packaging and serialization APIs.
///
/// service or serviceType is null..
/// serviceType has already been registered..
public
void
RegisterService(
object service,
Type serviceType
)
{
if (serviceType == null)
{
throw new ArgumentNullException("serviceType");
}
if (service == null)
{
throw new ArgumentNullException("service");
}
if (!_objDict.ContainsKey(serviceType))
{
_objDict.Add(serviceType, service);
}
else if (_objDict[serviceType] != service)
{
throw new XpsPackagingException(ReachSR.Get(ReachSRID.ReachPackaging_ServiceTypeAlreadyAdded, serviceType));
}
}
internal
bool
SubsetComplete(INode node)
{
FontSubsetterCommitPolicies signal = FontSubsetterCommitPolicies.CommitPerPage;
bool validSubsetNode = true;
bool subsetComplete = false;
if( node is IXpsFixedDocumentSequenceWriter )
{
signal = FontSubsetterCommitPolicies.CommitEntireSequence;
}
else
if( node is IXpsFixedDocumentWriter )
{
signal = FontSubsetterCommitPolicies.CommitPerDocument;
}
else
if( node is IXpsFixedPageWriter )
{
signal = FontSubsetterCommitPolicies.CommitPerPage;
}
else
{
validSubsetNode = false;
}
if( validSubsetNode )
{
XpsFontSerializationService fontService = (XpsFontSerializationService)GetService(typeof(XpsFontSerializationService));
if( fontService != null )
{
XpsFontSubsetter fontSubsetter = fontService.FontSubsetter;
subsetComplete = fontSubsetter.CommitFontSubsetsSignal(signal);
}
}
return subsetComplete;
}
#endregion Public methods
#region Protected methods
///
/// Retrieves a service interface given the
/// specified service type.
///
///
/// Service type to retrieve.
///
///
/// A instance of the service interface.
///
internal
object
GetService(
Type serviceType
)
{
object service = null;
if (_objDict.ContainsKey(serviceType))
{
service = _objDict[serviceType];
}
return service;
}
#endregion Protected methods
#region IServiceProvider implementation
object
IServiceProvider.GetService(
Type serviceType
)
{
return GetService(serviceType);
}
#endregion IServiceProvider implementation
#region Internal Properties
internal
Dictionary
ImageCrcTable
{
get
{
return _imageCrcTable;
}
set
{
_imageCrcTable = value;
}
}
internal
Dictionary
ImageUriHashTable
{
get
{
return _imageUriHashTable;
}
set
{
_imageUriHashTable = value;
}
}
internal
Dictionary
CurrentPageImageTable
{
get
{
return _currentPageImageTable;
}
set
{
_currentPageImageTable = value;
}
}
internal
Dictionary
ColorContextTable
{
get
{
return _colorContextTable;
}
set
{
_colorContextTable = value;
}
}
internal
Dictionary
CurrentPageColorContextTable
{
get
{
return _currentPageColorContextTable;
}
set
{
_currentPageColorContextTable = value;
}
}
internal
Dictionary
ResourceDictionaryTable
{
get
{
return _resourceDictionaryTable;
}
set
{
_resourceDictionaryTable = value;
}
}
internal
Dictionary
CurrentPageResourceDictionaryTable
{
get
{
return _currentPageResourceDictionaryTable;
}
set
{
_currentPageResourceDictionaryTable = value;
}
}
#endregion Internal Properties
#region Private data
private
Dictionary _imageCrcTable;
private
Dictionary _imageUriHashTable;
private
Dictionary _currentPageImageTable;
private
Dictionary _colorContextTable;
private
Dictionary _currentPageColorContextTable;
private
Dictionary _resourceDictionaryTable;
private
Dictionary _currentPageResourceDictionaryTable;
private
XpsResourceSharing _sharingMode;
private
Dictionary _objDict = new Dictionary();
#endregion Private data
}
///
///
///
public enum XpsResourceSharing
{
///
///
///
ShareResources = 0,
///
///
///
NoResourceSharing = 1
}
}
// 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
- Size.cs
- CommonXSendMessage.cs
- linebase.cs
- LogEntryHeaderSerializer.cs
- BaseCollection.cs
- TimelineGroup.cs
- Model3DCollection.cs
- PeerNameResolver.cs
- GregorianCalendarHelper.cs
- PersonalizationProvider.cs
- PartialCachingControl.cs
- ProcessProtocolHandler.cs
- UInt64Storage.cs
- Decorator.cs
- AnnotationAdorner.cs
- ListControl.cs
- Line.cs
- RepeatInfo.cs
- XmlSerializerObjectSerializer.cs
- SafeTimerHandle.cs
- sqlmetadatafactory.cs
- NodeFunctions.cs
- SystemException.cs
- LayoutTableCell.cs
- KnownBoxes.cs
- TreeNodeBinding.cs
- XmlAttributes.cs
- XmlEnumAttribute.cs
- XamlClipboardData.cs
- BridgeDataRecord.cs
- PriorityBinding.cs
- ConditionalAttribute.cs
- AuthorizationRuleCollection.cs
- DSACryptoServiceProvider.cs
- WsdlInspector.cs
- metadatamappinghashervisitor.cs
- MasterPage.cs
- MultipartContentParser.cs
- DataAdapter.cs
- WebPartCatalogAddVerb.cs
- MainMenu.cs
- ZipIORawDataFileBlock.cs
- UIElement.cs
- ScrollViewerAutomationPeer.cs
- DataViewManagerListItemTypeDescriptor.cs
- GuidelineSet.cs
- LockCookie.cs
- SecurityTokenResolver.cs
- TypeProvider.cs
- XPathNode.cs
- TransportSecurityBindingElement.cs
- FramingFormat.cs
- FrameDimension.cs
- DbConnectionPoolIdentity.cs
- Cell.cs
- XmlElementAttributes.cs
- SoapCodeExporter.cs
- CriticalFinalizerObject.cs
- XamlClipboardData.cs
- MethodAccessException.cs
- BorderGapMaskConverter.cs
- SynchronizingStream.cs
- DynamicPhysicalDiscoSearcher.cs
- FormatterServicesNoSerializableCheck.cs
- SettingsPropertyCollection.cs
- XmlSchemaInfo.cs
- Pts.cs
- ResourceDescriptionAttribute.cs
- InertiaTranslationBehavior.cs
- EnglishPluralizationService.cs
- CommandEventArgs.cs
- DataListItem.cs
- WebPartDisplayModeCollection.cs
- HierarchicalDataSourceControl.cs
- SqlBulkCopy.cs
- XmlDocumentFragment.cs
- X509Certificate.cs
- EventWaitHandle.cs
- NativeMethods.cs
- BamlLocalizerErrorNotifyEventArgs.cs
- SafeViewOfFileHandle.cs
- DbgUtil.cs
- SchemaImporterExtension.cs
- ErrorWebPart.cs
- FormViewCommandEventArgs.cs
- TileBrush.cs
- RoleManagerEventArgs.cs
- TemplateBaseAction.cs
- WmiEventSink.cs
- ElementUtil.cs
- RtfControlWordInfo.cs
- XmlTypeMapping.cs
- AsnEncodedData.cs
- ForEachAction.cs
- CapabilitiesAssignment.cs
- SerialStream.cs
- ExtendedPropertyDescriptor.cs
- HttpModuleCollection.cs
- AppSettingsSection.cs
- XmlSchemaSequence.cs