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
- XmlSchemaGroup.cs
- ResourceReferenceKeyNotFoundException.cs
- MarginCollapsingState.cs
- TimeIntervalCollection.cs
- DesignerActionUI.cs
- XappLauncher.cs
- OciHandle.cs
- Rect.cs
- MouseActionValueSerializer.cs
- DataGridViewAccessibleObject.cs
- EmptyControlCollection.cs
- SafeCryptContextHandle.cs
- NameSpaceExtractor.cs
- PreservationFileReader.cs
- CompoundFileDeflateTransform.cs
- DoubleLink.cs
- ExpressionLink.cs
- ReadWriteObjectLock.cs
- UrlPath.cs
- ChtmlTextBoxAdapter.cs
- MonitorWrapper.cs
- DataSourceProvider.cs
- OperationDescription.cs
- ReferentialConstraint.cs
- SettingsPropertyNotFoundException.cs
- ModelTreeEnumerator.cs
- IUnknownConstantAttribute.cs
- DataGridHelper.cs
- DrawingGroupDrawingContext.cs
- Int32Animation.cs
- ProbeMatches11.cs
- TextSpan.cs
- PhoneCall.cs
- _CommandStream.cs
- ExternalDataExchangeService.cs
- TransactionChannel.cs
- CacheMemory.cs
- TemplatingOptionsDialog.cs
- DataControlField.cs
- Win32PrintDialog.cs
- TimeIntervalCollection.cs
- EventLogEntryCollection.cs
- ControlCollection.cs
- BaseParser.cs
- XmlCollation.cs
- AutoResizedEvent.cs
- unsafeIndexingFilterStream.cs
- HtmlWindowCollection.cs
- List.cs
- XPathChildIterator.cs
- TcpServerChannel.cs
- TreeNodeCollection.cs
- _ShellExpression.cs
- DesignBindingConverter.cs
- shaperfactoryquerycachekey.cs
- TransformerTypeCollection.cs
- BitmapEffectInput.cs
- MessageBox.cs
- CaseInsensitiveHashCodeProvider.cs
- OletxVolatileEnlistment.cs
- SponsorHelper.cs
- Speller.cs
- RelationshipConstraintValidator.cs
- HttpFileCollection.cs
- WinEventQueueItem.cs
- Popup.cs
- RenamedEventArgs.cs
- StackOverflowException.cs
- PtsCache.cs
- FacetEnabledSchemaElement.cs
- BindingExpressionUncommonField.cs
- CompoundFileReference.cs
- Math.cs
- ImageSource.cs
- CodeAttributeDeclaration.cs
- SwitchElementsCollection.cs
- SingleAnimationBase.cs
- ProxyDataContractResolver.cs
- SliderAutomationPeer.cs
- arabicshape.cs
- WebDescriptionAttribute.cs
- NameValueConfigurationCollection.cs
- KeyPressEvent.cs
- DbParameterCollectionHelper.cs
- GridViewRowCollection.cs
- DataTable.cs
- DriveNotFoundException.cs
- unitconverter.cs
- ContextToken.cs
- TypeConverterAttribute.cs
- SkewTransform.cs
- GeneralTransform2DTo3D.cs
- DefaultBinder.cs
- HttpProfileBase.cs
- GrammarBuilderWildcard.cs
- XmlSchemaObject.cs
- SqlConnectionStringBuilder.cs
- SnapLine.cs
- ScaleTransform3D.cs
- DictionaryKeyPropertyAttribute.cs