コード例 #1
0
        public static ComposablePart CreatePart(object attributedPart, ReflectionContext reflectionContext)
        {
            Requires.NotNull(attributedPart, nameof(attributedPart));
            Requires.NotNull(reflectionContext, nameof(reflectionContext));

            return(AttributedModelDiscovery.CreatePart(attributedPart, reflectionContext));
        }
コード例 #2
0
        public static ComposablePart CreatePart(object attributedPart)
        {
            Requires.NotNull(attributedPart, nameof(attributedPart));
            Contract.Ensures(Contract.Result <ComposablePart>() != null);

            return(AttributedModelDiscovery.CreatePart(attributedPart));
        }
コード例 #3
0
        public static ComposablePart CreatePart(object attributedPart, ReflectionContext reflectionContext)
        {
            Requires.NotNull(attributedPart, "attributedPart");
            Requires.NotNull(reflectionContext, "reflectionContext");
            Contract.Ensures(Contract.Result <ComposablePart>() != null);

            return(AttributedModelDiscovery.CreatePart(attributedPart, reflectionContext));
        }
コード例 #4
0
 public static IEnumerable <Type> GetAttributedTypes()
 {
     foreach (Type type in typeof(Expectations).Assembly.GetTypes())
     {
         var definition = AttributedModelDiscovery.CreatePartDefinitionIfDiscoverable(type, (ICompositionElement)null);
         if (definition != null)
         {
             yield return(type);
         }
     }
 }
コード例 #5
0
 public static ComposablePartDefinition CreatePartDefinition(Type type, ICompositionElement?origin, bool ensureIsDiscoverable)
 {
     Requires.NotNull(type, nameof(type));
     if (ensureIsDiscoverable)
     {
         return(AttributedModelDiscovery.CreatePartDefinitionIfDiscoverable(type, origin) !);
     }
     else
     {
         return(AttributedModelDiscovery.CreatePartDefinition(type, null, false, origin));
     }
 }
コード例 #6
0
        public static ComposablePart CreatePart(ComposablePartDefinition partDefinition, object attributedPart)
        {
            Requires.NotNull(partDefinition, nameof(partDefinition));
            Requires.NotNull(attributedPart, nameof(attributedPart));

            var reflectionComposablePartDefinition = partDefinition as ReflectionComposablePartDefinition;

            if (reflectionComposablePartDefinition == null)
            {
                throw ExceptionBuilder.CreateReflectionModelInvalidPartDefinition(nameof(partDefinition), partDefinition.GetType());
            }

            return(AttributedModelDiscovery.CreatePart(reflectionComposablePartDefinition, attributedPart));
        }
コード例 #7
0
ファイル: AttributedModelServices.cs プロジェクト: zqb971/mef
        public static ComposablePart CreatePart(ComposablePartDefinition partDefinition, object attributedPart)
        {
            Requires.NotNull(partDefinition, "partDefinition");
            Requires.NotNull(attributedPart, "attributedPart");
            Contract.Ensures(Contract.Result <ComposablePart>() != null);

            var reflectionComposablePartDefinition = partDefinition as ReflectionComposablePartDefinition;

            if (reflectionComposablePartDefinition == null)
            {
                throw ExceptionBuilder.CreateReflectionModelInvalidPartDefinition("partDefinition", partDefinition.GetType());
            }

            return(AttributedModelDiscovery.CreatePart(reflectionComposablePartDefinition, attributedPart));
        }
コード例 #8
0
 public static ReflectionComposablePartDefinition CreateAttributed(Type type)
 {
     return(AttributedModelDiscovery.CreatePartDefinition(type, null, false, (ICompositionElement)null));
 }
コード例 #9
0
        public static ComposablePart CreatePart(object attributedPart)
        {
            Requires.NotNull(attributedPart, nameof(attributedPart));

            return(AttributedModelDiscovery.CreatePart(attributedPart));
        }