Ejemplo n.º 1
0
 public static void LoadPluginsFolder(string pluginsFolder)
 {
     if (!Directory.Exists(pluginsFolder))
     {
         Directory.CreateDirectory(pluginsFolder);
     }
     foreach (var plugin in Directory.GetFiles(pluginsFolder, "*.dll"))
     {
         var assembly = Assembly.LoadFrom(plugin);
         assembly = AppDomain.CurrentDomain.Load(assembly.GetName());
         InvertApplication.CachedAssembly(assembly);
     }
 }
Ejemplo n.º 2
0
        public static IEnumerable <Type> GetDerivedTypes <T>(bool includeAbstract = false, bool includeBase = true)
        {
            var type = typeof(T);

            if (includeBase)
            {
                yield return(type);
            }
            if (includeAbstract)
            {
                foreach (var assembly in CachedAssemblies)
                {
                    //if (!assembly.FullName.StartsWith("Invert")) continue;
                    foreach (var t in assembly
                             .GetTypes()
                             .Where(x => type.IsAssignableFrom(x)))
                    {
                        yield return(t);
                    }
                }
            }
            else
            {
                var items = new List <Type>();
                foreach (var assembly in CachedAssemblies)
                {
                    //if (!assembly.FullName.StartsWith("Invert")) continue;
                    try
                    {
                        foreach (var t in assembly
                                 .GetTypes()
                                 .Where(x => type.IsAssignableFrom(x) && !x.IsAbstract))
                        {
                            items.Add(t);
                        }
                    }
                    catch (Exception ex)
                    {
                        InvertApplication.Log(ex.Message);
                    }
                }
                foreach (var item in items)
                {
                    yield return(item);
                }
            }
        }
Ejemplo n.º 3
0
 public void Execute <TCommand>(TCommand command) where TCommand :  ICommand
 {
     InvertApplication.Execute(command);
 }