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
- TypeName.cs
- BlurBitmapEffect.cs
- ChtmlTextWriter.cs
- OleDbConnection.cs
- FolderBrowserDialog.cs
- StructuredCompositeActivityDesigner.cs
- NotFiniteNumberException.cs
- MethodImplAttribute.cs
- AdornedElementPlaceholder.cs
- ContainsRowNumberChecker.cs
- EastAsianLunisolarCalendar.cs
- AnimatedTypeHelpers.cs
- SmtpCommands.cs
- DetailsViewInsertedEventArgs.cs
- TextEffect.cs
- Floater.cs
- MSHTMLHost.cs
- DataGridViewDesigner.cs
- EntityDesignerBuildProvider.cs
- WorkflowDefinitionContext.cs
- DataTablePropertyDescriptor.cs
- NodeCounter.cs
- Win32KeyboardDevice.cs
- METAHEADER.cs
- XmlReader.cs
- ListItemConverter.cs
- SqlGatherConsumedAliases.cs
- RadioButtonList.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- WebPartCancelEventArgs.cs
- InfoCardRSAPKCS1SignatureFormatter.cs
- MailWriter.cs
- BufferedReadStream.cs
- ProjectionPruner.cs
- WorkflowPersistenceContext.cs
- StrongNameHelpers.cs
- EditorZoneBase.cs
- OverlappedContext.cs
- CharacterHit.cs
- ConfigXmlDocument.cs
- CopyNamespacesAction.cs
- XmlSchemaInfo.cs
- CalendarButtonAutomationPeer.cs
- EventMappingSettingsCollection.cs
- Crc32.cs
- FusionWrap.cs
- PasswordPropertyTextAttribute.cs
- CriticalExceptions.cs
- SSmlParser.cs
- ProgressBarHighlightConverter.cs
- SqlNode.cs
- ListBoxAutomationPeer.cs
- SystemBrushes.cs
- HttpWrapper.cs
- ImageSourceValueSerializer.cs
- KeyGestureValueSerializer.cs
- CodeDirectiveCollection.cs
- BehaviorEditorPart.cs
- RowUpdatingEventArgs.cs
- FullTextLine.cs
- SslStream.cs
- AdornedElementPlaceholder.cs
- PixelShader.cs
- ChangeBlockUndoRecord.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- HeaderUtility.cs
- AppendHelper.cs
- lengthconverter.cs
- PolyLineSegment.cs
- PageThemeParser.cs
- ExpressionBinding.cs
- EdmMember.cs
- NodeInfo.cs
- ImageAutomationPeer.cs
- AddInActivator.cs
- XMLDiffLoader.cs
- Transform3DCollection.cs
- ObjectQueryState.cs
- WorkflowTransactionService.cs
- BrushMappingModeValidation.cs
- User.cs
- ReverseInheritProperty.cs
- TransactionTraceIdentifier.cs
- DataGridTextBoxColumn.cs
- View.cs
- XamlUtilities.cs
- Classification.cs
- XamlWriter.cs
- RadioButtonList.cs
- HttpCacheVary.cs
- SqlBuilder.cs
- TextPenaltyModule.cs
- TypeDependencyAttribute.cs
- HostedHttpContext.cs
- MenuEventArgs.cs
- ReadOnlyAttribute.cs
- XmlnsCache.cs
- SmiEventSink_Default.cs
- StrongNameSignatureInformation.cs
- PortCache.cs