The Labs \ Source Viewer \ SSCLI \ System.Configuration.Internal \ DelegatingConfigHost

  1. //------------------------------------------------------------------------------
  2. // <copyright file="DelegatingConfigHost.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.Internal
  16. {
  17.     using System.Configuration;
  18.     using System.IO;
  19.     using System.Security.Permissions;
  20.     using System.Reflection;
  21.     using System.Threading;
  22.     using System.Security;
  23.     using System.CodeDom.Compiler;
  24.    
  25.     //
  26.     // A public implementation of IInternalConfigHost that simply
  27.     // delegates all members of the IInternalConfigHost interface to
  28.     // another instance of a host. All interface members are marked virtual
  29.     // so that a derived class can override just the ones needed to
  30.     // implement that specific host, while all others are delegated to
  31.     // another implementation such as InternalConfigHost.
  32.     //
  33.     // The advantages of this arrangement are:
  34.     // * The IInternalConfigHost interface can be extended without
  35.     // requiring other hosts to be updated.
  36.     // * This class that we are making public has no implementation
  37.     // of its own that can be exploited. All the hosts with meaningful
  38.     // implementation can remain internal.
  39.     // * It allows straightforward chaining of host functionality,
  40.     // see UpdateConfigHost as an example.
  41.     //
  42.     public class DelegatingConfigHost : IInternalConfigHost
  43.     {
  44.         IInternalConfigHost _host;
  45.        
  46.         protected DelegatingConfigHost()
  47.         {
  48.         }
  49.        
  50.         // The host that is delegated to.
  51.         protected IInternalConfigHost Host {
  52.             get { return _host; }
  53.             set { _host = value; }
  54.         }
  55.        
  56.         public virtual void Init(IInternalConfigRoot configRoot, params object[] hostInitParams)
  57.         {
  58.             Host.Init(configRoot, hostInitParams);
  59.         }
  60.        
  61.         public virtual void InitForConfiguration(ref string locationSubPath, out string configPath, out string locationConfigPath, IInternalConfigRoot configRoot, params object[] hostInitConfigurationParams)
  62.         {
  63.            
  64.             Host.InitForConfiguration(ref locationSubPath, out configPath, out locationConfigPath, configRoot, hostInitConfigurationParams);
  65.         }
  66.        
  67.         public virtual bool IsConfigRecordRequired(string configPath)
  68.         {
  69.             return Host.IsConfigRecordRequired(configPath);
  70.         }
  71.        
  72.         public virtual bool IsInitDelayed(IInternalConfigRecord configRecord)
  73.         {
  74.             return Host.IsInitDelayed(configRecord);
  75.         }
  76.        
  77.         public virtual void RequireCompleteInit(IInternalConfigRecord configRecord)
  78.         {
  79.             Host.RequireCompleteInit(configRecord);
  80.         }
  81.        
  82.         // IsSecondaryRoot
  83.         //
  84.         // Is this a secondary root. This means that it is a node in which
  85.         // everything that is defined in it should also be treated as a root.
  86.         // So...if a factory record is defined that was already defined above
  87.         // then throw since it is not allowed.
  88.         //
  89.         public virtual bool IsSecondaryRoot(string configPath)
  90.         {
  91.             return Host.IsSecondaryRoot(configPath);
  92.         }
  93.        
  94.         public virtual string GetStreamName(string configPath)
  95.         {
  96.             return Host.GetStreamName(configPath);
  97.         }
  98.        
  99.         public virtual string GetStreamNameForConfigSource(string streamName, string configSource)
  100.         {
  101.             return Host.GetStreamNameForConfigSource(streamName, configSource);
  102.         }
  103.        
  104.         public virtual object GetStreamVersion(string streamName)
  105.         {
  106.             return Host.GetStreamVersion(streamName);
  107.         }
  108.        
  109.         public virtual Stream OpenStreamForRead(string streamName)
  110.         {
  111.             return Host.OpenStreamForRead(streamName);
  112.         }
  113.        
  114.         public virtual Stream OpenStreamForRead(string streamName, bool assertPermissions)
  115.         {
  116.             return Host.OpenStreamForRead(streamName, assertPermissions);
  117.         }
  118.        
  119.         public virtual Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext)
  120.         {
  121.             return Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext);
  122.         }
  123.        
  124.         public virtual Stream OpenStreamForWrite(string streamName, string templateStreamName, ref object writeContext, bool assertPermissions)
  125.         {
  126.             return Host.OpenStreamForWrite(streamName, templateStreamName, ref writeContext, assertPermissions);
  127.         }
  128.        
  129.         public virtual void WriteCompleted(string streamName, bool success, object writeContext)
  130.         {
  131.             Host.WriteCompleted(streamName, success, writeContext);
  132.         }
  133.        
  134.         public virtual void WriteCompleted(string streamName, bool success, object writeContext, bool assertPermissions)
  135.         {
  136.             Host.WriteCompleted(streamName, success, writeContext, assertPermissions);
  137.         }
  138.        
  139.         public virtual void DeleteStream(string streamName)
  140.         {
  141.             Host.DeleteStream(streamName);
  142.         }
  143.        
  144.         public virtual bool IsFile(string streamName)
  145.         {
  146.             return Host.IsFile(streamName);
  147.         }
  148.        
  149.         public virtual bool SupportsChangeNotifications {
  150.             get { return Host.SupportsChangeNotifications; }
  151.         }
  152.        
  153.         public virtual object StartMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
  154.         {
  155.             return Host.StartMonitoringStreamForChanges(streamName, callback);
  156.         }
  157.        
  158.         public virtual void StopMonitoringStreamForChanges(string streamName, StreamChangeCallback callback)
  159.         {
  160.             Host.StopMonitoringStreamForChanges(streamName, callback);
  161.         }
  162.        
  163.         public virtual bool SupportsRefresh {
  164.             get { return Host.SupportsRefresh; }
  165.         }
  166.        
  167.         public virtual bool SupportsPath {
  168.             get { return Host.SupportsPath; }
  169.         }
  170.        
  171.         public virtual bool SupportsLocation {
  172.             get { return Host.SupportsLocation; }
  173.         }
  174.        
  175.         public virtual bool IsAboveApplication(string configPath)
  176.         {
  177.             return Host.IsAboveApplication(configPath);
  178.         }
  179.        
  180.         public virtual bool IsDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition)
  181.         {
  182.             return Host.IsDefinitionAllowed(configPath, allowDefinition, allowExeDefinition);
  183.         }
  184.        
  185.         public virtual void VerifyDefinitionAllowed(string configPath, ConfigurationAllowDefinition allowDefinition, ConfigurationAllowExeDefinition allowExeDefinition, IConfigErrorInfo errorInfo)
  186.         {
  187.             Host.VerifyDefinitionAllowed(configPath, allowDefinition, allowExeDefinition, errorInfo);
  188.         }
  189.        
  190.         public virtual string GetConfigPathFromLocationSubPath(string configPath, string locationSubPath)
  191.         {
  192.             return Host.GetConfigPathFromLocationSubPath(configPath, locationSubPath);
  193.         }
  194.        
  195.         public virtual bool IsLocationApplicable(string configPath)
  196.         {
  197.             return Host.IsLocationApplicable(configPath);
  198.         }
  199.        
  200.         public virtual bool IsTrustedConfigPath(string configPath)
  201.         {
  202.             return Host.IsTrustedConfigPath(configPath);
  203.         }
  204.        
  205.         public virtual bool IsFullTrustSectionWithoutAptcaAllowed(IInternalConfigRecord configRecord)
  206.         {
  207.             return Host.IsFullTrustSectionWithoutAptcaAllowed(configRecord);
  208.         }
  209.        
  210.         public virtual void GetRestrictedPermissions(IInternalConfigRecord configRecord, out PermissionSet permissionSet, out bool isHostReady)
  211.         {
  212.             Host.GetRestrictedPermissions(configRecord, out permissionSet, out isHostReady);
  213.         }
  214.        
  215.         public virtual IDisposable Impersonate()
  216.         {
  217.             return Host.Impersonate();
  218.         }
  219.        
  220.         public virtual bool PrefetchAll(string configPath, string streamName)
  221.         {
  222.             return Host.PrefetchAll(configPath, streamName);
  223.         }
  224.        
  225.         public virtual bool PrefetchSection(string sectionGroupName, string sectionName)
  226.         {
  227.             return Host.PrefetchSection(sectionGroupName, sectionName);
  228.         }
  229.        
  230.         public virtual object CreateDeprecatedConfigContext(string configPath)
  231.         {
  232.             return Host.CreateDeprecatedConfigContext(configPath);
  233.         }
  234.        
  235.         public virtual object CreateConfigurationContext(string configPath, string locationSubPath)
  236.         {
  237.             return Host.CreateConfigurationContext(configPath, locationSubPath);
  238.         }
  239.        
  240.         public virtual string DecryptSection(string encryptedXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection)
  241.         {
  242.             return Host.DecryptSection(encryptedXml, protectionProvider, protectedConfigSection);
  243.         }
  244.        
  245.         public virtual string EncryptSection(string clearTextXml, ProtectedConfigurationProvider protectionProvider, ProtectedConfigurationSection protectedConfigSection)
  246.         {
  247.             return Host.EncryptSection(clearTextXml, protectionProvider, protectedConfigSection);
  248.         }
  249.        
  250.         public virtual Type GetConfigType(string typeName, bool throwOnError)
  251.         {
  252.             return Host.GetConfigType(typeName, throwOnError);
  253.         }
  254.        
  255.         public virtual string GetConfigTypeName(Type t)
  256.         {
  257.             return Host.GetConfigTypeName(t);
  258.         }
  259.        
  260.         public virtual bool IsRemote {
  261.             get { return Host.IsRemote; }
  262.         }
  263.        
  264.     }
  265. }

Developer Fusion