forked from tylike/CIIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewsManager.cs
More file actions
59 lines (51 loc) · 2.28 KB
/
Copy pathViewsManager.cs
File metadata and controls
59 lines (51 loc) · 2.28 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
namespace CIIP.CodeFirstView
{
public class ViewsManager
{
//public static void Initialize(XafApplication app)
//{
// var asm = AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.FullName.StartsWith("DevExpress.") && !x.FullName.StartsWith("System."));
// //app.Modules.Where(
// // x => !x.AssemblyName.StartsWith("DevExpress.") && !x.AssemblyName.StartsWith("System."));
// var types =
// asm.SelectMany(x => x.GetType().Assembly.GetTypes())
// .Where(t => typeof(ViewObject).IsAssignableFrom(t) && !t.IsAbstract);
// ViewObjectTypes = types.ToList();
// ViewObjects = new List<ViewObject>();
// foreach (var item in ViewObjectTypes)
// {
// ViewObjects.Add(Activator.CreateInstance(item) as ViewObject);
// }
//}
static List<ViewObject> _viewObjects;
public static List<ViewObject> ViewObjects
{
get
{
if (_viewObjects == null)
{
var asm = AppDomain.CurrentDomain.GetAssemblies().Where(x => !x.FullName.StartsWith("DevExpress.") && !x.FullName.StartsWith("System.") && !x.FullName.StartsWith("Microsoft.") && !x.FullName.StartsWith("mscorlib."));
//app.Modules.Where(
// x => !x.AssemblyName.StartsWith("DevExpress.") && !x.AssemblyName.StartsWith("System."));
var types =
asm.SelectMany(x => x.GetTypes())
.Where(t => typeof(ViewObject).IsAssignableFrom(t) && !t.IsAbstract && !t.IsGenericType);
ViewObjectTypes = types.ToList();
_viewObjects = new List<ViewObject>();
foreach (var item in ViewObjectTypes)
{
_viewObjects.Add(Activator.CreateInstance(item) as ViewObject);
}
}
return _viewObjects;
}
}
public static List<Type> ViewObjectTypes
{
get; private set;
}
}
}