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
- UniqueConstraint.cs
- DynamicQueryableWrapper.cs
- LinqDataSourceDisposeEventArgs.cs
- IconEditor.cs
- SelfIssuedAuthRSAPKCS1SignatureFormatter.cs
- XmlTextAttribute.cs
- ToolBarPanel.cs
- PersonalizationState.cs
- CodeBlockBuilder.cs
- COM2PictureConverter.cs
- PolyLineSegment.cs
- ToggleButton.cs
- PrivilegeNotHeldException.cs
- ADMembershipUser.cs
- DaylightTime.cs
- MatrixCamera.cs
- DataListCommandEventArgs.cs
- PolyLineSegmentFigureLogic.cs
- OleDbDataAdapter.cs
- SqlResolver.cs
- DesignerActionPropertyItem.cs
- CompModSwitches.cs
- XappLauncher.cs
- DirectoryInfo.cs
- DataGridViewRow.cs
- BindableAttribute.cs
- WorkflowOwnershipException.cs
- WebControl.cs
- localization.cs
- UntypedNullExpression.cs
- PenCursorManager.cs
- DBPropSet.cs
- CachedBitmap.cs
- CommandCollectionEditor.cs
- ObjectStorage.cs
- SchemaManager.cs
- IIS7UserPrincipal.cs
- PropertyGrid.cs
- ArgumentValueSerializer.cs
- ControlBuilderAttribute.cs
- SortedSetDebugView.cs
- XmlSchemaSimpleContentExtension.cs
- LocalServiceSecuritySettingsElement.cs
- StrongNameMembershipCondition.cs
- XmlCountingReader.cs
- StateChangeEvent.cs
- Image.cs
- ScaleTransform.cs
- Triangle.cs
- CompiledRegexRunnerFactory.cs
- Color.cs
- XmlBindingWorker.cs
- DesignTableCollection.cs
- ListDataBindEventArgs.cs
- XsltContext.cs
- InvalidPropValue.cs
- InputScopeNameConverter.cs
- ConnectionsZone.cs
- EventRouteFactory.cs
- InvalidProgramException.cs
- GlobalEventManager.cs
- CompositeActivityCodeGenerator.cs
- IconConverter.cs
- SymbolType.cs
- PrinterUnitConvert.cs
- LicFileLicenseProvider.cs
- XsltLoader.cs
- SessionStateUtil.cs
- IfElseDesigner.xaml.cs
- TemplateControlCodeDomTreeGenerator.cs
- SystemNetHelpers.cs
- CollectionBase.cs
- PersistChildrenAttribute.cs
- Msec.cs
- ISessionStateStore.cs
- PocoPropertyAccessorStrategy.cs
- TextPattern.cs
- X509Certificate2Collection.cs
- UInt16.cs
- DeflateEmulationStream.cs
- SystemUnicastIPAddressInformation.cs
- ResourceReader.cs
- HttpSessionStateBase.cs
- OleDbPropertySetGuid.cs
- SafeProcessHandle.cs
- SettingsBase.cs
- QuadraticBezierSegment.cs
- RenamedEventArgs.cs
- InputLanguageCollection.cs
- SystemNetHelpers.cs
- HttpWriter.cs
- Pair.cs
- DataRowCollection.cs
- ViewgenContext.cs
- PrinterResolution.cs
- FilterInvalidBodyAccessException.cs
- ColorConvertedBitmapExtension.cs
- ByteViewer.cs
- SoapFormatExtensions.cs
- InkCanvasSelection.cs