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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ConfigDefinitionUpdates.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. namespace System.Configuration
  16. {
  17.     using System.Collections;
  18.    
  19.     //
  20.     // Contains all the updates to section definitions across all location sections.
  21.     //
  22.     internal class ConfigDefinitionUpdates
  23.     {
  24.         private ArrayList _locationUpdatesList;
  25.         private bool _requireLocationWritten;
  26.        
  27.         internal ConfigDefinitionUpdates()
  28.         {
  29.             _locationUpdatesList = new ArrayList();
  30.         }
  31.        
  32.         //
  33.         // Find the location update with a certain set of location attributes.
  34.         //
  35.         internal LocationUpdates FindLocationUpdates(bool allowOverride, bool inheritInChildApps)
  36.         {
  37.             foreach (LocationUpdates locationUpdates in _locationUpdatesList) {
  38.                 if (locationUpdates.AllowOverride == allowOverride && locationUpdates.InheritInChildApps == inheritInChildApps) {
  39.                     return locationUpdates;
  40.                 }
  41.             }
  42.            
  43.             return null;
  44.         }
  45.        
  46.         //
  47.         // Add a section definition update to the correct location update.
  48.         //
  49.         internal DefinitionUpdate AddUpdate(bool allowOverride, bool inheritInChildApps, bool moved, string updatedXml, SectionRecord sectionRecord)
  50.         {
  51.             LocationUpdates locationUpdates = FindLocationUpdates(allowOverride, inheritInChildApps);
  52.             if (locationUpdates == null) {
  53.                 locationUpdates = new LocationUpdates(allowOverride, inheritInChildApps);
  54.                 _locationUpdatesList.Add(locationUpdates);
  55.             }
  56.            
  57.             DefinitionUpdate definitionUpdate = new DefinitionUpdate(sectionRecord.ConfigKey, moved, updatedXml, sectionRecord);
  58.             locationUpdates.SectionUpdates.AddSection(definitionUpdate);
  59.             return definitionUpdate;
  60.         }
  61.        
  62.         //
  63.         // Determine which section definition updates are new.
  64.         //
  65.         internal void CompleteUpdates()
  66.         {
  67.             foreach (LocationUpdates locationUpdates in _locationUpdatesList) {
  68.                 locationUpdates.CompleteUpdates();
  69.             }
  70.         }
  71.        
  72.         internal ArrayList LocationUpdatesList {
  73.             get { return _locationUpdatesList; }
  74.         }
  75.        
  76.         internal bool RequireLocation {
  77.             get { return _requireLocationWritten; }
  78.             set { _requireLocationWritten = value; }
  79.         }
  80.        
  81.         internal void FlagLocationWritten()
  82.         {
  83.             _requireLocationWritten = false;
  84.         }
  85.     }
  86. }

Developer Fusion