ValidationManager.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / Compiler / Validation / ValidationManager.cs / 1305376 / ValidationManager.cs

                            namespace System.Workflow.ComponentModel.Compiler 
{
    #region Imports

    using System; 
    using System.Reflection;
    using System.Collections; 
    using System.Collections.Generic; 
    using System.ComponentModel.Design.Serialization;
 
    #endregion

    public sealed class ValidationManager : IServiceProvider
    { 
        #region Data members
 
        private Hashtable hashOfValidators = new Hashtable(); 
        private IServiceProvider serviceProvider = null;
        private ContextStack context = null; 
        private bool validateChildActivities = true;

        #endregion
 
        #region Constructors
 
        public ValidationManager(IServiceProvider serviceProvider) 
            :
            this(serviceProvider, true) 
        {
        }

        public ValidationManager(IServiceProvider serviceProvider, bool validateChildActivities) 
        {
            this.serviceProvider = serviceProvider; 
            this.validateChildActivities = validateChildActivities; 
        }
 
        #endregion

        #region Public members
 
        public ContextStack Context
        { 
            get 
            {
                if (this.context == null) 
                    this.context = new ContextStack();

                return this.context;
            } 
        }
 
        public bool ValidateChildActivities 
        {
            get 
            {
                return this.validateChildActivities;
            }
        } 

        public Validator[] GetValidators(Type type) 
        { 
            if (this.hashOfValidators.Contains(type))
                return ((List)this.hashOfValidators[type]).ToArray(); 

            List validators = new List();
            foreach (Validator validator in ComponentDispenser.CreateComponents(type, typeof(ActivityValidatorAttribute)))
                validators.Add(validator); 

            this.hashOfValidators[type] = validators; 
            return validators.ToArray(); 
        }
 
        #endregion

        #region IServiceProvider Members
 
        public object GetService(Type serviceType)
        { 
            return this.serviceProvider.GetService(serviceType); 
        }
 
        #endregion
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
namespace System.Workflow.ComponentModel.Compiler 
{
    #region Imports

    using System; 
    using System.Reflection;
    using System.Collections; 
    using System.Collections.Generic; 
    using System.ComponentModel.Design.Serialization;
 
    #endregion

    public sealed class ValidationManager : IServiceProvider
    { 
        #region Data members
 
        private Hashtable hashOfValidators = new Hashtable(); 
        private IServiceProvider serviceProvider = null;
        private ContextStack context = null; 
        private bool validateChildActivities = true;

        #endregion
 
        #region Constructors
 
        public ValidationManager(IServiceProvider serviceProvider) 
            :
            this(serviceProvider, true) 
        {
        }

        public ValidationManager(IServiceProvider serviceProvider, bool validateChildActivities) 
        {
            this.serviceProvider = serviceProvider; 
            this.validateChildActivities = validateChildActivities; 
        }
 
        #endregion

        #region Public members
 
        public ContextStack Context
        { 
            get 
            {
                if (this.context == null) 
                    this.context = new ContextStack();

                return this.context;
            } 
        }
 
        public bool ValidateChildActivities 
        {
            get 
            {
                return this.validateChildActivities;
            }
        } 

        public Validator[] GetValidators(Type type) 
        { 
            if (this.hashOfValidators.Contains(type))
                return ((List)this.hashOfValidators[type]).ToArray(); 

            List validators = new List();
            foreach (Validator validator in ComponentDispenser.CreateComponents(type, typeof(ActivityValidatorAttribute)))
                validators.Add(validator); 

            this.hashOfValidators[type] = validators; 
            return validators.ToArray(); 
        }
 
        #endregion

        #region IServiceProvider Members
 
        public object GetService(Type serviceType)
        { 
            return this.serviceProvider.GetService(serviceType); 
        }
 
        #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