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
- WebSysDefaultValueAttribute.cs
- FrugalMap.cs
- RemotingAttributes.cs
- UserControlAutomationPeer.cs
- CroppedBitmap.cs
- ServiceOperation.cs
- StatusBarDrawItemEvent.cs
- DataConnectionHelper.cs
- SiteMapNodeItem.cs
- ISessionStateStore.cs
- TransformFinalBlockRequest.cs
- HtmlContainerControl.cs
- Missing.cs
- HttpRequestWrapper.cs
- Int16.cs
- DataSourceDescriptorCollection.cs
- MemoryMappedView.cs
- EntityType.cs
- DataRowChangeEvent.cs
- KerberosSecurityTokenProvider.cs
- DbSourceParameterCollection.cs
- XmlArrayItemAttribute.cs
- QilCloneVisitor.cs
- MimeParameter.cs
- RepeatButton.cs
- TaiwanCalendar.cs
- TcpClientSocketManager.cs
- NamespaceEmitter.cs
- StrokeNodeOperations.cs
- CharEnumerator.cs
- ContainerSelectorGlyph.cs
- CodeDomExtensionMethods.cs
- TryExpression.cs
- IntSecurity.cs
- NotCondition.cs
- KeyedCollection.cs
- WebPartDeleteVerb.cs
- CircleHotSpot.cs
- IItemContainerGenerator.cs
- SortedList.cs
- BitmapPalette.cs
- ValueTable.cs
- Signature.cs
- RouteValueExpressionBuilder.cs
- AnimationClock.cs
- OptionalRstParameters.cs
- DateTimeFormatInfo.cs
- TextSimpleMarkerProperties.cs
- MachineKeyConverter.cs
- WriterOutput.cs
- WinInetCache.cs
- EmbeddedMailObjectsCollection.cs
- LayoutEngine.cs
- tooltip.cs
- WebConfigurationManager.cs
- X509PeerCertificateAuthenticationElement.cs
- PolicyLevel.cs
- MenuItem.cs
- Size.cs
- HttpServerVarsCollection.cs
- ProfileManager.cs
- EntitySqlQueryCacheKey.cs
- QilIterator.cs
- DockPanel.cs
- ObjectRef.cs
- ScrollableControlDesigner.cs
- Viewport3DVisual.cs
- CultureSpecificCharacterBufferRange.cs
- FindResponse.cs
- AuthenticationSection.cs
- EmissiveMaterial.cs
- _UncName.cs
- CodeSubDirectoriesCollection.cs
- InternalConfigHost.cs
- ListViewCancelEventArgs.cs
- WorkflowTransactionOptions.cs
- UniqueIdentifierService.cs
- StringFunctions.cs
- DecoderBestFitFallback.cs
- ActiveXHelper.cs
- XmlJsonWriter.cs
- MouseButtonEventArgs.cs
- SymLanguageVendor.cs
- RequestStatusBarUpdateEventArgs.cs
- SqlError.cs
- EventLog.cs
- Model3DGroup.cs
- AppearanceEditorPart.cs
- DataServiceRequestOfT.cs
- CultureSpecificCharacterBufferRange.cs
- Rotation3DAnimationBase.cs
- StringCollectionMarkupSerializer.cs
- QilInvokeEarlyBound.cs
- WebPartMovingEventArgs.cs
- MethodRental.cs
- OleDbPropertySetGuid.cs
- TransformPattern.cs
- RelationshipType.cs
- IPEndPoint.cs
- FieldBuilder.cs