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
// TODO: ICompositionElement Give this def an origin indicating that it was added directly to the ComposablePartExportProvider.
var mappedType = reflectionContext.MapType(IntrospectionExtensions.GetTypeInfo(attributedPart.GetType()));
if (mappedType.Assembly.ReflectionOnly)
{
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.Argument_ReflectionContextReturnsReflectionOnlyType, "reflectionContext"), "reflectionContext");
}
ReflectionComposablePartDefinition definition = AttributedModelDiscovery.CreatePartDefinition(mappedType, PartCreationPolicyAttribute.Shared, true, (ICompositionElement)null);
return CreatePart(definition, attributedPart);
}