ReachDocumentReferenceSerializerAsync.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 / ReachDocumentReferenceSerializerAsync.cs / 1 / ReachDocumentReferenceSerializerAsync.cs

                            /*++ 

    Copyright (C) 2004- 2005 Microsoft Corporation
    All rights reserved.
 
    Module Name:
        ReachDocumentReferenceSerializerAsync.cs 
 
    Abstract:
 
    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.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;
using System.Windows.Threading; 

namespace System.Windows.Xps.Serialization 
{ 
    /// 
    /// 
    /// 
    internal class ReachDocumentReferenceSerializerAsync :
                   ReachSerializerAsync
    { 
        /// 
        /// Creates a new serailizer for a DocumentReference 
        ///  
        /// serialization manager
        public 
        ReachDocumentReferenceSerializerAsync(
            PackageSerializationManager   manager
            ):
        base(manager) 
        {
 
        } 

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

            } 

            switch (context.Action) 
            { 
                case SerializerAction.serializeDocument:
                { 
                    SerializeDocument(context.ObjectContext);
                    break;
                }
 
                default:
                { 
                    base.AsyncOperation(context); 
                    break;
                } 
            }
        }

        ///  
        ///
        ///  
        internal 
        override
        void 
        PersistObjectData(
            SerializableObjectContext   serializableObjectContext
            )
        { 
            if(serializableObjectContext.IsComplexValue)
            { 
 
                ReachSerializerContext context = new ReachSerializerContext(this,
                                                                            serializableObjectContext, 
                                                                            SerializerAction.serializeDocument);

                ((XpsSerializationManagerAsync)SerializationManager).OperationStack.Push(context);
 
                SerializeObjectCore(serializableObjectContext);
            } 
            else 
            {
                // What about this case?  Is IsComplexValue something we really want to check for this? 
            }
        }

        private object Idle(object sender) 
        {
            return null; 
        } 

        ///  
        ///
        /// 
        private
        void 
        SerializeDocument(
            SerializableObjectContext   serializableObjectContext 
            ) 
        {
            // 
            // Loads the document
            //
            FixedDocument document =
            ((DocumentReference)serializableObjectContext.TargetObject).GetDocument(false); 

            if (document.IsInitialized == false) 
            { 
                // Give a parser item a kick
                document.Dispatcher.Invoke(DispatcherPriority.ApplicationIdle, 
                    new DispatcherOperationCallback(Idle), null);
            }

            if (document != null) 
            {
                ReachSerializer serializer = SerializationManager.GetSerializer(document); 
 
                if(serializer!=null)
                { 
                    serializer.SerializeObject(document);
                }
                else
                { 
                    //
                    // This shouldn't ever happen. 
                    // 
                    throw new XpsSerializationException(ReachSR.Get(ReachSRID.ReachSerialization_NoSerializer));
                } 
            }

        }
    }; 
}

// 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