The Labs \ Source Viewer \ SSCLI \ System.Security.Policy \ IBuiltInEvidence

  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. // IBuiltInEvidence.cs
  17. //
  18. namespace System.Security.Policy
  19. {
  20.     internal interface IBuiltInEvidence
  21.     {
  22.         int OutputToBuffer(char[] buffer, int position, bool verbose);
  23.        
  24.         // Initializes a class according to data in the buffer. Returns new position within buffer
  25.         int InitFromBuffer(char[] buffer, int position);
  26.        
  27.         int GetRequiredSize(bool verbose);
  28.     }
  29.    
  30.     static internal class BuiltInEvidenceHelper
  31.     {
  32.         internal const char idApplicationDirectory = (char)0;
  33.         internal const char idStrongName = (char)2;
  34.         internal const char idZone = (char)3;
  35.         internal const char idUrl = (char)4;
  36.         internal const char idWebPage = (char)5;
  37.         internal const char idSite = (char)6;
  38.         internal const char idPermissionRequestEvidence = (char)7;
  39.         internal const char idGac = (char)9;
  40.        
  41.         static internal void CopyIntToCharArray(int value, char[] buffer, int position)
  42.         {
  43.             buffer[position] = (char)((value >> 16) & 65535);
  44.             buffer[position + 1] = (char)((value)&65535);
  45.         }
  46.        
  47.         static internal int GetIntFromCharArray(char[] buffer, int position)
  48.         {
  49.             int value = (int)buffer[position];
  50.             value = value << 16;
  51.             value += (int)buffer[position + 1];
  52.             return value;
  53.         }
  54.        
  55.         static internal void CopyLongToCharArray(long value, char[] buffer, int position)
  56.         {
  57.             buffer[position] = (char)((value >> 48) & 65535);
  58.             buffer[position + 1] = (char)((value >> 32) & 65535);
  59.             buffer[position + 2] = (char)((value >> 16) & 65535);
  60.             buffer[position + 3] = (char)((value)&65535);
  61.         }
  62.        
  63.         static internal long GetLongFromCharArray(char[] buffer, int position)
  64.         {
  65.             long value = (long)buffer[position];
  66.             value = value << 16;
  67.             value += (long)buffer[position + 1];
  68.             value = value << 16;
  69.             value += (long)buffer[position + 2];
  70.             value = value << 16;
  71.             value += (long)buffer[position + 3];
  72.             return value;
  73.         }
  74.     }
  75. }

Developer Fusion