AppManager.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMSvcHost / System / ServiceModel / Activation / AppManager.cs / 1 / AppManager.cs

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

namespace System.ServiceModel.Activation 
{
    using System; 
    using System.Collections; 
    using System.Collections.Generic;
    using System.Security.Principal; 
    using System.Diagnostics;
    using System.ServiceModel;

    // NOTE: This class is not thread-safe. The caller should perform synchronization. 
    class AppManager
    { 
        Dictionary apps; 
        Dictionary pools;
 
        public AppManager()
        {
            this.apps = new Dictionary();
            this.pools = new Dictionary(); 
        }
 
        public int AppsCount 
        {
            get 
            {
                return this.apps.Count;
            }
        } 

        public Dictionary Apps 
        { 
            get
            { 
                return this.apps;
            }
        }
 
        public Dictionary AppPools
        { 
            get 
            {
                return this.pools; 
            }
        }

        public void CreateAppPool(string appPoolId, SecurityIdentifier sid) 
        {
            AppPool appPool = new AppPool(appPoolId, false, sid); 
            this.pools.Add(appPoolId, appPool); 
        }
 
        public App CreateApp(string appKey, string path, int siteId, string appPoolId, bool requestsBlocked)
        {
            AppPool appPool = this.AppPools[appPoolId];
            App app = new App(appKey, path, siteId, appPool, requestsBlocked); 
            this.apps.Add(appKey, app);
            appPool.AddApp(app); 
 
            return app;
        } 

        public void DeleteAppPool(string appPoolId)
        {
            AppPool pool; 
            if(this.pools.TryGetValue(appPoolId, out pool))
            { 
                if (pool != null) 
                {
                    foreach (App app in pool.SnapshotApps()) 
                    {
                        DeleteApp(app, true);
                    }
 
                    pools.Remove(appPoolId);
                    pool.OnDeleted(); 
                } 
            }
        } 

        public void DeleteApp(App app, bool appPoolDeleted)
        {
            app.AppPool.RemoveApp(app); 
            apps.Remove(app.AppKey);
            app.OnDeleted(appPoolDeleted); 
        } 

        public void Clear() 
        {
            foreach(App app in apps.Values)
            {
                app.OnDeleted(false); 
            }
 
            apps.Clear(); 
            pools.Clear();
        } 
    }
}


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