2 // AssemblyLoadInfo.cs: Information needed to load logger or task class.
4 // NOTE: It's not included in Microsoft.Build.Framework only in
5 // Microsoft.Build.Engine and tools/xbuild.
8 // Marek Sieradzki (marek.sieradzki@gmail.com)
10 // (C) 2005 Marek Sieradzki
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Globalization
;
33 using System
.Reflection
;
35 namespace Mono
.XBuild
.Framework
{
36 internal class AssemblyLoadInfo
{
38 AssemblyName assemblyName
;
39 string assemblyNameString
;
42 LoadInfoType infoType
;
44 public AssemblyLoadInfo ()
48 public AssemblyLoadInfo (string assemblyName
, string className
)
50 this.assemblyName
= new AssemblyName (assemblyName
);
51 this.className
= className
;
52 assemblyNameString
= null;
53 infoType
= LoadInfoType
.AssemblyName
;
56 public AssemblyLoadInfo (LoadInfoType loadInfoType
, string filename
, string name
,
57 string version
, string culture
, string publicKeyToken
, string className
)
59 SetAssemblyName (loadInfoType
, filename
, name
, version
, culture
, publicKeyToken
, className
);
62 protected void SetAssemblyName (LoadInfoType loadInfoType
, string filename
, string name
, string version
,
63 string culture
, string publicKeyToken
, string className
)
65 assemblyName
= new AssemblyName ();
66 this.infoType
= loadInfoType
;
67 this.className
= className
;
68 if (infoType
== LoadInfoType
.AssemblyName
) {
70 assemblyName
.Version
= new Version (version
);
71 if (culture
!= null) {
72 if (culture
== "neutral")
73 culture
= String
.Empty
;
74 assemblyName
.CultureInfo
= new CultureInfo (culture
);
76 if (publicKeyToken
!= null) {
77 char[] chars
= publicKeyToken
.ToCharArray ();
78 byte[] bytes
= new byte [Buffer
.ByteLength (chars
)];
80 for (int i
= 0; i
< Buffer
.ByteLength (chars
); i
++)
81 bytes
[i
] = Buffer
.GetByte (chars
, i
);
82 assemblyName
.SetPublicKeyToken (bytes
);
85 assemblyName
.Name
= name
;
86 } else if (infoType
== LoadInfoType
.AssemblyFilename
) {
87 this.filename
= filename
;
93 public AssemblyName AssemblyName
{
94 get { return assemblyName; }
97 public string AssemblyNameString
{
98 get { return assemblyNameString; }
101 public string Filename
{
102 get { return filename; }
105 public LoadInfoType InfoType
{
106 get { return infoType; }
109 public string ClassName
{
110 get { return className; }
114 get { return Type.GetType (className); }
118 internal enum LoadInfoType
{
121 AssemblyNameFromString