InitializeCorrelation.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 / NetFx40 / System.ServiceModel.Activities / System / ServiceModel / Activities / InitializeCorrelation.cs / 1305376 / InitializeCorrelation.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Activities 
{
    using System; 
    using System.Activities; 
    using System.Collections.Generic;
    using System.Runtime.DurableInstancing; 
    using System.ServiceModel.Activities.Dispatcher;
    using SR2 = System.ServiceModel.Activities.SR;
    using System.ComponentModel;
    using System.Windows.Markup; 
    using System.Runtime.Collections;
    using System.Runtime; 
 
    [ContentProperty("CorrelationData")]
    public sealed class InitializeCorrelation : NativeActivity 
    {
        public InitializeCorrelation()
        {
            this.CorrelationData = new OrderedDictionary>(); 
        }
 
        [DefaultValue(null)] 
        public InArgument Correlation
        { 
            get;
            set;
        }
 
        public IDictionary> CorrelationData
        { 
            get; 
            private set;
        } 

        protected override void Execute(NativeActivityContext context)
        {
            CorrelationHandle correlationHandle = (this.Correlation == null) ? null : this.Correlation.Get(context); 

            if (correlationHandle == null) 
            { 
                //throw only if ambient correlation handle is also null
                correlationHandle = context.Properties.Find(CorrelationHandle.StaticExecutionPropertyName) as CorrelationHandle; 
                if (correlationHandle == null)
                {
                    throw FxTrace.Exception.AsError(
                        new InvalidOperationException(SR2.NullCorrelationHandleInInitializeCorrelation(this.DisplayName))); 
                }
            } 
 
            CorrelationExtension extension = context.GetExtension();
            if (extension != null) 
            {
                Dictionary dictionary = new Dictionary();
                foreach ( KeyValuePair> pair in this.CorrelationData )
                { 
                    Fx.Assert(pair.Value != null, "pair.Value should be validated during cache metadata");
                    dictionary.Add(pair.Key, pair.Value.Get(context)); 
                } 

                correlationHandle.InitializeBookmarkScope(context, extension.GenerateKey(dictionary)); 
            }
            else
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR2.InitializeCorrelationRequiresWorkflowServiceHost(this.DisplayName))); 
            }
        } 
 
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.


                        

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