The Labs \ Source Viewer \ SSCLI \ System.Security.Util \ Config

  1. // ==++==
  2. //
  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. //
  14. // ==--==
  15. //
  16. // Config.cs
  17. //
  18. namespace System.Security.Util
  19. {
  20.     using System;
  21.     using System.Security.Util;
  22.     using System.Security.Policy;
  23.     using System.Security.Permissions;
  24.     using System.Collections;
  25.     using System.IO;
  26.     using System.Reflection;
  27.     using System.Globalization;
  28.     using System.Text;
  29.     using System.Runtime.Serialization.Formatters.Binary;
  30.     using System.Threading;
  31.     using System.Runtime.CompilerServices;
  32.    
  33.     // Duplicated in vm\COMSecurityConfig.h
  34.     [Serializable(), Flags()]
  35.     internal enum QuickCacheEntryType
  36.     {
  37.         FullTrustZoneMyComputer = 16777216,
  38.         FullTrustZoneIntranet = 33554432,
  39.         FullTrustZoneInternet = 67108864,
  40.         FullTrustZoneTrusted = 134217728,
  41.         FullTrustZoneUntrusted = 268435456,
  42.         FullTrustAll = 536870912
  43.     }
  44.    
  45.     static internal class Config
  46.     {
  47.         private static string m_machineConfig;
  48.         private static string m_userConfig;
  49.        
  50.         private static void GetFileLocales()
  51.         {
  52.             if (m_machineConfig == null)
  53.                 m_machineConfig = _GetMachineDirectory();
  54.             if (m_userConfig == null)
  55.                 m_userConfig = _GetUserDirectory();
  56.         }
  57.        
  58.         static internal string MachineDirectory {
  59.             get {
  60.                 GetFileLocales();
  61.                 return m_machineConfig;
  62.             }
  63.         }
  64.        
  65.         static internal string UserDirectory {
  66.             get {
  67.                 GetFileLocales();
  68.                 return m_userConfig;
  69.             }
  70.         }
  71.        
  72.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  73.         static internal extern bool SaveDataByte(string path, byte[] data, int offset, int length);
  74.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  75.         static internal extern bool RecoverData(ConfigId id);
  76.        
  77.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  78.         static internal extern void SetQuickCache(ConfigId id, QuickCacheEntryType quickCacheFlags);
  79.        
  80.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  81.         static internal extern bool GetCacheEntry(ConfigId id, int numKey, char[] key, out byte[] data);
  82.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  83.         static internal extern void AddCacheEntry(ConfigId id, int numKey, char[] key, byte[] data);
  84.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  85.         static internal extern void ResetCacheData(ConfigId id);
  86.        
  87.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  88.         private static extern string _GetMachineDirectory();
  89.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  90.         private static extern string _GetUserDirectory();
  91.        
  92.         [MethodImplAttribute(MethodImplOptions.InternalCall)]
  93.         static internal extern bool WriteToEventLog(string message);
  94.     }
  95. }

Developer Fusion