StateFinalizationActivity.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 / Activities / StateFinalizationActivity.cs / 1305376 / StateFinalizationActivity.cs

                            namespace System.Workflow.Activities 
{
    #region Imports

    using System; 
    using System.Text;
    using System.Reflection; 
    using System.Collections; 
    using System.Collections.Generic;
    using System.CodeDom; 
    using System.ComponentModel;
    using System.ComponentModel.Design;
    using System.Drawing;
    using System.Workflow.ComponentModel; 
    using System.Workflow.ComponentModel.Design;
    using System.Workflow.ComponentModel.Compiler; 
    using System.Workflow.Activities.Common; 

    #endregion 

    [SRDescription(SR.StateFinalizationActivityDescription)]
    [Designer(typeof(StateFinalizationDesigner), typeof(IDesigner))]
    [ToolboxItem(typeof(ActivityToolboxItem))] 
    [ToolboxBitmap(typeof(StateFinalizationActivity), "Resources.StateFinalizationActivity.png")]
    [ActivityValidator(typeof(StateFinalizationValidator))] 
    [SRCategory(SR.Standard)] 
    [System.Runtime.InteropServices.ComVisible(false)]
    public sealed class StateFinalizationActivity : SequenceActivity 
    {
        public StateFinalizationActivity()
        {
        } 

        public StateFinalizationActivity(string name) 
            :base(name) 
        {
        } 
    }

    [System.Runtime.InteropServices.ComVisible(false)]
    internal sealed class StateFinalizationValidator : CompositeActivityValidator 
    {
        public override ValidationErrorCollection Validate(ValidationManager manager, object obj) 
        { 
            ValidationErrorCollection validationErrors = base.Validate(manager, obj);
 
            StateFinalizationActivity stateFinalization = obj as StateFinalizationActivity;
            if (stateFinalization == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(StateFinalizationActivity).FullName), "obj");
 
            StateActivity state = stateFinalization.Parent as StateActivity;
            if (state == null) 
            { 
                validationErrors.Add(new ValidationError(SR.GetError_StateFinalizationParentNotState(), ErrorNumbers.Error_StateHandlerParentNotState));
                return validationErrors; 
            }

            foreach (Activity activity in state.EnabledActivities)
            { 
                StateFinalizationActivity childStateFinalization = activity as StateFinalizationActivity;
                if (childStateFinalization != null) 
                { 
                    if (childStateFinalization == stateFinalization)
                        continue; 

                    validationErrors.Add(new ValidationError(
                        SR.GetError_MultipleStateFinalizationActivities(), ErrorNumbers.Error_MultipleStateFinalizationActivities));
                    break; 
                }
            } 
 
            if (StateMachineHelpers.ContainsEventActivity(stateFinalization))
            { 
                validationErrors.Add(new ValidationError(SR.GetError_EventActivityNotValidInStateFinalization(), ErrorNumbers.Error_EventActivityNotValidInStateHandler));
            }

            return validationErrors; 
        }
    } 
} 

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