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
- InstanceLockedException.cs
- FlowNode.cs
- XamlRtfConverter.cs
- LogArchiveSnapshot.cs
- PropertyValueChangedEvent.cs
- PenThreadPool.cs
- DynamicPropertyHolder.cs
- DownloadProgressEventArgs.cs
- WebPartConnectionsConnectVerb.cs
- SelectedGridItemChangedEvent.cs
- DbDataSourceEnumerator.cs
- SpellCheck.cs
- TabControl.cs
- Debug.cs
- QuadraticBezierSegment.cs
- TypeConvertions.cs
- GridProviderWrapper.cs
- NotifyIcon.cs
- BuildProvider.cs
- KeyValuePair.cs
- GifBitmapEncoder.cs
- ModelItemImpl.cs
- OdbcDataReader.cs
- ObjectListDataBindEventArgs.cs
- TTSVoice.cs
- DocumentPageViewAutomationPeer.cs
- SqlCacheDependency.cs
- TemplateBuilder.cs
- SwitchAttribute.cs
- ListDictionaryInternal.cs
- CollectionConverter.cs
- TypeInitializationException.cs
- GeneralTransformCollection.cs
- OdbcCommand.cs
- UnmanagedMemoryStream.cs
- MarshalDirectiveException.cs
- DesignerLabelAdapter.cs
- PointAnimation.cs
- ProjectionAnalyzer.cs
- PrincipalPermission.cs
- DataGridColumnReorderingEventArgs.cs
- FixedSOMTextRun.cs
- ListViewItem.cs
- ResXResourceWriter.cs
- ToolStripControlHost.cs
- WindowsFormsHostPropertyMap.cs
- RuleElement.cs
- QilInvoke.cs
- DesignerTransactionCloseEvent.cs
- TypeResolvingOptionsAttribute.cs
- HttpModuleActionCollection.cs
- SelectionGlyphBase.cs
- updateconfighost.cs
- SurrogateChar.cs
- ReflectionServiceProvider.cs
- GridViewSelectEventArgs.cs
- DiscoveryUtility.cs
- DataExpression.cs
- StickyNoteAnnotations.cs
- BindingsCollection.cs
- EventMap.cs
- XmlSchemaValidator.cs
- OleDbWrapper.cs
- SqlBooleanMismatchVisitor.cs
- ImageSource.cs
- ProfileService.cs
- OptimizerPatterns.cs
- _ListenerAsyncResult.cs
- Opcode.cs
- DataGridViewButtonCell.cs
- FileDialog_Vista.cs
- Assert.cs
- IssuedTokensHeader.cs
- Application.cs
- SecurityCriticalDataForSet.cs
- RequestNavigateEventArgs.cs
- SatelliteContractVersionAttribute.cs
- AuthenticationModuleElementCollection.cs
- TargetException.cs
- PermissionSetEnumerator.cs
- Utility.cs
- SafeCryptHandles.cs
- StringValidatorAttribute.cs
- InheritedPropertyChangedEventArgs.cs
- SpellerHighlightLayer.cs
- DbgCompiler.cs
- RectangleGeometry.cs
- DocumentXPathNavigator.cs
- diagnosticsswitches.cs
- RegexCode.cs
- SkewTransform.cs
- WebMessageBodyStyleHelper.cs
- UrlAuthorizationModule.cs
- XmlSchemaComplexContentExtension.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- DoubleLinkListEnumerator.cs
- Part.cs
- DataColumnChangeEvent.cs
- RoutingSection.cs
- SqlInternalConnection.cs