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
- ProjectionPlan.cs
- DocumentOutline.cs
- ApplicationFileCodeDomTreeGenerator.cs
- StylusCollection.cs
- UpdateInfo.cs
- DataGridRow.cs
- sitestring.cs
- BitmapEffect.cs
- OleDbCommandBuilder.cs
- GPRECTF.cs
- Stopwatch.cs
- ApplicationException.cs
- PerformanceCounterCategory.cs
- FormatterConverter.cs
- XmlQualifiedNameTest.cs
- EntityDataSourceContextDisposingEventArgs.cs
- BooleanExpr.cs
- NumericExpr.cs
- EncryptedPackage.cs
- DataGridViewControlCollection.cs
- SystemInformation.cs
- SmtpMail.cs
- ExtensionFile.cs
- RightsManagementSuppressedStream.cs
- BinaryMessageEncodingElement.cs
- SerializationObjectManager.cs
- StringFormat.cs
- ping.cs
- AssemblyBuilderData.cs
- EtwTrackingBehaviorElement.cs
- ConstructorBuilder.cs
- autovalidator.cs
- Propagator.JoinPropagator.cs
- CodeDomSerializer.cs
- ComponentTray.cs
- ObjectViewListener.cs
- RadioButtonPopupAdapter.cs
- InkCanvasInnerCanvas.cs
- Nullable.cs
- FocusTracker.cs
- Filter.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs
- Base64Decoder.cs
- ReachFixedPageSerializerAsync.cs
- IndexedWhereQueryOperator.cs
- SystemUnicastIPAddressInformation.cs
- ContractListAdapter.cs
- PriorityRange.cs
- XmlEntity.cs
- TakeQueryOptionExpression.cs
- DrawingBrush.cs
- InternalTypeHelper.cs
- SspiWrapper.cs
- HttpHandlersSection.cs
- CodeTypeOfExpression.cs
- WebPartChrome.cs
- WebSysDefaultValueAttribute.cs
- PathFigureCollection.cs
- RootBuilder.cs
- WithStatement.cs
- QueryStack.cs
- ConfigXmlComment.cs
- Select.cs
- ResourceDictionaryCollection.cs
- EntityKeyElement.cs
- PageHandlerFactory.cs
- ComponentCache.cs
- VSWCFServiceContractGenerator.cs
- HtmlTableRow.cs
- RelationshipDetailsRow.cs
- TypeBuilder.cs
- PreviewPageInfo.cs
- MemberExpression.cs
- TreeNodeConverter.cs
- SystemColors.cs
- StopStoryboard.cs
- FolderLevelBuildProviderCollection.cs
- GcSettings.cs
- MdImport.cs
- SchemaImporter.cs
- ClientBuildManager.cs
- TransactionContextValidator.cs
- GridViewCancelEditEventArgs.cs
- CqlIdentifiers.cs
- DataGridViewSortCompareEventArgs.cs
- FixedDocumentSequencePaginator.cs
- CompilerGeneratedAttribute.cs
- ContentType.cs
- FormViewUpdatedEventArgs.cs
- SevenBitStream.cs
- ArraySortHelper.cs
- StringReader.cs
- ADConnectionHelper.cs
- _NegoStream.cs
- QueryAccessibilityHelpEvent.cs
- ClientSettings.cs
- XdrBuilder.cs
- RegexCharClass.cs
- TemplateControlParser.cs
- HttpHandlerActionCollection.cs