示例#1
0
            public DryIocResolution(Container container, PluginsConfiguration configuration)
            {
                this.Container = container.OpenScope();
                var assemblies = new List <Assembly>();

                try
                {
                    foreach (var directory in configuration.Directories)
                    {
                        foreach (var f in Directory.GetFiles(directory, "*Plugin*.dll", SearchOption.AllDirectories))
                        {
                            assemblies.Add(Assembly.LoadFrom(f));
                        }
                    }
                }
                catch (System.Reflection.ReflectionTypeLoadException ex)
                {
                    var firstFive = string.Join(Environment.NewLine, ex.LoaderExceptions.Take(5).Select(it => it.Message));
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    System.Diagnostics.Debug.WriteLine(firstFive);
                    throw new FrameworkException("Error loading plugins. Can't load plugins. {0}".With(firstFive), ex);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                    throw new FrameworkException("Error loading plugins.", ex);
                }
                AttributedModel.DefaultSetup(this.Container);
                this.Container.RegisterExports(assemblies.ToArray());
            }
示例#2
0
 public DryIocMefProvider(
     PluginsConfiguration configuration,
     IMixinProvider mixinProvider,
     Container container)
     : base(mixinProvider, new DryIocResolution(container, configuration))
 {
 }
示例#3
0
 public AutofacMefProvider(
     PluginsConfiguration configuration,
     IMixinProvider mixinProvider,
     ILifetimeScope container)
     : base(mixinProvider, new AutofacResolution(container, configuration))
 {
 }
示例#4
0
 public AutofacResolution(ILifetimeScope container, PluginsConfiguration configuration)
 {
     this.Container = container.BeginLifetimeScope(builder =>
     {
         try
         {
             if (configuration.Directories != null)
             {
                 foreach (var directory in configuration.Directories)
                 {
                     if (directory != null)
                     {
                         builder.RegisterComposablePartCatalog(new DirectoryCatalog(directory));
                     }
                 }
             }
             if (configuration.Assemblies != null)
             {
                 foreach (var asm in configuration.Assemblies)
                 {
                     if (asm != null)
                     {
                         builder.RegisterComposablePartCatalog(new AssemblyCatalog(asm));
                     }
                 }
             }
         }
         catch (System.Reflection.ReflectionTypeLoadException ex)
         {
             var firstFive = string.Join(Environment.NewLine, ex.LoaderExceptions.Take(5).Select(it => it.Message));
             System.Diagnostics.Debug.WriteLine(ex.ToString());
             System.Diagnostics.Debug.WriteLine(firstFive);
             throw new FrameworkException("Error loading plugins. Can't load plugins. {0}".With(firstFive), ex);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.ToString());
             throw new FrameworkException("Error loading plugins.", ex);
         }
     });
 }