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
- ScrollPattern.cs
- SystemIPGlobalProperties.cs
- SimpleHandlerFactory.cs
- SqlError.cs
- XsltSettings.cs
- CollectionAdapters.cs
- EntityDataSourceWizardForm.cs
- MulticastOption.cs
- DTCTransactionManager.cs
- ListViewCancelEventArgs.cs
- PaperSize.cs
- QueryCacheKey.cs
- CaseStatement.cs
- Trigger.cs
- ReturnValue.cs
- EntitySqlQueryState.cs
- BitmapEffectGeneralTransform.cs
- WindowsBrush.cs
- RoutedEventHandlerInfo.cs
- CommandBinding.cs
- DbExpressionRules.cs
- TimeoutException.cs
- Helpers.cs
- CommandExpr.cs
- RelationshipEndMember.cs
- Win32.cs
- MessageBox.cs
- UpdateCommand.cs
- HttpPostedFileBase.cs
- Binding.cs
- ZoneButton.cs
- AlignmentYValidation.cs
- RemotingException.cs
- WebBrowser.cs
- NullReferenceException.cs
- ListBindingHelper.cs
- HelpProvider.cs
- DataGridClipboardCellContent.cs
- SmtpDigestAuthenticationModule.cs
- SpeakCompletedEventArgs.cs
- OdbcConnectionOpen.cs
- CodeTypeOfExpression.cs
- complextypematerializer.cs
- SqlUserDefinedTypeAttribute.cs
- IProvider.cs
- DataTable.cs
- CodeCommentStatementCollection.cs
- WebPartTransformerAttribute.cs
- WebPartsPersonalizationAuthorization.cs
- HexParser.cs
- XXXOnTypeBuilderInstantiation.cs
- DictionaryMarkupSerializer.cs
- TextElementAutomationPeer.cs
- OutputCacheSection.cs
- MaskedTextBox.cs
- SqlDeflator.cs
- Rect3DValueSerializer.cs
- X509ChainPolicy.cs
- PromptBuilder.cs
- ADMembershipProvider.cs
- Double.cs
- SqlConnectionHelper.cs
- ReflectionUtil.cs
- RecognizedAudio.cs
- SqlHelper.cs
- Scheduler.cs
- Config.cs
- InputProviderSite.cs
- BaseCodeDomTreeGenerator.cs
- Thickness.cs
- BigInt.cs
- _PooledStream.cs
- SecurityCriticalDataForSet.cs
- ClassData.cs
- WindowsUpDown.cs
- CustomBindingElementCollection.cs
- SqlAliasesReferenced.cs
- ServiceHttpHandlerFactory.cs
- PrintDocument.cs
- HotSpot.cs
- ScriptResourceInfo.cs
- HWStack.cs
- SqlAliaser.cs
- FloatUtil.cs
- ExpressionPrefixAttribute.cs
- CodeRemoveEventStatement.cs
- FileChangesMonitor.cs
- ClientConfigurationHost.cs
- OptimizedTemplateContentHelper.cs
- EmptyImpersonationContext.cs
- ScriptServiceAttribute.cs
- Win32SafeHandles.cs
- ConsoleKeyInfo.cs
- PointUtil.cs
- DecimalConstantAttribute.cs
- RunInstallerAttribute.cs
- HtmlShim.cs
- ObjectStateEntry.cs
- OutputCacheSettingsSection.cs
- ExecutorLocksHeldException.cs