Welcome to mirror list, hosted at ThFree Co, Russian Federation.

EnumCheckAssemblyCollection.cs « tools « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 470492c25b581bf6bb2082aed91c495b3121bb84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
 * Namespace: System.Web
 * Class:     EnumCheckAssembly
 *
 * Author:  Gaurav Vaish
 * Contact: <gvaish@iitk.ac.in>
 * Status:  100%
 *
 * (C) Gaurav Vaish (2002)
 */

using System;
using System.IO;
using System.Xml;
using System.Collections;
using System.Reflection;

namespace Mono.Enumerations
{
	public class EnumCheckAssemblyCollection: IEnumerable
	{
		public string ConfigFile = "assemblies.xml";
		
		private ArrayList assemblyList = new ArrayList();

		public EnumCheckAssemblyCollection()
		{
		}

		public void Parse()
		{
			Stream      fStream;
			XmlReader   reader;
			XmlDocument document;
			string      url;

			fStream = new FileStream(ConfigFile, FileMode.Open, FileAccess.Read, FileShare.Read);
			reader = new XmlTextReader(fStream);
			document = new XmlDocument();
			document.Load(reader);
			if(document.DocumentElement != null)
			{
				if(document.DocumentElement.LocalName == "assemblies")
				{
					foreach(XmlNode pathNode in document.DocumentElement)
					{
						if(pathNode.NodeType == XmlNodeType.Element && pathNode.LocalName=="path")
						{
							url = pathNode.Attributes["url"].Value;
							while(url.EndsWith("\\") || url.EndsWith("/"))
							{
								url = url.Substring(0, url.Length - 1);
							}
							if(url == null || url.Length == 0)
							{
								continue;
							}
							foreach(XmlNode assemblyNode in pathNode.ChildNodes)
							{
								if(assemblyNode.LocalName == "assembly")
								{
									assemblyList.Add(url + "\\" + assemblyNode.Attributes["file"].Value);
								}
							}
						}
					}
				}
			}
			fStream.Close();
		}

		public IEnumerator GetEnumerator()
		{
			return assemblyList.GetEnumerator();
		}
	}
}