private ReflectionComposablePartDefinition CreateDefinition(Type type) { var definition = AttributedModelDiscovery.CreatePartDefinition(type, null, false, ElementFactory.Create()); Assert.Equal(type, definition.GetPartType()); return(definition); }
public static ReflectionComposablePart CreatePart(object attributedPart) { Assumes.NotNull(attributedPart); // If given an instance then we want to pass the default composition options because we treat it as a shared part ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(attributedPart.GetType(), PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null); return(new ReflectionComposablePart(definition, attributedPart)); }
public static ReflectionComposablePart CreatePart(object attributedPart) { Assumes.NotNull(attributedPart); // If given an instance then we want to pass the default composition options because we treat it as a shared part // TODO: ICompositionElement Give this def an origin indicating that it was added directly to the MutableExportProvider. ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(attributedPart.GetType(), PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null); return(new ReflectionComposablePart(definition, attributedPart)); }
public static ReflectionComposablePart CreatePart(object attributedPart, ReflectionContext reflectionContext) { Assumes.NotNull(attributedPart); Assumes.NotNull(reflectionContext); // If given an instance then we want to pass the default composition options because we treat it as a shared part var mappedType = reflectionContext.MapType(IntrospectionExtensions.GetTypeInfo(attributedPart.GetType())); if (mappedType.Assembly.ReflectionOnly) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.Argument_ReflectionContextReturnsReflectionOnlyType, nameof(reflectionContext)), nameof(reflectionContext)); } ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(mappedType, PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null); return(CreatePart(definition, attributedPart)); }