4 // Represents .assembly { }
7 // Ankit Jain <JAnkit@novell.com>
9 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
;
34 namespace Mono
.ILASM
{
36 public class Assembly
: IDeclSecurityTarget
, ICustomAttrTarget
38 private DeclSecurity decl_sec
;
39 private ArrayList customattr_list
;
42 private byte [] public_key
;
43 private int major_version
;
44 private int minor_version
;
45 private int build_version
;
46 private int revision_version
;
47 private string locale
;
48 private int hash_algorithm
;
49 private PEAPI
.AssemAttr attr
;
51 public Assembly (string name
)
60 public DeclSecurity DeclSecurity
{
63 decl_sec
= new DeclSecurity ();
68 public void SetVersion (int major
, int minor
, int build
, int revision
)
70 this.major_version
= major
;
71 this.minor_version
= minor
;
72 this.build_version
= build
;
73 this.revision_version
= revision
;
76 public void SetLocale (string locale
)
81 public void SetHashAlgorithm (int algorithm
)
83 hash_algorithm
= algorithm
;
86 public void SetPublicKey (byte [] public_key
)
88 this.public_key
= public_key
;
91 public void SetAssemblyAttr (PEAPI
.AssemAttr attr
)
96 public void AddCustomAttribute (CustomAttr customattr
)
98 if (customattr_list
== null)
99 customattr_list
= new ArrayList ();
101 customattr_list
.Add (customattr
);
104 public void Resolve (CodeGen code_gen
, PEAPI
.Assembly asm
)
106 if (customattr_list
!= null)
107 foreach (CustomAttr customattr
in customattr_list
) {
108 customattr
.AddTo (code_gen
, asm
);
111 if (decl_sec
!= null)
112 decl_sec
.AddTo (code_gen
, asm
);
115 asm
.AddAssemblyInfo(major_version
,
116 minor_version
, build_version
,
117 revision_version
, public_key
,
118 (uint) hash_algorithm
, locale
);
120 asm
.AddAssemblyAttr (attr
);