ReachPageContentSerializerAsync.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Print / Reach / Serialization / manager / ReachPageContentSerializerAsync.cs / 1 / ReachPageContentSerializerAsync.cs

                            /*++ 

    Copyright (C) 2004- 2005 Microsoft Corporation
    All rights reserved.
 
    Module Name:
        ReachPageContentSerializerAsync.cs 
 
    Abstract:
        This file contains the definition of a class that defines 
        the common functionality required to serialize a PageContent.

    Author:
        [....] ([....]) 25-May-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.Printing;
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 ReachPageContentSerializer.
    ///  
    internal class ReachPageContentSerializerAsync :
                   ReachSerializerAsync 
    { 
        #region Constructor
 
        /// 
        /// Constructor for class ReachPageContentSerializer
        /// 
        ///  
        /// The serialization manager, the services of which are
        /// used later in the serialization process of the type. 
        ///  
        public
        ReachPageContentSerializerAsync( 
            PackageSerializationManager   manager
            ):
        base(manager)
        { 

        } 
 
        #endregion Constructor
 
        #region Public Methods

        /// 
        /// 
        /// 
        public 
        override 
        void
        AsyncOperation( 
            ReachSerializerContext context
            )
        {
            if(context == null) 
            {
 
            } 

            switch (context.Action) 
            {
                case SerializerAction.serializePage:
                {
                    SerializePage(context.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.IsComplexValue) 
            {
                ReachSerializerContext context = new ReachSerializerContext(this,
                                                                            serializableObjectContext,
                                                                            SerializerAction.serializePage); 

                ((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context); 
            } 
            else
            { 
                throw new XpsSerializationException(ReachSR.Get(ReachSRID.ReachSerialization_WrongPropertyTypeForPageContent));
            }
        }
 
        private
        void 
        SerializePage( 
            SerializableObjectContext   serializableObjectContext
            ) 
        {
            FixedPage fixedPage = Toolbox.GetPageRoot(serializableObjectContext.TargetObject);

            if(fixedPage != null) 
            {
                ReachSerializer serializer = SerializationManager.GetSerializer(fixedPage); 
 
                if(serializer!=null)
                { 
                    XpsSerializationPrintTicketRequiredEventArgs e =
                        new XpsSerializationPrintTicketRequiredEventArgs(PrintTicketLevel.FixedPagePrintTicket,
                                                         0);
                    ((XpsSerializationManagerAsync)SerializationManager).OnXPSSerializationPrintTicketRequired(e); 

                    PrintTicket printTicket = null; 
                    if( e.Modified ) 
                    {
                        printTicket =  e.PrintTicket; 
                    }
                    Toolbox.Layout(fixedPage, printTicket);

                    ((XpsSerializationManagerAsync)SerializationManager).FixedPagePrintTicket = printTicket; 

                    serializer.SerializeObject(fixedPage); 
                } 
                else
                { 
                    throw new XpsSerializationException(ReachSR.Get(ReachSRID.ReachSerialization_NoSerializer));
                }
            }
 
        }
 
        #endregion Internal Methods 
    };
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK