Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Serialization / manager / ReachUIElementCollectionSerializerAsync.cs / 1 / ReachUIElementCollectionSerializerAsync.cs
/*++
Copyright (C) 2004- 2005 Microsoft Corporation
All rights reserved.
Module Name:
ReachUIElementCollectionSerializerAsync.cs
Abstract:
This file contains the definition of a class that defines
the common functionality required to serialize a
UIElementCollection
Author:
[....] ([....]) 20-May-2004
Revision History:
--*/
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using System.Xml;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.ComponentModel.Design.Serialization;
using System.Windows.Xps.Packaging;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Markup;
namespace System.Windows.Xps.Serialization
{
///
/// Class defining common functionality required to
/// serialize a UIElementCollection.
///
internal class ReachUIElementCollectionSerializerAsync :
ReachSerializerAsync
{
#region Constructor
///
/// Constructor for class ReachUIElementCollectionSerializer
///
///
/// The serialization manager, the services of which are
/// used later in the serialization process of the type.
///
public
ReachUIElementCollectionSerializerAsync(
PackageSerializationManager manager
):
base(manager)
{
}
#endregion Constructor
#region Public Methods
public
override
void
AsyncOperation(
ReachSerializerContext context
)
{
if(context == null)
{
}
switch (context.Action)
{
case SerializerAction.endPersistObjectData:
{
EndPersistObjectData();
break;
}
case SerializerAction.serializeNextUIElement:
{
UIElementCollectionSerializerContext thisContext = context as UIElementCollectionSerializerContext;
if(thisContext != null)
{
SerializeNextUIElement(thisContext.Enumerator,
thisContext.ObjectContext);
}
break;
}
default:
{
base.AsyncOperation(context);
break;
}
}
}
///
/// The main method that is called to serialize a UIElementCollection.
///
///
/// Instance of object to be serialized.
///
public
override
void
SerializeObject(
Object serializedObject
)
{
base.SerializeObject(serializedObject);
}
#endregion Public Methods
#region Internal Methods
///
/// The method is called once the object data is discovered at that
/// point of the serialization process.
///
///
/// The context of the object to be serialized at this time.
///
internal
override
void
PersistObjectData(
SerializableObjectContext serializableObjectContext
)
{
if (serializableObjectContext == null)
{
throw new ArgumentNullException("serializableObjectContext");
}
IEnumerable enumerableObject = serializableObjectContext.TargetObject as IEnumerable;
if (enumerableObject == null)
{
throw new XpsSerializationException(ReachSR.Get(ReachSRID.MustBeOfType, "serializableObjectContext.TargetObject", typeof(IEnumerable)));
}
//
// Serialize the PageContent Items contained within the collection
//
SerializeUIElements(serializableObjectContext);
}
#endregion Internal Methods
#region Private Methods
///
/// This is being called to serialize the Page Content items
/// contained within the collection
///
private
void
SerializeUIElements(
SerializableObjectContext serializableObjectContext
)
{
//
// Serialize each PageContent in PageContentCollection
//
IEnumerator enumerator = ((IEnumerable)serializableObjectContext.TargetObject).GetEnumerator();
enumerator.Reset();
UIElementCollectionSerializerContext context = new UIElementCollectionSerializerContext(this,
serializableObjectContext,
enumerator,
SerializerAction.serializeNextUIElement);
((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);
}
private
void
SerializeNextUIElement(
IEnumerator enumerator,
SerializableObjectContext serializableObjectContext
)
{
if(enumerator.MoveNext())
{
UIElementCollectionSerializerContext context = new UIElementCollectionSerializerContext(this,
serializableObjectContext,
enumerator,
SerializerAction.serializeNextUIElement);
((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);
object uiElement = enumerator.Current;
SerializeUIElement(uiElement);
}
}
///
/// Called to serialize a single UIElement
///
private
void
SerializeUIElement(
object uiElement
)
{
Visual visual = uiElement as Visual;
if(visual != null)
{
ReachSerializer serializer = SerializationManager.GetSerializer(visual);
if(serializer!=null)
{
serializer.SerializeObject(visual);
}
else
{
throw new XpsSerializationException(ReachSR.Get(ReachSRID.ReachSerialization_NoSerializer));
}
}
}
#endregion Private Methods
};
internal class UIElementCollectionSerializerContext :
ReachSerializerContext
{
public
UIElementCollectionSerializerContext(
ReachSerializerAsync serializer,
SerializableObjectContext objectContext,
IEnumerator enumerator,
SerializerAction action
):
base(serializer,objectContext,action)
{
this._enumerator = enumerator;
}
public
IEnumerator
Enumerator
{
get
{
return _enumerator;
}
}
private
IEnumerator _enumerator;
};
}
// 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
- ProfileSection.cs
- WmpBitmapEncoder.cs
- StreamGeometryContext.cs
- EntityProviderFactory.cs
- DBCommandBuilder.cs
- DbCommandDefinition.cs
- TypeConstant.cs
- LinkConverter.cs
- ProcessThreadDesigner.cs
- CodeExpressionStatement.cs
- ApplicationManager.cs
- ValidatedControlConverter.cs
- EmptyReadOnlyDictionaryInternal.cs
- InheritanceService.cs
- PerformanceCounterPermissionEntry.cs
- SortableBindingList.cs
- SoapAttributes.cs
- DataProtection.cs
- WindowsGraphicsCacheManager.cs
- ImageDrawing.cs
- CollectionViewProxy.cs
- SocketAddress.cs
- TogglePattern.cs
- Converter.cs
- XpsFont.cs
- ResourcesBuildProvider.cs
- DispatcherProcessingDisabled.cs
- EndOfStreamException.cs
- SerializerProvider.cs
- PasswordDeriveBytes.cs
- EntityDataSourceQueryBuilder.cs
- MouseActionConverter.cs
- SmtpMail.cs
- TrackingDataItemValue.cs
- Codec.cs
- XmlNodeList.cs
- dataprotectionpermission.cs
- ServiceDescriptionReflector.cs
- ReachDocumentReferenceSerializerAsync.cs
- Activity.cs
- WindowsAltTab.cs
- DateTimeFormatInfoScanner.cs
- NavigatorInput.cs
- ApplicationServiceManager.cs
- EventMemberCodeDomSerializer.cs
- ObjectListShowCommandsEventArgs.cs
- StickyNoteAnnotations.cs
- SpellerError.cs
- SrgsRulesCollection.cs
- AxisAngleRotation3D.cs
- UserCancellationException.cs
- LinearKeyFrames.cs
- WindowsSlider.cs
- UserControl.cs
- ReaderWriterLockWrapper.cs
- MorphHelpers.cs
- KeysConverter.cs
- ColorComboBox.cs
- LogLogRecordEnumerator.cs
- SerialStream.cs
- BamlCollectionHolder.cs
- EditorServiceContext.cs
- PaperSource.cs
- NextPreviousPagerField.cs
- HttpRawResponse.cs
- DataRecordObjectView.cs
- CatalogPart.cs
- SafeLibraryHandle.cs
- RequestQueryParser.cs
- IsolatedStorageFilePermission.cs
- BypassElement.cs
- MenuItem.cs
- DoubleConverter.cs
- StrongNameKeyPair.cs
- Pair.cs
- Blend.cs
- ToolStripStatusLabel.cs
- Boolean.cs
- ResourceExpression.cs
- CodeActivityContext.cs
- ExtenderHelpers.cs
- CounterCreationDataCollection.cs
- IssuanceLicense.cs
- EntityDataSourceWizardForm.cs
- DecimalAnimationUsingKeyFrames.cs
- BitmapVisualManager.cs
- DateTimeFormatInfo.cs
- shaperfactoryquerycacheentry.cs
- HtmlUtf8RawTextWriter.cs
- SafeNativeMethodsCLR.cs
- Boolean.cs
- ImageListImageEditor.cs
- LiteralLink.cs
- XamlPointCollectionSerializer.cs
- WindowsSolidBrush.cs
- VSDExceptions.cs
- ClientSettingsStore.cs
- HScrollProperties.cs
- CultureSpecificStringDictionary.cs
- WriteableOnDemandStream.cs