Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Serialization / manager / NGCPageContentCollectionSerializerAsync.cs / 1 / NGCPageContentCollectionSerializerAsync.cs
/*++ Copyright (C) 2004- 2005 Microsoft Corporation All rights reserved. Module Name: NGCPageContentCollectionSerializerAsync.cs Abstract: This file contains the definition of a class that defines the common functionality required to serialize a PageContentCollection Author: [....] ([....]) 1-June-2005 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 PageContentCollectionSerializer. /// internal class NgcPageContentCollectionSerializerAsync : NGCSerializerAsync { #region Constructor ////// Constructor for class ReachPageContentCollectionSerializer /// /// /// The serialization manager, the services of which are /// used later in the serialization process of the type. /// public NgcPageContentCollectionSerializerAsync( PackageSerializationManager manager ): base(manager) { } #endregion Constructor #region Public Mehods public override void AsyncOperation( NGCSerializerContext context ) { if(context == null) { } switch (context.Action) { case SerializerAction.endPersistObjectData: { EndPersistObjectData(); break; } case SerializerAction.serializeNextPageContent: { NgcPageContentCollectionSerializerContext thisContext = context as NgcPageContentCollectionSerializerContext; if(thisContext != null) { SerializeNextPageContent(thisContext.Enumerator, thisContext.ObjectContext); } break; } default: { base.AsyncOperation(context); break; } } } #endregion #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 // SerializePageContents(serializableObjectContext); } internal override void EndPersistObjectData( ) { // // do nothing in this stage // } #endregion Internal Methods #region Private Methods ////// This is being called to serialize the Page Content items /// contained within the collection /// /// /// The context of the object to be serialized at this time. /// private void SerializePageContents( SerializableObjectContext serializableObjectContext ) { // // Serialize each PageContent in PageContentColleciton // IEnumerator enumerator = ((IEnumerable)serializableObjectContext.TargetObject).GetEnumerator(); enumerator.Reset(); NgcPageContentCollectionSerializerContext context = new NgcPageContentCollectionSerializerContext(this, serializableObjectContext, enumerator, SerializerAction.serializeNextPageContent); ((NgcSerializationManagerAsync)SerializationManager).OperationStack.Push(context); } private void SerializeNextPageContent( IEnumerator enumerator, SerializableObjectContext serializableObjectContext ) { if(enumerator.MoveNext()) { NgcPageContentCollectionSerializerContext context = new NgcPageContentCollectionSerializerContext(this, serializableObjectContext, enumerator, SerializerAction.serializeNextPageContent); ((NgcSerializationManagerAsync)SerializationManager).OperationStack.Push(context); object pageContent = enumerator.Current; SerializePageContent(pageContent); } } ////// Called to serialize a single PageContent /// /// /// The PageContent to be serialized. /// private void SerializePageContent( object pageContent ) { ReachSerializer serializer = SerializationManager.GetSerializer(pageContent); if(serializer!=null) { serializer.SerializeObject(pageContent); } else { throw new XpsSerializationException(ReachSR.Get(ReachSRID.ReachSerialization_NoSerializer)); } } #endregion Private Methods }; internal class NgcPageContentCollectionSerializerContext : NGCSerializerContext { public NgcPageContentCollectionSerializerContext( NGCSerializerAsync 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
- ExtensionsSection.cs
- BezierSegment.cs
- WMIGenerator.cs
- Int16Storage.cs
- PropertyChangingEventArgs.cs
- DataTableNewRowEvent.cs
- TypeConstant.cs
- HashMembershipCondition.cs
- ServiceOperationListItem.cs
- DataGridViewRowCollection.cs
- URLString.cs
- ObjectItemCollection.cs
- FixedTextSelectionProcessor.cs
- TableProviderWrapper.cs
- SQLCharsStorage.cs
- CurrentChangingEventManager.cs
- System.Data.OracleClient_BID.cs
- SettingsBase.cs
- EntityRecordInfo.cs
- Utility.cs
- BinaryCommonClasses.cs
- DataBindingExpressionBuilder.cs
- Operand.cs
- EncodingInfo.cs
- ProfileManager.cs
- SqlInfoMessageEvent.cs
- PaperSize.cs
- GlobalAllocSafeHandle.cs
- DataBoundLiteralControl.cs
- BaseInfoTable.cs
- TraceSwitch.cs
- ToolStripPanelRow.cs
- RtfToken.cs
- SmiContext.cs
- BackgroundFormatInfo.cs
- TableCellsCollectionEditor.cs
- HealthMonitoringSection.cs
- MailDefinition.cs
- XmlNodeReader.cs
- DataExchangeServiceBinder.cs
- cookieexception.cs
- ListBoxAutomationPeer.cs
- InputScope.cs
- MethodBuilderInstantiation.cs
- CLSCompliantAttribute.cs
- JsonObjectDataContract.cs
- TemplateNameScope.cs
- SyndicationElementExtensionCollection.cs
- GroupItem.cs
- DataListCommandEventArgs.cs
- WebPartAuthorizationEventArgs.cs
- GridViewUpdatedEventArgs.cs
- TabControlCancelEvent.cs
- PreloadedPackages.cs
- FieldNameLookup.cs
- WebPartConnectionsConfigureVerb.cs
- HtmlToClrEventProxy.cs
- __ComObject.cs
- RegexRunner.cs
- ExpressionCopier.cs
- ClickablePoint.cs
- IndentedTextWriter.cs
- FontNameConverter.cs
- Point3DCollectionConverter.cs
- BehaviorEditorPart.cs
- ViewManager.cs
- SqlError.cs
- OperandQuery.cs
- SamlSecurityToken.cs
- GridViewSelectEventArgs.cs
- TaskbarItemInfo.cs
- _LazyAsyncResult.cs
- Membership.cs
- CodeIterationStatement.cs
- Icon.cs
- ProcessHostMapPath.cs
- regiisutil.cs
- FixedSOMPage.cs
- SamlSubjectStatement.cs
- SafeEventLogReadHandle.cs
- SmiSettersStream.cs
- ListContractAdapter.cs
- SpellerError.cs
- DataGridViewCellFormattingEventArgs.cs
- ConsoleKeyInfo.cs
- HTMLTextWriter.cs
- EmbeddedMailObject.cs
- MostlySingletonList.cs
- WebPartVerbsEventArgs.cs
- SRef.cs
- CompilationLock.cs
- FullTextState.cs
- WsatTransactionFormatter.cs
- ColumnHeader.cs
- CharConverter.cs
- FrameworkReadOnlyPropertyMetadata.cs
- DocumentSchemaValidator.cs
- FontStyles.cs
- WorkflowRuntime.cs
- DeflateInput.cs