Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / xws_reg / System / ServiceModel / Install / Configuration / ProtocolsInstallComponent.cs / 1 / ProtocolsInstallComponent.cs
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.ServiceModel.Install.Configuration
{
using System;
using System.Configuration;
using System.Globalization;
using System.Text;
using System.Web.Configuration;
using System.Reflection;
using System.Collections.Generic;
internal class ProtocolsInstallComponent : ServiceModelInstallComponent
{
string appDomainHandlerType;
ConfigurationLoader configLoader;
string displayString;
string name;
string processHandlerType;
ProtocolsInstallComponent(string name, ConfigurationLoader configLoader)
{
this.name = name;
string mapped = null;
switch (name)
{
case ServiceModelInstallStrings.NetTcp:
mapped = ServiceModelInstallStrings.Tcp;
break;
case ServiceModelInstallStrings.NetPipe:
mapped = ServiceModelInstallStrings.NamedPipe;
break;
case ServiceModelInstallStrings.NetMsmq:
mapped = ServiceModelInstallStrings.Msmq;
break;
case ServiceModelInstallStrings.MsmqFormatName:
mapped = ServiceModelInstallStrings.MsmqIntegration;
break;
default:
throw new InvalidOperationException(SR.GetString(SR.InvalidProtocol, name));
}
this.processHandlerType = ServiceModelInstallStrings.ProcessProtocolHandlerType.Replace(ServiceModelInstallStrings.ProtocolToken, mapped);
this.appDomainHandlerType = ServiceModelInstallStrings.AppDomainProtocolHandlerType.Replace(ServiceModelInstallStrings.ProtocolToken, mapped);
this.configLoader = configLoader;
}
internal override string DisplayName
{
get {return this.displayString; }
}
protected override string InstallActionMessage
{
get {return SR.GetString(SR.ProtocolsInstall, this.name, this.configLoader.RootWebConfigurationFilePath); }
}
internal override string[] InstalledVersions
{
get
{
if (null != configLoader.ProtocolsSection)
{
ProtocolElement element = configLoader.ProtocolsSection.Protocols[name];
if (element != null)
{
return new string[] {
ServiceModelInstallStrings.ProcessHandlerType + ServiceModelInstallStrings.VersionStringSeparator + element.ProcessHandlerType,
ServiceModelInstallStrings.AppDomainHandlerType + ServiceModelInstallStrings.VersionStringSeparator + element.AppDomainHandlerType
};
}
}
return new string[0];
}
}
internal override bool IsInstalled
{
get
{
return configLoader.ProtocolsSection != null && configLoader.ProtocolsSection.Protocols[name] != null;
}
}
protected override string ReinstallActionMessage
{
get {return SR.GetString(SR.ProtocolsReinstall, this.name, this.configLoader.RootWebConfigurationFilePath); }
}
protected override string UninstallActionMessage
{
get {return SR.GetString(SR.ProtocolsUninstall, this.name, this.configLoader.RootWebConfigurationFilePath); }
}
internal static ProtocolsInstallComponent CreateNativeProtocolsInstallComponent(string name)
{
ProtocolsInstallComponent protocols = new ProtocolsInstallComponent(name, new NativeConfigurationLoader());
protocols.displayString = SR.GetString(SR.ProtocolsName, name);
return protocols;
}
internal static ProtocolsInstallComponent CreateWow64ProtocolsInstallComponent(string name)
{
if (!InstallHelper.Is64BitMachine() || String.IsNullOrEmpty(InstallHelper.Wow64WebConfigFileName))
{
throw new ConfigurationLoaderException(SR.GetString(SR.Wow64NotInstalled));
}
ProtocolsInstallComponent protocols = new ProtocolsInstallComponent(name, new Wow64ConfigurationLoader());
protocols.displayString = SR.GetString(SR.ProtocolsNameWow64, name);
return protocols;
}
internal override void Install(OutputLevel outputLevel)
{
if (!IisHelper.ShouldInstallWas)
{
throw new WasNotInstalledException(SR.GetString(SR.WasNotInstalled, SR.GetString(SR.ProtocolsName, name)));
}
if (!this.IsInstalled)
{
if (null != this.configLoader.ProtocolsSection)
{
ProtocolElement element = new ProtocolElement(name);
element.ProcessHandlerType = processHandlerType;
element.AppDomainHandlerType = appDomainHandlerType;
element.Validate = false;
configLoader.ProtocolsSection.Protocols.Add(element);
configLoader.Save();
}
else
{
throw new InvalidOperationException(SR.GetString(SR.ConfigurationSectionNotInstalled,
this.configLoader.ProtocolsSectionPath,
this.configLoader.RootWebConfigurationFilePath));
}
}
else
{
EventLogger.LogWarning(SR.GetString(SR.ProtocolsAlreadyExists, name, configLoader.RootWebConfigurationFilePath), OutputLevel.Verbose == outputLevel);
}
}
internal override void Uninstall(OutputLevel outputLevel)
{
if (this.IsInstalled)
{
configLoader.ProtocolsSection.Protocols.Remove(name);
configLoader.Save();
}
else
{
EventLogger.LogWarning(SR.GetString(SR.ProtocolsNotInstalled, name, configLoader.RootWebConfigurationFilePath), OutputLevel.Verbose == outputLevel);
}
}
internal override InstallationState VerifyInstall()
{
InstallationState installState = InstallationState.Unknown;
if (this.IsInstalled)
{
if (null != configLoader.ProtocolsSection)
{
ProtocolElement element = configLoader.ProtocolsSection.Protocols[name];
if (element != null)
{
if (!element.Validate &&
element.ProcessHandlerType.Equals(processHandlerType, StringComparison.OrdinalIgnoreCase) &&
element.AppDomainHandlerType.Equals(appDomainHandlerType, StringComparison.OrdinalIgnoreCase))
{
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
- CorrelationService.cs
- Effect.cs
- CircleHotSpot.cs
- NotifyParentPropertyAttribute.cs
- HttpWriter.cs
- RectKeyFrameCollection.cs
- SqlDependencyUtils.cs
- ClientData.cs
- IdentifierCreationService.cs
- InternalMappingException.cs
- ThreadStartException.cs
- StringExpressionSet.cs
- Helpers.cs
- RuntimeHelpers.cs
- FormsAuthentication.cs
- updatecommandorderer.cs
- ProcessThreadCollection.cs
- DbCommandDefinition.cs
- PointLight.cs
- KeyInterop.cs
- EntityDataSource.cs
- XmlAnyAttributeAttribute.cs
- PrivilegedConfigurationManager.cs
- CellPartitioner.cs
- StorageConditionPropertyMapping.cs
- StateChangeEvent.cs
- RSACryptoServiceProvider.cs
- MessageContractMemberAttribute.cs
- TableCellAutomationPeer.cs
- RecognitionEventArgs.cs
- ObjectListFieldsPage.cs
- UriExt.cs
- InkPresenter.cs
- WizardPanel.cs
- CardSpaceSelector.cs
- FormsAuthenticationEventArgs.cs
- newinstructionaction.cs
- SafeFindHandle.cs
- ZipIORawDataFileBlock.cs
- BindingsSection.cs
- SecurityRequiresReviewAttribute.cs
- SplineKeyFrames.cs
- TextLineBreak.cs
- ExpandSegment.cs
- DataObjectPastingEventArgs.cs
- HandlerMappingMemo.cs
- AttributeProviderAttribute.cs
- Padding.cs
- WhitespaceReader.cs
- RSAOAEPKeyExchangeFormatter.cs
- BooleanSwitch.cs
- GatewayIPAddressInformationCollection.cs
- DbConnectionHelper.cs
- Line.cs
- AssemblyBuilderData.cs
- Random.cs
- GridItemCollection.cs
- ApplicationHost.cs
- TemplateKey.cs
- ProcessThreadCollection.cs
- SocketAddress.cs
- SortedList.cs
- FormClosingEvent.cs
- _UncName.cs
- OutKeywords.cs
- KnownBoxes.cs
- DesignerTransactionCloseEvent.cs
- NetworkInterface.cs
- VideoDrawing.cs
- WorkItem.cs
- ArrayExtension.cs
- ModuleElement.cs
- LineServicesRun.cs
- PublishLicense.cs
- LinkUtilities.cs
- BitmapMetadataBlob.cs
- DisposableCollectionWrapper.cs
- RegexMatchCollection.cs
- TemplateColumn.cs
- PolyBezierSegment.cs
- ZoneIdentityPermission.cs
- ScriptResourceInfo.cs
- SoapSchemaExporter.cs
- RenderTargetBitmap.cs
- RotationValidation.cs
- BrowserDefinition.cs
- ErrorWrapper.cs
- PageParserFilter.cs
- X509ChainPolicy.cs
- NameSpaceEvent.cs
- CalendarDayButton.cs
- XmlSerializerAssemblyAttribute.cs
- RangeBase.cs
- SiteMapNode.cs
- CollectionBase.cs
- RawStylusInputCustomData.cs
- SQLInt16Storage.cs
- BridgeDataRecord.cs
- StylusPointPropertyInfo.cs
- AtomPub10ServiceDocumentFormatter.cs