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

  1. //------------------------------------------------------------------------------
  2. // <copyright file="ConfigurationFileMap.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;
  17. using System.Collections.Specialized;
  18. using System.Security;
  19. using System.Security.Permissions;
  20. namespace System.Configuration
  21. {
  22.    
  23.     //
  24.     // Holds the configuration file mapping for
  25.     // machine.config. It is the base class for
  26.     // ExeConfigurationFileMap and WebConfigurationFileMap.
  27.     //
  28.     public class ConfigurationFileMap : ICloneable
  29.     {
  30.         string _machineConfigFilename;
  31.         bool _requirePathDiscovery;
  32.        
  33.         public ConfigurationFileMap()
  34.         {
  35.             _machineConfigFilename = ClientConfigurationHost.MachineConfigFilePath;
  36.             _requirePathDiscovery = true;
  37.         }
  38.        
  39.         public ConfigurationFileMap(string machineConfigFilename)
  40.         {
  41.             _machineConfigFilename = machineConfigFilename;
  42.         }
  43.        
  44.         public virtual object Clone()
  45.         {
  46.             return new ConfigurationFileMap(_machineConfigFilename);
  47.         }
  48.        
  49.         //
  50.         // The name of machine.config.
  51.         //
  52.         public string MachineConfigFilename {
  53.             get {
  54.                 //
  55.                 // Ensure that we use the same string to issue the demand that we use to
  56.                 // return to the caller.
  57.                 //
  58.                 string filename = _machineConfigFilename;
  59.                 if (_requirePathDiscovery) {
  60.                     new FileIOPermission(FileIOPermissionAccess.PathDiscovery, filename).Demand();
  61.                 }
  62.                
  63.                 return filename;
  64.             }
  65.            
  66.             set {
  67.                 _requirePathDiscovery = false;
  68.                 _machineConfigFilename = value;
  69.             }
  70.         }
  71.     }
  72. }

Developer Fusion