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
- DataMemberFieldConverter.cs
- KeySplineConverter.cs
- TextCharacters.cs
- XamlWrappingReader.cs
- CustomWebEventKey.cs
- ProtocolViolationException.cs
- PartialArray.cs
- WeakRefEnumerator.cs
- DBCSCodePageEncoding.cs
- PathStreamGeometryContext.cs
- HttpWebRequest.cs
- Semaphore.cs
- ExpandableObjectConverter.cs
- XsdBuilder.cs
- Span.cs
- RouteItem.cs
- Privilege.cs
- SoapElementAttribute.cs
- MessageHeaderAttribute.cs
- LocationReferenceEnvironment.cs
- XmlSortKeyAccumulator.cs
- ServiceSecurityContext.cs
- SplashScreenNativeMethods.cs
- TextProperties.cs
- HierarchicalDataSourceDesigner.cs
- OdbcUtils.cs
- ThreadExceptionEvent.cs
- UpdatePanel.cs
- LoginDesignerUtil.cs
- InProcStateClientManager.cs
- PageCodeDomTreeGenerator.cs
- TemplateField.cs
- IODescriptionAttribute.cs
- ValidatedControlConverter.cs
- WebMessageBodyStyleHelper.cs
- CollectionConverter.cs
- OleDbDataReader.cs
- DynamicValidatorEventArgs.cs
- HttpRequestCacheValidator.cs
- SqlXmlStorage.cs
- _FtpDataStream.cs
- _IPv6Address.cs
- PathSegmentCollection.cs
- ListItemCollection.cs
- DoubleCollectionValueSerializer.cs
- BookmarkScopeHandle.cs
- Style.cs
- WorkflowServiceHostFactory.cs
- SQLDateTime.cs
- IDQuery.cs
- PagesSection.cs
- SafeWaitHandle.cs
- Mappings.cs
- SerializationStore.cs
- RepeatBehavior.cs
- PinnedBufferMemoryStream.cs
- UnsafeNativeMethods.cs
- ListenerConstants.cs
- VisualStyleElement.cs
- EventLogPermissionEntryCollection.cs
- SinglePageViewer.cs
- ExtensionFile.cs
- LabelLiteral.cs
- EventProvider.cs
- SqlCacheDependencySection.cs
- GC.cs
- UrlSyndicationContent.cs
- NodeCounter.cs
- XmlDeclaration.cs
- HashMembershipCondition.cs
- ScrollProviderWrapper.cs
- recordstatescratchpad.cs
- UITypeEditor.cs
- CompilationUtil.cs
- DataSetFieldSchema.cs
- ZipIOEndOfCentralDirectoryBlock.cs
- Shape.cs
- CapabilitiesRule.cs
- LineProperties.cs
- Flowchart.cs
- OracleBFile.cs
- ItemsPanelTemplate.cs
- EventLog.cs
- ToolStripMenuItem.cs
- XhtmlBasicValidationSummaryAdapter.cs
- MouseDevice.cs
- DateBoldEvent.cs
- TransportChannelListener.cs
- CompilerErrorCollection.cs
- HandlerFactoryCache.cs
- CompilerCollection.cs
- Size.cs
- ExpressionParser.cs
- TypeToken.cs
- ErrorWrapper.cs
- EventHandlersStore.cs
- StateDesigner.TransitionInfo.cs
- XmlHierarchicalDataSourceView.cs
- DetailsViewActionList.cs
- StorageModelBuildProvider.cs