AssemblyHash.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // AssemblyHash.cs
  3. //
  4. // Implementation of the
  5. // System.Configuration.Assemblies.AssemblyHash
  6. // class for the Mono Class Library
  7. //
  8. // Author:
  9. // Tomas Restrepo ([email protected])
  10. //
  11. namespace System.Configuration.Assemblies {
  12. [Serializable]
  13. public struct AssemblyHash : System.ICloneable
  14. {
  15. private AssemblyHashAlgorithm _algorithm;
  16. private byte[] _value;
  17. public static readonly AssemblyHash Empty =
  18. new AssemblyHash(AssemblyHashAlgorithm.None,null);
  19. //
  20. // properties
  21. //
  22. public AssemblyHashAlgorithm Algorithm {
  23. get { return _algorithm; }
  24. set { _algorithm = value; }
  25. }
  26. //
  27. // construction
  28. //
  29. public AssemblyHash ( AssemblyHashAlgorithm algorithm, byte[] value )
  30. {
  31. _algorithm = algorithm;
  32. _value = null;
  33. if ( value != null )
  34. {
  35. int size = value.Length;
  36. _value = new byte[size];
  37. System.Array.Copy ( value, _value, size );
  38. }
  39. }
  40. public AssemblyHash ( byte[] value )
  41. : this(AssemblyHashAlgorithm.SHA1, value)
  42. {
  43. }
  44. public object Clone()
  45. {
  46. return new AssemblyHash(_algorithm,_value);
  47. }
  48. public byte[] GetValue()
  49. {
  50. return _value;
  51. }
  52. public void SetValue ( byte[] value )
  53. {
  54. _value = value;
  55. }
  56. } // class AssemblyHash
  57. } // namespace System.Configuration.Assemblies