CompositeActivityMarkupSerializer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Serializer / CompositeActivityMarkupSerializer.cs / 1305376 / CompositeActivityMarkupSerializer.cs

                            namespace System.Workflow.ComponentModel.Serialization 
{
    using System;
    using System.Reflection;
    using System.Collections; 
    using System.Collections.Generic;
    using System.Workflow.ComponentModel.Design; 
    using System.Xml; 

    #region Class CompositeActivityMarkupSerializer 
    public class CompositeActivityMarkupSerializer : ActivityMarkupSerializer
    {
        internal override void OnBeforeSerializeContents(WorkflowMarkupSerializationManager serializationManager, object obj)
        { 
            base.OnBeforeSerializeContents(serializationManager, obj);
 
            //For root activity we will go through all the nested activities and put the namespaces at the top level 
            CompositeActivity compositeActivity = obj as CompositeActivity;
            XmlWriter writer = serializationManager.WorkflowMarkupStack[typeof(XmlWriter)] as XmlWriter; 
            if (compositeActivity.Parent == null && writer != null)
            {
                Dictionary writtenMappings = new Dictionary();
 
                string prefix = String.Empty;
                XmlQualifiedName xmlQualifiedName = serializationManager.GetXmlQualifiedName(compositeActivity.GetType(), out prefix); 
                writtenMappings.Add(xmlQualifiedName.Namespace, compositeActivity); 

                foreach (Activity containedActivity in Helpers.GetNestedActivities(compositeActivity)) 
                {
                    prefix = String.Empty;
                    xmlQualifiedName = serializationManager.GetXmlQualifiedName(containedActivity.GetType(), out prefix);
                    if (!writtenMappings.ContainsKey(xmlQualifiedName.Namespace)) 
                    {
                        writer.WriteAttributeString("xmlns", prefix, null, xmlQualifiedName.Namespace); 
                        writtenMappings.Add(xmlQualifiedName.Namespace, containedActivity); 
                    }
                } 
            }
        }
    }
    #endregion 

} 

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