Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / RegistryExceptionHelper.cs / 1 / RegistryExceptionHelper.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace Microsoft.Tools.ServiceModel.WsatConfig { using Microsoft.Win32; using System; class RegistryExceptionHelper { string registryKey; public RegistryExceptionHelper(string registryKey) { this.registryKey = registryKey; EnsureEndsWithSlash(ref this.registryKey); } public RegistryExceptionHelper(string machineName, RegistryHive registryHive, string registryKeyRelativeToHive) : this(RegistryExceptionHelper.GetRegistryKeyBase(machineName, registryHive) + registryKeyRelativeToHive) { } public static void EnsureEndsWithSlash(ref string str) { if (!string.IsNullOrEmpty(str)) { if (!str.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) { str += '\\'; } } } static string GetRegistryKeyBase(string machineName, RegistryHive registryHive) { string registryBase = Utilities.IsLocalMachineName(machineName) ? string.Empty : SR.GetString(SR.RemoteRegistryFormat, machineName); switch (registryHive) { case RegistryHive.ClassesRoot: registryBase += Registry.ClassesRoot.Name; break; case RegistryHive.CurrentUser: registryBase += Registry.CurrentUser.Name; break; case RegistryHive.LocalMachine: registryBase += Registry.LocalMachine.Name; break; default: // We do not support other values here System.Diagnostics.Debug.Assert(false, "registryHive is not supported"); break; } RegistryExceptionHelper.EnsureEndsWithSlash(ref registryBase); return registryBase; } public WsatAdminException CreateRegistryAccessException(int errorCode) { return CreateRegistryAccessException(unchecked((uint)errorCode)); } public WsatAdminException CreateRegistryAccessException(uint errorCode) { return new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.ErrorRegistryAccess, registryKey, errorCode)); } public WsatAdminException CreateRegistryAccessException(Exception innerException) { return DoCreateRegistryAccessException(registryKey, innerException); } public WsatAdminException CreateRegistryAccessException(string subRegistryKey, Exception innerException) { return DoCreateRegistryAccessException(registryKey + subRegistryKey, innerException); } static WsatAdminException DoCreateRegistryAccessException(string regKey, Exception innerException) { if (innerException == null) { return new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.ErrorRegistryAccessNoErrorCode, regKey)); } return new WsatAdminException(WsatAdminErrorCode.REGISTRY_ACCESS, SR.GetString(SR.ErrorRegistryAccessNoErrorCode, regKey), innerException); } public WsatAdminException CreateRegistryWriteException(Exception innerException) { return DoCreateRegistryWriteException(registryKey, innerException); } public WsatAdminException CreateRegistryWriteException(string subRegistryKey, Exception innerException) { return DoCreateRegistryWriteException(registryKey + subRegistryKey, innerException); } static WsatAdminException DoCreateRegistryWriteException(string regKey, Exception innerException) { if (innerException == null) { return new WsatAdminException(WsatAdminErrorCode.REGISTRY_WRITE, SR.GetString(SR.ErrorRegistryWrite, regKey)); } return new WsatAdminException(WsatAdminErrorCode.REGISTRY_WRITE, SR.GetString(SR.ErrorRegistryWrite, regKey), innerException); } } } // 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
- XMLUtil.cs
- OperationFormatStyle.cs
- FocusManager.cs
- _NegoState.cs
- IsolatedStorageFileStream.cs
- InkCanvasSelection.cs
- CardSpaceShim.cs
- NavigatorInput.cs
- ConcurrencyBehavior.cs
- GroupAggregateExpr.cs
- PopOutPanel.cs
- UnicodeEncoding.cs
- MenuItemStyleCollection.cs
- Form.cs
- StrokeDescriptor.cs
- DockEditor.cs
- EpmSyndicationContentSerializer.cs
- DemultiplexingClientMessageFormatter.cs
- NamespaceCollection.cs
- FixedTextSelectionProcessor.cs
- XmlSignificantWhitespace.cs
- GridLength.cs
- ToolBarPanel.cs
- ZoomPercentageConverter.cs
- SemaphoreSlim.cs
- BuilderPropertyEntry.cs
- CounterCreationData.cs
- WsatServiceCertificate.cs
- DataGridViewMethods.cs
- AuthStoreRoleProvider.cs
- ColumnWidthChangedEvent.cs
- ContainerActivationHelper.cs
- CookieParameter.cs
- XmlSchemaImport.cs
- ListParagraph.cs
- AudioLevelUpdatedEventArgs.cs
- ToolboxDataAttribute.cs
- SoapProtocolImporter.cs
- ImageMap.cs
- PropertyPushdownHelper.cs
- JapaneseLunisolarCalendar.cs
- X509RawDataKeyIdentifierClause.cs
- TableRowCollection.cs
- AttributeExtensions.cs
- StringValidator.cs
- RemoteWebConfigurationHostServer.cs
- HostExecutionContextManager.cs
- ClientCultureInfo.cs
- DESCryptoServiceProvider.cs
- StylusPointCollection.cs
- SamlAction.cs
- PropertyCollection.cs
- TaskCanceledException.cs
- IncrementalReadDecoders.cs
- LayoutSettings.cs
- StreamMarshaler.cs
- WindowsBrush.cs
- MimeMultiPart.cs
- Exceptions.cs
- _ScatterGatherBuffers.cs
- XmlSignatureProperties.cs
- Separator.cs
- Msmq4SubqueuePoisonHandler.cs
- Configuration.cs
- FtpWebResponse.cs
- Int16Storage.cs
- ListControlActionList.cs
- ConfigurationElementCollection.cs
- RandomNumberGenerator.cs
- DeflateStream.cs
- ZeroOpNode.cs
- GetWinFXPath.cs
- HtmlInputText.cs
- TableItemPattern.cs
- CacheVirtualItemsEvent.cs
- StorageEndPropertyMapping.cs
- VirtualDirectoryMappingCollection.cs
- ProcessThreadDesigner.cs
- ImageKeyConverter.cs
- SetIndexBinder.cs
- InsufficientMemoryException.cs
- ProcessModelSection.cs
- UriWriter.cs
- RegexParser.cs
- AuthenticationManager.cs
- DiscoveryServiceExtension.cs
- CellParaClient.cs
- Win32Native.cs
- CaseInsensitiveOrdinalStringComparer.cs
- JsonObjectDataContract.cs
- PackagePart.cs
- InkCollectionBehavior.cs
- SubqueryRules.cs
- Point3DConverter.cs
- Token.cs
- WebServiceResponseDesigner.cs
- InvokeDelegate.cs
- MethodToken.cs
- NameSpaceExtractor.cs
- WebPartDisplayModeEventArgs.cs