AssemblyHash.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. public struct AssemblyHash : System.ICloneable
  13. {
  14. private AssemblyHashAlgorithm _algorithm;
  15. private byte[] _value;
  16. public static readonly AssemblyHash Empty =
  17. new AssemblyHash(AssemblyHashAlgorithm.None,null);
  18. //
  19. // properties
  20. //
  21. public AssemblyHashAlgorithm Algorithm {
  22. get { return _algorithm; }
  23. set { _algorithm = value; }
  24. }
  25. //
  26. // construction
  27. //
  28. public AssemblyHash ( AssemblyHashAlgorithm algorithm, byte[] value )
  29. {
  30. _algorithm = algorithm;
  31. _value = null;
  32. if ( value != null )
  33. {
  34. int size = value.Length;
  35. _value = new byte[size];
  36. System.Array.Copy ( value, _value, size );
  37. }
  38. }
  39. public AssemblyHash ( byte[] value )
  40. : this(AssemblyHashAlgorithm.SHA1, value)
  41. {
  42. }
  43. public object Clone()
  44. {
  45. return new AssemblyHash(_algorithm,_value);
  46. }
  47. public byte[] GetValue()
  48. {
  49. return _value;
  50. }
  51. public void SetValue ( byte[] value )
  52. {
  53. _value = value;
  54. }
  55. } // class AssemblyHash
  56. } // namespace System.Configuration.Assemblies