DelegateCompletionCallbackWrapper.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.Activities / System / Activities / Runtime / DelegateCompletionCallbackWrapper.cs / 1305376 / DelegateCompletionCallbackWrapper.cs

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

namespace System.Activities.Runtime 
{
    using System; 
    using System.Collections.Generic; 
    using System.Runtime;
    using System.Runtime.Serialization; 
    using System.Security;

    [DataContract]
    class DelegateCompletionCallbackWrapper : CompletionCallbackWrapper 
    {
        static Type callbackType = typeof(DelegateCompletionCallback); 
        static Type[] callbackParameterTypes = new Type [] {typeof(NativeActivityContext), typeof(ActivityInstance), typeof(IDictionary)}; 

        [DataMember(EmitDefaultValue = false)] 
        Dictionary results;

        public DelegateCompletionCallbackWrapper(DelegateCompletionCallback callback, ActivityInstance owningInstance)
            : base(callback, owningInstance) 
        {
            this.NeedsToGatherOutputs = true; 
        } 

        protected override void GatherOutputs(ActivityInstance completedInstance) 
        {
            if (completedInstance.Activity.HandlerOf != null)
            {
                IList runtimeArguments = completedInstance.Activity.HandlerOf.RuntimeDelegateArguments; 
                LocationEnvironment environment = completedInstance.Environment;
 
                for (int i = 0; i < runtimeArguments.Count; i++) 
                {
                    RuntimeDelegateArgument runtimeArgument = runtimeArguments[i]; 

                    if (runtimeArgument.BoundArgument != null)
                    {
                        if (ArgumentDirectionHelper.IsOut(runtimeArgument.Direction)) 
                        {
                            Location parameterLocation = environment.GetSpecificLocation(runtimeArgument.BoundArgument.Id); 
 
                            if (parameterLocation != null)
                            { 
                                if (this.results == null)
                                {
                                    this.results = new Dictionary();
                                } 

                                this.results.Add(runtimeArgument.Name, parameterLocation.Value); 
                            } 
                        }
                    } 
                }
            }
        }
 
        protected internal override void Invoke(NativeActivityContext context, ActivityInstance completedInstance)
        { 
            EnsureCallback(callbackType, callbackParameterTypes); 
            DelegateCompletionCallback completionCallback = (DelegateCompletionCallback)this.Callback;
 
            IDictionary returnValue = this.results;

            if (returnValue == null)
            { 
                returnValue = ActivityUtilities.EmptyParameters;
            } 
 
            completionCallback(context, completedInstance, returnValue);
        } 

    }
}

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