BuildProviderInstallComponent.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 / Tools / xws_reg / System / ServiceModel / Install / Configuration / BuildProviderInstallComponent.cs / 1 / BuildProviderInstallComponent.cs

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

namespace System.ServiceModel.Install.Configuration 
{
    using System; 
    using System.Collections.Generic; 
    using System.Configuration;
    using System.Text; 
    using System.Web.Configuration;
    using System.Xml;

    internal class BuildProviderInstallComponent : ServiceModelInstallComponent 
    {
        ConfigurationLoader configLoader; 
        string displayString; 

        BuildProviderInstallComponent(ConfigurationLoader configLoader) 
        {
            this.configLoader = configLoader;
        }
 
        internal override string DisplayName
        { 
            get {return this.displayString; } 
        }
 
        protected override string InstallActionMessage
        {
            get {return SR.GetString(SR.BuildProviderInstall, ServiceModelInstallStrings.BuildProvidersType); }
        } 

        internal override string[] InstalledVersions 
        { 
            get
            { 
                List installedVersions = new List();

                if (null != configLoader.SystemWebSectionGroup)
                { 
                    foreach (string buildProviderExtension in ServiceModelInstallStrings.BuildProviderExtensionValues)
                    { 
                        BuildProvider buildProvider = configLoader.SystemWebSectionGroup.Compilation.BuildProviders[buildProviderExtension]; 
                        if (null != buildProvider)
                        { 
                            string versionString = InstallHelper.GetVersionStringFromTypeString(buildProvider.Type);

                            if (!String.IsNullOrEmpty(versionString))
                            { 
                                installedVersions.Add(versionString);
                            } 
                        } 
                    }
                } 

                return installedVersions.ToArray();
            }
        } 

        internal override bool IsInstalled 
        { 
            get
            { 
                if (null != configLoader.SystemWebSectionGroup)
                {
                    foreach (string buildProviderExtension in ServiceModelInstallStrings.BuildProviderExtensionValues)
                    { 
                        BuildProvider buildProvider = configLoader.SystemWebSectionGroup.Compilation.BuildProviders[buildProviderExtension];
                        if (null != buildProvider) 
                        { 
                            return true;
                        } 
                    }
                }

                return false; 
            }
        } 
 
        protected override string ReinstallActionMessage
        { 
            get {return SR.GetString(SR.BuildProviderInstall, ServiceModelInstallStrings.BuildProvidersType); }
        }

        protected override string UninstallActionMessage 
        {
            get {return SR.GetString(SR.BuildProviderUninstall, ServiceModelInstallStrings.BuildProvidersType); } 
        } 

        internal static BuildProviderInstallComponent CreateNativeBuildProviderInstallComponent() 
        {
            BuildProviderInstallComponent buildProvider = new BuildProviderInstallComponent(new NativeConfigurationLoader());
            buildProvider.displayString = SR.GetString(SR.BuildProviderName);
 
            return buildProvider;
        } 
 
        internal static BuildProviderInstallComponent CreateWow64BuildProviderInstallComponent()
        { 
            if (!InstallHelper.Is64BitMachine() || String.IsNullOrEmpty(InstallHelper.Wow64WebConfigFileName))
            {
                throw new InvalidOperationException(SR.GetString(SR.Wow64NotInstalled));
            } 

            BuildProviderInstallComponent buildProvider = new BuildProviderInstallComponent(new Wow64ConfigurationLoader()); 
            buildProvider.displayString = SR.GetString(SR.BuildProviderNameWow64); 

            return buildProvider; 
        }

        internal override void Install(OutputLevel outputLevel)
        { 
            if (!this.IsInstalled)
            { 
                if (null != configLoader.SystemWebSectionGroup) 
                {
                    foreach (string extensionValue in ServiceModelInstallStrings.BuildProviderExtensionValues) 
                    {
                        BuildProvider buildProvider = new BuildProvider(extensionValue, ServiceModelInstallStrings.BuildProvidersType);
                        configLoader.SystemWebSectionGroup.Compilation.BuildProviders.Add(buildProvider);
                        configLoader.Save(); 
                    }
                } 
                else 
                {
                    throw new InvalidOperationException(SR.GetString(SR.ConfigurationSectionNotInstalled, 
                        configLoader.SystemWebSectionGroupPath,
                        configLoader.RootWebConfigurationFilePath));
                }
            } 
            else
            { 
                EventLogger.LogWarning(SR.GetString(SR.BuildProviderAlreadyExists, ServiceModelInstallStrings.BuildProvidersType), (OutputLevel.Verbose == outputLevel)); 
            }
        } 

        internal override void Uninstall(OutputLevel outputLevel)
        {
            if (this.IsInstalled) 
            {
                // Now, remove the other nodes 
                foreach (string extensionValue in ServiceModelInstallStrings.BuildProviderExtensionValues) 
                {
                    configLoader.SystemWebSectionGroup.Compilation.BuildProviders.Remove(extensionValue); 
                    configLoader.Save();
                }
            }
            else 
            {
                EventLogger.LogWarning(SR.GetString(SR.BuildProviderNotInstalled, ServiceModelInstallStrings.BuildProvidersType), (OutputLevel.Verbose == outputLevel)); 
            } 
        }
 
        internal override InstallationState VerifyInstall()
        {
            InstallationState installState = InstallationState.Unknown;
 
            if (this.IsInstalled)
            { 
                if (null != configLoader.SystemWebSectionGroup) 
                {
                    foreach (string extensionValue in ServiceModelInstallStrings.BuildProviderExtensionValues) 
                    {
                        BuildProvider buildProvider = new BuildProvider(extensionValue, ServiceModelInstallStrings.BuildProvidersType);
                        BuildProvider installedBuildProvider = configLoader.SystemWebSectionGroup.Compilation.BuildProviders[extensionValue];
                        if (installedBuildProvider.Equals(buildProvider)) 
                        {
                            installState = InstallationState.InstalledDefaults; 
                        } 
                        else
                        { 
                            installState = InstallationState.InstalledCustom;
                            break;
                        }
                    } 
                }
            } 
            else 
            {
                installState = InstallationState.NotInstalled; 
            }

            return installState;
        } 
    }
} 

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