43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace Module.NavigationTool.Editor.Toolbar
|
|
{
|
|
internal static class ToolbarSettingsUtility
|
|
{
|
|
public static IToolbarSettings[] GetAllSettings()
|
|
{
|
|
var list = new List<IToolbarSettings>(8);
|
|
|
|
try
|
|
{
|
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
|
Type iType = typeof(IToolbarSettings);
|
|
|
|
for (var i = 0; i < assemblies.Length; i++)
|
|
{
|
|
Assembly assembly = assemblies[i];
|
|
Type[] types = assembly.GetTypes();
|
|
|
|
for (var j = 0; j < types.Length; j++)
|
|
{
|
|
Type type = types[j];
|
|
|
|
if (!type.IsInterface && !type.IsAbstract && iType.IsAssignableFrom(type))
|
|
list.Add((IToolbarSettings)FormatterServices.GetUninitializedObject(type));
|
|
}
|
|
}
|
|
|
|
list.Sort((s0, s1) => string.Compare(s0.Title, s1.Title, StringComparison.Ordinal));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// Fail silently
|
|
}
|
|
|
|
return list.ToArray();
|
|
}
|
|
}
|
|
} |