Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / Configuration / HttpModulesInstallComponent.cs / 1 / HttpModulesInstallComponent.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Install.Configuration
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Text;
using System.Web.Configuration;
internal class HttpModulesInstallComponent : ServiceModelInstallComponent
{
ConfigurationLoader configLoader;
string displayString;
string httpModuleType;
protected HttpModulesInstallComponent(ConfigurationLoader configLoader)
{
httpModuleType = ServiceModelInstallStrings.HttpModulesType;
this.configLoader = configLoader;
}
internal override string DisplayName
{
get {return this.displayString; }
}
protected override string InstallActionMessage
{
get {return SR.GetString(SR.HttpModulesComponentInstall, ServiceModelInstallStrings.ServiceModel); }
}
internal override string[] InstalledVersions
{
get
{
List installedVersions = new List();
if (null != configLoader.SystemWebSectionGroup)
{
// Foreach needed here since HttpModuleActionCollection does not have an accessor that takes a string (at least not in Whidbey)
foreach (HttpModuleAction module in configLoader.SystemWebSectionGroup.HttpModules.Modules)
{
if (module.Name.Equals(ServiceModelInstallStrings.ServiceModel, StringComparison.Ordinal))
{
string versionString = module.Name + " : " + InstallHelper.GetVersionStringFromTypeString(module.Type);
if (!String.IsNullOrEmpty(versionString))
{
installedVersions.Add(versionString);
}
}
}
}
return installedVersions.ToArray();
}
}
internal override bool IsInstalled
{
get
{
if (null != configLoader.SystemWebSectionGroup)
{
// Foreach needed here since HttpModuleActionCollection does not have an accessor that takes a string (at least not in Whidbey)
foreach (HttpModuleAction installedModule in configLoader.SystemWebSectionGroup.HttpModules.Modules)
{
if (installedModule.Name.Equals(ServiceModelInstallStrings.ServiceModel, StringComparison.Ordinal))
{
return true;
}
}
}
return false;
}
}
protected override string ReinstallActionMessage
{
get {return SR.GetString(SR.HttpModulesComponentReinstall, ServiceModelInstallStrings.ServiceModel); }
}
protected override string UninstallActionMessage
{
get {return SR.GetString(SR.HttpModulesComponentUninstall, ServiceModelInstallStrings.ServiceModel); }
}
internal static HttpModulesInstallComponent CreateNativeHttpModulesInstallComponent()
{
HttpModulesInstallComponent httpModulesComponent = new HttpModulesInstallComponent(new NativeConfigurationLoader());
httpModulesComponent.displayString = SR.GetString(SR.HttpModulesComponentName);
return httpModulesComponent;
}
internal static HttpModulesInstallComponent CreateWow64HttpModulesInstallComponent()
{
if (!InstallHelper.Is64BitMachine() || String.IsNullOrEmpty(InstallHelper.Wow64WebConfigFileName))
{
throw new ConfigurationLoaderException(SR.GetString(SR.Wow64NotInstalled));
}
HttpModulesInstallComponent httpModulesComponent = new HttpModulesInstallComponent(new Wow64ConfigurationLoader());
httpModulesComponent.displayString = SR.GetString(SR.HttpModulesComponentNameWow64);
return httpModulesComponent;
}
internal override void Install(OutputLevel outputLevel)
{
if (!this.IsInstalled)
{
if (null != configLoader.SystemWebSectionGroup)
{
HttpModuleAction module = new HttpModuleAction(ServiceModelInstallStrings.ServiceModel, this.httpModuleType);
configLoader.SystemWebSectionGroup.HttpModules.Modules.Add(module);
configLoader.Save();
}
else
{
throw new InvalidOperationException(SR.GetString(SR.ConfigurationSectionNotInstalled,
configLoader.SystemWebSectionGroupPath,
configLoader.RootWebConfigurationFilePath));
}
}
else
{
EventLogger.LogWarning(SR.GetString(SR.HttpModulesComponentAlreadyExists, ServiceModelInstallStrings.ServiceModel), (OutputLevel.Verbose == outputLevel));
}
}
internal override void Uninstall(OutputLevel outputLevel)
{
if (this.IsInstalled)
{
// Remove the httpModules node
configLoader.SystemWebSectionGroup.HttpModules.Modules.Remove(ServiceModelInstallStrings.ServiceModel);
configLoader.Save();
}
else
{
EventLogger.LogWarning(SR.GetString(SR.HttpModulesComponentNotInstalled, ServiceModelInstallStrings.ServiceModel), (OutputLevel.Verbose == outputLevel));
}
}
internal override InstallationState VerifyInstall()
{
InstallationState installState = InstallationState.Unknown;
if (this.IsInstalled)
{
if (null != configLoader.SystemWebSectionGroup)
{
HttpModuleAction module = new HttpModuleAction(ServiceModelInstallStrings.ServiceModel, this.httpModuleType);
// Foreach needed here since HttpModuleActionCollection does not have an accessor that takes a string (at least not in Whidbey)
foreach (HttpModuleAction installedModule in configLoader.SystemWebSectionGroup.HttpModules.Modules)
{
if (module.Name.Equals(installedModule.Name, StringComparison.Ordinal))
{
if (installedModule.Equals(module))
{
installState = InstallationState.InstalledDefaults;
}
else
{
installState = InstallationState.InstalledCustom;
}
}
}
}
}
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

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EditingScopeUndoUnit.cs
- WindowsImpersonationContext.cs
- ErrorFormatterPage.cs
- CodeSnippetExpression.cs
- PerfCounters.cs
- BookmarkEventArgs.cs
- HotCommands.cs
- CodeTryCatchFinallyStatement.cs
- DbMetaDataColumnNames.cs
- WindowsEditBoxRange.cs
- SendOperation.cs
- XmlRawWriter.cs
- DefaultObjectMappingItemCollection.cs
- ProgressiveCrcCalculatingStream.cs
- WorkflowRuntimeElement.cs
- BreakSafeBase.cs
- ScriptReference.cs
- ToolboxItemSnapLineBehavior.cs
- _IPv4Address.cs
- TripleDES.cs
- DataGridColumnEventArgs.cs
- MetadataUtil.cs
- ClaimTypes.cs
- TransformPatternIdentifiers.cs
- AmbiguousMatchException.cs
- SqlDataSourceSelectingEventArgs.cs
- Accessors.cs
- HtmlTextArea.cs
- NamespaceTable.cs
- GridItemProviderWrapper.cs
- DataServiceRequestArgs.cs
- SafeHandles.cs
- HyperlinkAutomationPeer.cs
- IssuanceLicense.cs
- SqlParameterCollection.cs
- EncryptedPackageFilter.cs
- RoleService.cs
- DataSvcMapFile.cs
- AudioDeviceOut.cs
- BufferedWebEventProvider.cs
- RawUIStateInputReport.cs
- CallbackHandler.cs
- SuppressIldasmAttribute.cs
- SqlReferenceCollection.cs
- HtmlInputButton.cs
- ThreadAbortException.cs
- QilNode.cs
- Privilege.cs
- DebugHandleTracker.cs
- JournalNavigationScope.cs
- BuildResultCache.cs
- HotSpot.cs
- LockedBorderGlyph.cs
- GroupBox.cs
- XamlValidatingReader.cs
- HttpGetClientProtocol.cs
- XamlSerializerUtil.cs
- GB18030Encoding.cs
- wgx_commands.cs
- AccessDataSource.cs
- XmlDigitalSignatureProcessor.cs
- XmlILAnnotation.cs
- TextEndOfLine.cs
- UmAlQuraCalendar.cs
- NamespaceEmitter.cs
- XmlNamedNodeMap.cs
- FontConverter.cs
- WindowsListViewItemStartMenu.cs
- Container.cs
- ServiceSecurityAuditElement.cs
- diagnosticsswitches.cs
- XmlEntityReference.cs
- SqlConnectionManager.cs
- SystemIPInterfaceProperties.cs
- FileSystemEventArgs.cs
- QuotaExceededException.cs
- XPathAxisIterator.cs
- TextWriterTraceListener.cs
- AppDomainManager.cs
- TileBrush.cs
- InkPresenterAutomationPeer.cs
- DispatcherTimer.cs
- EntityDataSourceUtil.cs
- ItemMap.cs
- BuilderElements.cs
- DoubleKeyFrameCollection.cs
- TiffBitmapDecoder.cs
- VirtualPathUtility.cs
- DataGridViewToolTip.cs
- TextProperties.cs
- InputBinding.cs
- TogglePattern.cs
- DetailsViewUpdateEventArgs.cs
- StorageEntityTypeMapping.cs
- ScrollContentPresenter.cs
- Track.cs
- Shape.cs
- BamlRecords.cs
- IISMapPath.cs
- AddressHeader.cs