The Labs \ Source Viewer \ SSCLI \ System.Configuration \ SectionInput

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SectionInput.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. using System;
  16. using System.Collections.Generic;
  17. namespace System.Configuration
  18. {
  19.    
  20.     [System.Diagnostics.DebuggerDisplay("SectionInput {_sectionXmlInfo.ConfigKey}")]
  21.     internal class SectionInput
  22.     {
  23.         // result can be null, so we use this object to indicate whether it has been evaluated
  24.         private static object s_unevaluated = new object();
  25.        
  26.         // input from the XML file
  27.         private SectionXmlInfo _sectionXmlInfo;
  28.        
  29.         // Provider to use for encryption
  30.         private ProtectedConfigurationProvider _protectionProvider;
  31.        
  32.         // Has the protection provider been determined for this input?
  33.         private bool _isProtectionProviderDetermined;
  34.        
  35.         // the result of evaluating this section
  36.         private object _result;
  37.        
  38.         // the result of evaluating this section after GetRuntimeObject is called
  39.         private object _resultRuntimeObject;
  40.        
  41.         // accummulated errors related to this input
  42.         private List<ConfigurationException> _errors;
  43.        
  44.         internal SectionInput(SectionXmlInfo sectionXmlInfo, List<ConfigurationException> errors)
  45.         {
  46.             _sectionXmlInfo = sectionXmlInfo;
  47.             _errors = errors;
  48.            
  49.             _result = s_unevaluated;
  50.             _resultRuntimeObject = s_unevaluated;
  51.         }
  52.        
  53.         internal SectionXmlInfo SectionXmlInfo {
  54.             get { return _sectionXmlInfo; }
  55.         }
  56.        
  57.         internal bool HasResult {
  58.             get { return _result != s_unevaluated; }
  59.         }
  60.        
  61.         internal bool HasResultRuntimeObject {
  62.             get { return _resultRuntimeObject != s_unevaluated; }
  63.         }
  64.        
  65.         internal object Result {
  66. // Useful assert, but it fires in the debugger when using automatic property evaluation
  67. // Debug.Assert(_result != s_unevaluated, "_result != s_unevaluated");
  68.             get { return _result; }
  69.            
  70.             set { _result = value; }
  71.         }
  72.        
  73.         internal object ResultRuntimeObject {
  74. // Useful assert, but it fires in the debugger when using automatic property evaluation
  75. // Debug.Assert(_resultRuntimeObject != s_unevaluated, "_resultRuntimeObject != s_unevaluated");
  76.             get { return _resultRuntimeObject; }
  77.            
  78.             set { _resultRuntimeObject = value; }
  79.         }
  80.        
  81.         internal void ClearResult()
  82.         {
  83.             _result = s_unevaluated;
  84.             _resultRuntimeObject = s_unevaluated;
  85.         }
  86.        
  87.         internal bool IsProtectionProviderDetermined {
  88.             get { return _isProtectionProviderDetermined; }
  89.         }
  90.        
  91.         internal ProtectedConfigurationProvider ProtectionProvider {
  92.             get { return _protectionProvider; }
  93.             set {
  94.                 _protectionProvider = value;
  95.                 _isProtectionProviderDetermined = true;
  96.             }
  97.         }
  98.        
  99.         // Errors associated with a section input.
  100.         internal ICollection<ConfigurationException> Errors {
  101.             get { return _errors; }
  102.         }
  103.        
  104.         internal bool HasErrors {
  105.             get { return ErrorsHelper.GetHasErrors(_errors); }
  106.         }
  107.        
  108.         internal void ThrowOnErrors()
  109.         {
  110.             ErrorsHelper.ThrowOnErrors(_errors);
  111.         }
  112.     }
  113. }

Developer Fusion