1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.Internal; 6 using System.Collections.Generic; 7 using System.Composition.Hosting.Core; 8 using System.Reflection; 9 10 namespace System.Composition.TypedParts.ActivationFeatures 11 { 12 /// <summary> 13 /// Allows modification of the activators generated for typed parts. 14 /// </summary> 15 internal abstract class ActivationFeature 16 { 17 /// <summary> 18 /// A constant shared for subclass use. 19 /// </summary> 20 protected static readonly CompositionDependency[] NoDependencies = EmptyArray<CompositionDependency>.Value; 21 22 /// <summary> 23 /// Participate in the activator creation process. 24 /// </summary> 25 /// <param name="partType">The part type being activated.</param> 26 /// <param name="activator">The activator body so far.</param> 27 /// <param name="partMetadata">Metadata associated with the part being activated.</param> 28 /// <param name="dependencies">Dependencies returned by a previous call to <see cref="GetDependencies"/>.</param> 29 /// <returns>A new activator body, or the one already provided.</returns> RewriteActivator( TypeInfo partType, CompositeActivator activator, IDictionary<string, object> partMetadata, IEnumerable<CompositionDependency> dependencies)30 public abstract CompositeActivator RewriteActivator( 31 TypeInfo partType, 32 CompositeActivator activator, 33 IDictionary<string, object> partMetadata, 34 IEnumerable<CompositionDependency> dependencies); 35 36 /// <summary> 37 /// Describe the dependencies required by this activation feature. 38 /// </summary> 39 /// <param name="partType">The part type being activated.</param> 40 /// <param name="definitionAccessor">The definition accessor.</param> 41 /// <returns>Dependencies.</returns> GetDependencies(TypeInfo partType, DependencyAccessor definitionAccessor)42 public virtual IEnumerable<CompositionDependency> GetDependencies(TypeInfo partType, DependencyAccessor definitionAccessor) 43 { 44 return NoDependencies; 45 } 46 } 47 } 48