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
- ToolCreatedEventArgs.cs
- _NegoStream.cs
- ContentTextAutomationPeer.cs
- SimpleTypesSurrogate.cs
- ImmutablePropertyDescriptorGridEntry.cs
- DebuggerAttributes.cs
- ActivationServices.cs
- PaintValueEventArgs.cs
- Odbc32.cs
- EventSetter.cs
- AtlasWeb.Designer.cs
- BaseParaClient.cs
- TypeGenericEnumerableViewSchema.cs
- DesignerTransaction.cs
- BufferedStream.cs
- SystemIPGlobalStatistics.cs
- DetailsViewUpdatedEventArgs.cs
- PackageRelationship.cs
- NopReturnReader.cs
- SelectionProcessor.cs
- DataGridViewButtonCell.cs
- ConstantExpression.cs
- TemplateInstanceAttribute.cs
- RequestQueue.cs
- XmlSchemaObjectCollection.cs
- DateTimeConstantAttribute.cs
- JsonServiceDocumentSerializer.cs
- UnionCodeGroup.cs
- MarginsConverter.cs
- FamilyCollection.cs
- WebPartTransformerCollection.cs
- HandlerWithFactory.cs
- DbConnectionPoolIdentity.cs
- AllMembershipCondition.cs
- StatementContext.cs
- ObjectQueryState.cs
- CodeParameterDeclarationExpression.cs
- NavigationFailedEventArgs.cs
- ServiceDesigner.cs
- TreeIterators.cs
- MultitargetingHelpers.cs
- ValidatorCompatibilityHelper.cs
- CompiledXpathExpr.cs
- ping.cs
- CellPartitioner.cs
- MapPathBasedVirtualPathProvider.cs
- RuleInfoComparer.cs
- SqlClientWrapperSmiStream.cs
- NavigationCommands.cs
- ClientBuildManagerCallback.cs
- WebBrowserUriTypeConverter.cs
- SmiContextFactory.cs
- CircleHotSpot.cs
- EndEvent.cs
- ControlBindingsCollection.cs
- SqlCachedBuffer.cs
- SplitterEvent.cs
- ButtonBase.cs
- WebResponse.cs
- Page.cs
- DataGridViewAutoSizeModeEventArgs.cs
- SiteMapNodeItem.cs
- SafeBitVector32.cs
- NavigatorOutput.cs
- CheckBoxList.cs
- HtmlInputCheckBox.cs
- ContentOperations.cs
- ServiceDebugElement.cs
- SourceFileInfo.cs
- TrackPoint.cs
- GridProviderWrapper.cs
- CodeDelegateCreateExpression.cs
- Int32.cs
- TailCallAnalyzer.cs
- UnsafeCollabNativeMethods.cs
- wgx_sdk_version.cs
- ServiceProviders.cs
- TableStyle.cs
- BrushValueSerializer.cs
- ViewStateException.cs
- Vector3D.cs
- TextEvent.cs
- FilterException.cs
- HttpProcessUtility.cs
- StateBag.cs
- ItemAutomationPeer.cs
- PropertyMapper.cs
- BinaryMethodMessage.cs
- GroupBox.cs
- MailMessageEventArgs.cs
- BitmapImage.cs
- SecuritySessionFilter.cs
- SafeEventLogWriteHandle.cs
- newinstructionaction.cs
- ReadOnlyCollectionBuilder.cs
- UnicodeEncoding.cs
- ConnectionsZone.cs
- DataGridTable.cs
- EvidenceTypeDescriptor.cs
- HwndKeyboardInputProvider.cs