summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Loader/FormsLoader.cs
blob: d6826830f4f04d30cdcc8d0a4af19da1b4e6ec10 (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
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms.Core.UITests;

namespace Xamarin.Forms.Loader
{
	internal sealed class FormsLoader
	{
		static IEnumerable<FormsType> formsTypes;
		static IEnumerable<TestType> iOSTestTypes;
		static IEnumerable<TestType> androidTestTypes;

		public FormsLoader()
		{
			var formsCoreAssembly = typeof (View).Assembly;
			var iOSUITestAssembly = typeof (iOSLoaderIdentifier).Assembly;
			var androidUITestAssembly = typeof (AndroidLoaderIdentifier).Assembly;

			// skip interfaces, delegates, classes that inherit from attribute
			formsTypes =
				from o in formsCoreAssembly.GetTypes()
				where o.IsVisible && o.IsClass && !o.IsDelegate() && !o.InheritsFromAttribute() && !o.InheritsFromException()
				select new FormsType(this, o);

			iOSTestTypes =
				from o in iOSUITestAssembly.GetTypes()
				where o.IsTestFixture() && o.HasCategoryAttribute()
				select new TestType(this, o);

			androidTestTypes =
				from o in androidUITestAssembly.GetTypes()
				where o.IsTestFixture() && o.HasCategoryAttribute()
				select new TestType(this, o);
		}

		public IEnumerable<FormsType> FormsTypes()
		{
			return formsTypes;
		}

		public IEnumerable<TestType> IOSTestTypes()
		{
			return iOSTestTypes;
		}

		public IEnumerable<TestType> AndroidTestTypes()
		{
			return androidTestTypes;
		}
	}
}