Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / TransactionBridge / Microsoft / Transactions / Wsat / Protocol / RegistryConfigurationProvider.cs / 1 / RegistryConfigurationProvider.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- // Implement the ConfigurationProvider base class for the system registry using System; using System.ServiceModel.Channels; using System.IO; using System.Security; using System.Security.AccessControl; using Microsoft.Transactions.Bridge; using Microsoft.Win32; namespace Microsoft.Transactions.Wsat.Protocol { class RegistryConfigurationProvider : ConfigurationProvider { RegistryKey regKey; public RegistryConfigurationProvider(RegistryKey rootKey, string subKey) { try { if (rootKey != null) { // This can return null if the key does not exist this.regKey = rootKey.OpenSubKey(subKey, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadKey); } } catch (SecurityException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ConfigurationProviderException(SR.GetString(SR.RegistryKeyOpenSubKeyFailed, subKey, rootKey.Name, e.Message), e)); } catch (IOException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ConfigurationProviderException(SR.GetString(SR.RegistryKeyOpenSubKeyFailed, subKey, rootKey.Name, e.Message), e)); } } public override void Dispose() { if (this.regKey != null) { this.regKey.Close(); this.regKey = null; } } object ReadValue(string value, object defaultValue) { if (this.regKey == null) return defaultValue; try { return this.regKey.GetValue(value, defaultValue); } catch (SecurityException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ConfigurationProviderException(SR.GetString(SR.RegistryKeyGetValueFailed, value, this.regKey.Name, e.Message), e)); } catch (IOException e) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new ConfigurationProviderException(SR.GetString(SR.RegistryKeyGetValueFailed, value, this.regKey.Name, e.Message), e)); } } public override int ReadInteger(string value, int defaultValue) { object regValue = ReadValue(value, defaultValue); if (regValue == null || !(regValue is Int32)) return defaultValue; return (int)regValue; } public override string ReadString(string value, string defaultValue) { object regValue = ReadValue(value, defaultValue); if (regValue == null) return defaultValue; string regString = regValue as string; if (regString == null) return defaultValue; return regString; } public override string[] ReadMultiString(string value, string[] defaultValue) { object regValue = ReadValue(value, defaultValue); if (regValue == null) return defaultValue; string[] regMulti = regValue as string[]; if (regMulti == null) return defaultValue; return regMulti; } public override ConfigurationProvider OpenKey(string key) { return new RegistryConfigurationProvider(this.regKey, key); } } } // 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
- SoapBinding.cs
- MimeParameter.cs
- QueueProcessor.cs
- NumberFormatInfo.cs
- Attributes.cs
- SourceFileBuildProvider.cs
- RelationshipConverter.cs
- ObjectStateEntryDbDataRecord.cs
- SqlBuilder.cs
- TemplateControl.cs
- DivideByZeroException.cs
- MimeMapping.cs
- OracleBinary.cs
- ConsumerConnectionPoint.cs
- ListChunk.cs
- ValueExpressions.cs
- _AuthenticationState.cs
- EnumerationRangeValidationUtil.cs
- Certificate.cs
- _HeaderInfo.cs
- LicenseException.cs
- ConnectionProviderAttribute.cs
- ProjectionPath.cs
- SessionState.cs
- SocketException.cs
- EncoderNLS.cs
- hwndwrapper.cs
- SqlOuterApplyReducer.cs
- StateMachineSubscriptionManager.cs
- DesignerTransaction.cs
- TimeSpan.cs
- HelpProvider.cs
- LinkButton.cs
- DataGridAutoFormatDialog.cs
- PreProcessInputEventArgs.cs
- LinearGradientBrush.cs
- DebugInfoGenerator.cs
- Brush.cs
- ToolboxItemAttribute.cs
- GenericQueueSurrogate.cs
- BaseValidator.cs
- MachineKeyConverter.cs
- ProcessThreadDesigner.cs
- PeerNearMe.cs
- Trace.cs
- HtmlLabelAdapter.cs
- CustomError.cs
- SecondaryIndex.cs
- FunctionImportElement.cs
- SymbolTable.cs
- UserPreferenceChangedEventArgs.cs
- RowToParametersTransformer.cs
- CellQuery.cs
- ExpressionBuilderCollection.cs
- TextParagraphProperties.cs
- ThicknessKeyFrameCollection.cs
- SystemFonts.cs
- SuppressMessageAttribute.cs
- Int32RectValueSerializer.cs
- DefaultMergeHelper.cs
- OwnerDrawPropertyBag.cs
- TextRenderingModeValidation.cs
- CompModSwitches.cs
- TemplatePropertyEntry.cs
- ShaderEffect.cs
- ToolStripSettings.cs
- XamlStyleSerializer.cs
- Vector3DAnimation.cs
- DataGridView.cs
- DrawingContextDrawingContextWalker.cs
- RSAOAEPKeyExchangeDeformatter.cs
- BufferedGraphics.cs
- VectorCollectionValueSerializer.cs
- ArithmeticLiteral.cs
- xmlsaver.cs
- AuthenticatingEventArgs.cs
- CorrelationScope.cs
- WorkflowHostingResponseContext.cs
- DefaultEventAttribute.cs
- RadioButtonFlatAdapter.cs
- DriveNotFoundException.cs
- FixedSOMPageConstructor.cs
- IgnoreSection.cs
- DisplayNameAttribute.cs
- ProxyWebPart.cs
- PropertyItem.cs
- DeclarativeCatalogPart.cs
- MetadataArtifactLoaderCompositeResource.cs
- StatusBarPanel.cs
- DataRowCollection.cs
- Merger.cs
- QuerySafeNavigator.cs
- HttpAsyncResult.cs
- AccessDataSourceView.cs
- DeviceFilterDictionary.cs
- XmlILConstructAnalyzer.cs
- MsmqIntegrationSecurity.cs
- LambdaExpression.cs
- ConnectionManagementSection.cs
- WindowsImpersonationContext.cs