Tue May 13 15:34:29 CEST 2003 Paolo Molaro <lupus@ximian.com>
[mono.git] / mcs / class / corlib / System.Configuration.Assemblies / AssemblyHash.cs
1 \r
2 //\r
3 // AssemblyHash.cs\r
4 //\r
5 //    Implementation of the \r
6 //    System.Configuration.Assemblies.AssemblyHash\r
7 //    class for the Mono Class Library\r
8 //\r
9 // Author:\r
10 //    Tomas Restrepo (tomasr@mvps.org)\r
11 //\r
12 \r
13 namespace System.Configuration.Assemblies {\r
14    \r
15         [Serializable]\r
16    public struct AssemblyHash : System.ICloneable\r
17    {\r
18       private AssemblyHashAlgorithm _algorithm;\r
19       private byte[] _value;\r
20 \r
21       public static readonly AssemblyHash Empty = \r
22          new AssemblyHash(AssemblyHashAlgorithm.None,null);\r
23 \r
24 \r
25       //\r
26       // properties\r
27       //\r
28       public AssemblyHashAlgorithm Algorithm {\r
29          get { return _algorithm; }\r
30          set { _algorithm = value; }\r
31       }\r
32 \r
33 \r
34       //\r
35       // construction\r
36       //\r
37       public AssemblyHash ( AssemblyHashAlgorithm algorithm, byte[] value )\r
38       {\r
39          _algorithm = algorithm;\r
40          _value = null;\r
41          if ( value != null )\r
42          {\r
43             int size = value.Length;\r
44             _value = new byte[size];\r
45             System.Array.Copy ( value, _value, size );\r
46          }\r
47       }\r
48 \r
49       public AssemblyHash ( byte[] value )\r
50          : this(AssemblyHashAlgorithm.SHA1, value)\r
51       {\r
52       }\r
53 \r
54       public object Clone()\r
55       {\r
56          return new AssemblyHash(_algorithm,_value);\r
57       }\r
58 \r
59       public byte[] GetValue()\r
60       {\r
61          return _value;\r
62       }\r
63       public void SetValue ( byte[] value )\r
64       {\r
65          _value = value;\r
66       }\r
67 \r
68    } // class AssemblyHash\r
69 \r
70 } // namespace System.Configuration.Assemblies\r
71 \r