private void Scan(Assembly asm, IEnumerable <Type> types, IExtensionAttachmentStrategy strategy)
 {
     foreach (var type in types)
     {
         var ctx = new ExtensionAttachmentContext(ServiceContainer, this, asm, type);
         foreach (var attr in CustomAttributeData.GetCustomAttributes(type))
         {
             strategy.Attach(ctx, attr);
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Load assemblies for reflection only by its file names and scans.
        /// </summary>
        public static void ReflectionOnlyFromScan(
            [NotNull] this IExtensionManager manager,
            IExtensionAttachmentStrategy strategy,
            params string[] asmFiles)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            using (ReflectionResolverScope())
                manager.Scan(
                    strategy,
                    asmFiles.Select(Assembly.ReflectionOnlyLoadFrom).ToArray());
        }
 /// <summary>
 /// Scan specific type.
 /// </summary>
 public void Scan(
     [NotNull] IExtensionAttachmentStrategy strategy,
     [NotNull] params Type[] types)
 {
     if (strategy == null)
     {
         throw new ArgumentNullException(nameof(strategy));
     }
     if (types == null)
     {
         throw new ArgumentNullException(nameof(types));
     }
     foreach (var group in types.GroupBy(t => t.Assembly))
     {
         Scan(group.Key, group, strategy);
     }
 }
        /// <summary>
        /// Сканирует сборку.
        /// </summary>
        public void Scan(IExtensionAttachmentStrategy strategy, [NotNull] params Assembly[] assemblies)
        {
            if (strategy == null)
            {
                throw new ArgumentNullException(nameof(strategy));
            }
            if (assemblies == null)
            {
                throw new ArgumentNullException(nameof(assemblies));
            }

            foreach (var asm in assemblies)
            {
                var ctx = new ExtensionAttachmentContext(ServiceContainer, this, asm);
                foreach (var attr in CustomAttributeData.GetCustomAttributes(asm))
                {
                    strategy.Attach(ctx, attr);
                }
                Scan(asm, asm.GetTypes(), strategy);
            }
        }