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

                            /*++ 

    Copyright (C) 2004- 2005 Microsoft Corporation
    All rights reserved.
 
    Module Name:
        ReachDocumentReferenceCollectionSerializer.cs 
 
    Abstract:
 
    Author:
        [....] ([....]) January 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
{ 
    ///  
    ///
    ///  
    internal class ReachDocumentReferenceCollectionSerializer :
                   ReachSerializer
    {
        ///  
        /// Creates new serializer for a DocumentReferenceCollection
        ///  
        /// serialization manager for this seriaizer 
        public
        ReachDocumentReferenceCollectionSerializer( 
            PackageSerializationManager manager
            ):
        base(manager)
        { 

        } 
 
        /// 
        /// 
        /// 
        internal
        override
        void 
        PersistObjectData(
            SerializableObjectContext   serializableObjectContext 
            ) 
        {
            if (serializableObjectContext == null) 
            {
                throw new ArgumentNullException("serializableObjectContext");
            }
 
            // get DocumentReferenceCollection
            System.Collections.Generic.IEnumerable enumerableObject = serializableObjectContext.TargetObject as System.Collections.Generic.IEnumerable; 
 
            if (enumerableObject == null)
            { 
                throw new XpsSerializationException(ReachSR.Get(ReachSRID.MustBeOfType, "serializableObjectContext.TargetObject", typeof(System.Collections.Generic.IEnumerable)));
            }

            SerializeDocumentReferences(serializableObjectContext); 
        }
 
        ///  
        /// This is being called to serialize the DocumentReference items
        /// contained within the colleciton 
        /// 
        private
        void
        SerializeDocumentReferences( 
            SerializableObjectContext   serializableObjectContext
            ) 
        { 
            //
            // Serialize each DocumentReference in DocumentReferenceColleciton 
            //
            foreach (object documentReference in (System.Collections.Generic.IEnumerable)serializableObjectContext.TargetObject)
            {
                if (documentReference != null) 
                {
                    // Serialize the current item 
                    SerializeDocumentReference(documentReference); 
                }
            } 
        }


        ///  
        ///     Called to serialize a single DocumentReference
        ///  
        private 
        void
        SerializeDocumentReference( 
            object documentReference
            )
        {
            ReachSerializer serializer = SerializationManager.GetSerializer(documentReference); 

            if(serializer!=null) 
            { 
                serializer.SerializeObject(documentReference);
            } 
            else
            {
                // should we throw if this is not a DocumentReference or just not do anything?
                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