Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / Tools / WSATConfig / Configuration / RegistryExceptionHelper.cs / 1305376 / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SignatureHelper.cs
- ContentDesigner.cs
- formatter.cs
- ConstructorBuilder.cs
- DiagnosticTraceRecords.cs
- AudioBase.cs
- Listen.cs
- CorrelationQueryBehavior.cs
- ObjectDataSourceMethodEventArgs.cs
- MemberNameValidator.cs
- GeneralTransformGroup.cs
- BitConverter.cs
- OracleLob.cs
- CodeDirectiveCollection.cs
- Perspective.cs
- SQLStringStorage.cs
- DescendantOverDescendantQuery.cs
- configsystem.cs
- Int32EqualityComparer.cs
- AppDomainProtocolHandler.cs
- EventSetter.cs
- PaintEvent.cs
- FlowLayout.cs
- RegexCode.cs
- SwitchElementsCollection.cs
- FlowPosition.cs
- TdsParameterSetter.cs
- SqlSupersetValidator.cs
- safePerfProviderHandle.cs
- String.cs
- _SslSessionsCache.cs
- BookmarkScope.cs
- ToolboxDataAttribute.cs
- MenuItemStyleCollectionEditor.cs
- OutputScopeManager.cs
- SrgsToken.cs
- NumericUpDown.cs
- ExpressionHelper.cs
- Color.cs
- HMAC.cs
- TextAutomationPeer.cs
- QualifiedCellIdBoolean.cs
- SimpleWebHandlerParser.cs
- LinqMaximalSubtreeNominator.cs
- ApplicationServicesHostFactory.cs
- KeyPullup.cs
- PeerNameRecordCollection.cs
- DesignColumnCollection.cs
- SrgsSemanticInterpretationTag.cs
- BasePattern.cs
- GeometryHitTestParameters.cs
- SqlConnectionPoolGroupProviderInfo.cs
- AuthorizationRuleCollection.cs
- TypeBuilderInstantiation.cs
- _emptywebproxy.cs
- XmlParserContext.cs
- CacheSection.cs
- ArgumentOutOfRangeException.cs
- CompositeActivityTypeDescriptorProvider.cs
- IPAddress.cs
- Error.cs
- NTAccount.cs
- HWStack.cs
- ThrowHelper.cs
- RuntimeConfigLKG.cs
- SqlInfoMessageEvent.cs
- MessageBox.cs
- RowParagraph.cs
- CancellationState.cs
- DebugView.cs
- ScalarConstant.cs
- SoapProtocolImporter.cs
- ItemCheckedEvent.cs
- SamlAttribute.cs
- Material.cs
- HwndSource.cs
- OleAutBinder.cs
- HyperLinkColumn.cs
- _BufferOffsetSize.cs
- ClonableStack.cs
- NamespaceEmitter.cs
- DiscoveryDocumentSerializer.cs
- MILUtilities.cs
- GridViewDeletedEventArgs.cs
- ImmComposition.cs
- StrongNameSignatureInformation.cs
- DSASignatureFormatter.cs
- Type.cs
- counter.cs
- EntitySqlQueryBuilder.cs
- JournalEntryStack.cs
- LoginCancelEventArgs.cs
- Parameter.cs
- WmlFormAdapter.cs
- TransportConfigurationTypeElementCollection.cs
- XmlRawWriter.cs
- TextPointer.cs
- ToolStripRenderer.cs
- UseLicense.cs
- WorkflowWebHostingModule.cs