-
Notifications
You must be signed in to change notification settings - Fork 305
Expand file tree
/
Copy pathProviders.cs
More file actions
60 lines (53 loc) · 2.2 KB
/
Providers.cs
File metadata and controls
60 lines (53 loc) · 2.2 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
60
// Copyright 2005, 2006 - Morten Nielsen (www.iter.dk)
//
// This file is part of SharpMap.
// SharpMap is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SharpMap is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License
// along with SharpMap; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Collections.ObjectModel;
using System.Reflection;
namespace SharpMap.Utilities
{
/// <summary>
/// Provider helper utilities
/// </summary>
public class Providers
{
/// <summary>
/// Returns a list of available data providers in this assembly
/// </summary>
public static Collection<Type> GetProviders()
{
Collection<Type> ProviderList = new Collection<Type>();
// Ask the current AppDomain for a list of all
// loaded assemblies.
AppDomain ad = AppDomain.CurrentDomain;
Assembly[] loadedAssemblies = ad.GetAssemblies();
foreach (Assembly asm in loadedAssemblies)
foreach (Type t in asm.GetTypes())
if ((t.IsClass) && (t.GetInterface("SharpMap.Data.Providers.IProvider") != null))
ProviderList.Add(t);
return ProviderList;
}
/// <summary>
/// Filter method used for searching for objects in an assembly
/// </summary>
/// <param name="typeObj"></param>
/// <param name="criteriaObj"></param>
/// <returns></returns>
private static bool MyInterfaceFilter(Type typeObj, Object criteriaObj)
{
return (typeObj.ToString() == criteriaObj.ToString());
}
}
}