ActivityCollectionMarkupSerializer.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 / ActivityCollectionMarkupSerializer.cs / 1305376 / ActivityCollectionMarkupSerializer.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 ActivityCollectionMarkupSerializer 
    internal class ActivityCollectionMarkupSerializer : CollectionMarkupSerializer
    {
        protected internal override IList GetChildren(WorkflowMarkupSerializationManager serializationManager, object obj)
        { 
            if (obj == null)
                throw new ArgumentNullException("obj"); 
 
            ActivityCollection activityCollection = obj as ActivityCollection;
            if (activityCollection == null) 
                throw new ArgumentException(SR.GetString(SR.Error_SerializerTypeMismatch, typeof(ActivityCollection).FullName), "obj");

            CompositeActivity compositeActivity = activityCollection.Owner as CompositeActivity;
            if (compositeActivity != null && Helpers.IsCustomActivity(compositeActivity)) 
                return null;
            else 
                return base.GetChildren(serializationManager, obj); 
        }
 
        protected internal override void ClearChildren(WorkflowMarkupSerializationManager serializationManager, object obj)
        {
            //Dont do anything for this call
        } 

        protected internal override void AddChild(WorkflowMarkupSerializationManager serializationManager, object obj, object childObj) 
        { 
            if (obj == null)
                throw new ArgumentNullException("obj"); 
            if (childObj == null)
                throw new ArgumentNullException("childObj");

            ActivityCollection activityCollection = obj as ActivityCollection; 
            if (activityCollection == null)
                throw new ArgumentException(SR.GetString(SR.Error_SerializerTypeMismatch, typeof(ActivityCollection).FullName), "obj"); 
 
            Activity activity = childObj as Activity;
            if (activity == null) 
                throw new InvalidOperationException(SR.GetString(SR.Error_ActivityCollectionSerializer, childObj.GetType().FullName));

            CompositeActivity compositeActivity = activityCollection.Owner as CompositeActivity;
            if (compositeActivity != null) 
            {
                if (Helpers.IsCustomActivity(compositeActivity)) 
                    throw new InvalidOperationException(SR.GetString(SR.Error_CanNotAddActivityInBlackBoxActivity)); 

                base.AddChild(serializationManager, obj, childObj); 
            }
        }
    }
    #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