internal CompositionError(CompositionErrorId id, string?description, ICompositionElement?element, Exception?exception) { _id = id; _description = description ?? string.Empty; _element = element; _exception = exception; }
public static ContractBasedImportDefinition CreateImportDefinition( LazyMemberInfo importingMember, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, bool isRecomposable, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, bool isExportFactory, ICompositionElement?origin) { return(CreateImportDefinition( importingMember, contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, false, requiredCreationPolicy, metadata, isExportFactory, origin)); }
public ReflectionMemberExportDefinition(LazyMemberInfo member, ExportDefinition exportDefinition, ICompositionElement?origin) { ArgumentNullException.ThrowIfNull(exportDefinition); _member = member; _exportDefinition = exportDefinition; _origin = origin; }
public ApplicationCatalog(ReflectionContext reflectionContext, ICompositionElement definitionOrigin) { Requires.NotNull(reflectionContext, nameof(reflectionContext)); Requires.NotNull(definitionOrigin, nameof(definitionOrigin)); _reflectionContext = reflectionContext; _definitionOrigin = definitionOrigin; }
/// <summary> /// Creates a catalog of <see cref="ComposablePartDefinition"/>s based on all the *.dll files /// in the given directory path. /// /// Possible exceptions that can be thrown are any that <see cref="Directory.GetFiles(string, string)"/> or /// <see cref="Assembly.Load(AssemblyName)"/> can throw. /// </summary> /// <param name="path"> /// Path to the directory to scan for assemblies to add to the catalog. /// The path needs to be absolute or relative to <see cref="AppDomain.BaseDirectory"/> /// </param> /// <param name="searchPattern"> /// Any valid searchPattern that <see cref="Directory.GetFiles(string, string)"/> will accept. /// </param> /// <exception cref="ArgumentException"> /// If <paramref name="path"/> is a zero-length string, contains only white space, or /// contains one or more implementation-specific invalid characters. Or <paramref name="searchPattern"/> /// does not contain a valid pattern. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="path"/> is <see langword="null"/>. /// </exception> /// <exception cref="DirectoryNotFoundException"> /// The specified <paramref name="path"/> is invalid (for example, it is on an unmapped drive). /// </exception> /// <exception cref="PathTooLongException"> /// The specified <paramref name="path"/>, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters and file names must /// be less than 260 characters. /// </exception> /// <exception cref="UnauthorizedAccessException"> /// The caller does not have the required permission. /// </exception> public DirectoryCatalog(string path, string searchPattern) { Requires.NotNullOrEmpty(path, nameof(path)); Requires.NotNullOrEmpty(searchPattern, nameof(searchPattern)); _definitionOrigin = this; Initialize(path, searchPattern); }
public AttributedPartCreationInfo(Type type, PartCreationPolicyAttribute?partCreationPolicy, bool ignoreConstructorImports, ICompositionElement?origin) { ArgumentNullException.ThrowIfNull(type); _type = type; _ignoreConstructorImports = ignoreConstructorImports; _partCreationPolicy = partCreationPolicy; _origin = origin; }
/// <summary> /// Creates a catalog of <see cref="ComposablePartDefinition"/>s based on all the *.dll files /// in the given directory path. /// /// Possible exceptions that can be thrown are any that <see cref="Directory.GetFiles(string, string)"/> or /// <see cref="Assembly.Load(AssemblyName)"/> can throw. /// </summary> /// <param name="path"> /// Path to the directory to scan for assemblies to add to the catalog. /// The path needs to be absolute or relative to <see cref="AppDomain.BaseDirectory"/> /// </param> /// <param name="definitionOrigin"> /// The <see cref="ICompositionElement"/> CompositionElement used by Diagnostics to identify the source for parts. /// </param> /// <exception cref="ArgumentException"> /// If <paramref name="path"/> is a zero-length string, contains only white space, or /// contains one or more implementation-specific invalid characters. Or <paramref name="searchPattern"/> /// does not contain a valid pattern. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="path"/> is <see langword="null"/>. /// <paramref name="definitionOrigin"/> is <see langword="null"/>. /// </exception> /// <exception cref="DirectoryNotFoundException"> /// The specified <paramref name="path"/> is invalid (for example, it is on an unmapped drive). /// </exception> /// <exception cref="PathTooLongException"> /// The specified <paramref name="path"/>, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters and file names must /// be less than 260 characters. /// </exception> /// <exception cref="UnauthorizedAccessException"> /// The caller does not have the required permission. /// </exception> public DirectoryCatalog(string path, string searchPattern, ICompositionElement definitionOrigin) { Requires.NotNullOrEmpty(path, nameof(path)); Requires.NotNullOrEmpty(searchPattern, nameof(searchPattern)); Requires.NotNull(definitionOrigin, nameof(definitionOrigin)); _definitionOrigin = definitionOrigin; Initialize(path, searchPattern); }
/// <summary> /// Creates a catalog of <see cref="ComposablePartDefinition"/>s based on all the given searchPattern /// over the files in the given directory path. /// /// Possible exceptions that can be thrown are any that <see cref="Directory.GetFiles(string, string)"/> or /// <see cref="Assembly.Load(AssemblyName)"/> can throw. /// </summary> /// <param name="path"> /// Path to the directory to scan for assemblies to add to the catalog. /// The path needs to be absolute or relative to <see cref="AppDomain.BaseDirectory"/> /// </param> /// <param name="searchPattern"> /// Any valid searchPattern that <see cref="Directory.GetFiles(string, string)"/> will accept. /// </param> /// <param name="reflectionContext"> /// The <see cref="ReflectionContext"/> a context used by the catalog when /// interpreting the types to inject attributes into the type definition. /// </param> /// <exception cref="ArgumentException"> /// If <paramref name="path"/> is a zero-length string, contains only white space, or /// contains one or more implementation-specific invalid characters. Or <paramref name="searchPattern"/> /// does not contain a valid pattern. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="path"/> is <see langword="null"/> /// or <paramref name="searchPattern"/> is <see langword="null"/>. /// or <paramref name="reflectionContext"/> is <see langword="null"/>. /// </exception> /// <exception cref="DirectoryNotFoundException"> /// The specified <paramref name="path"/> is invalid (for example, it is on an unmapped drive). /// </exception> /// <exception cref="PathTooLongException"> /// The specified <paramref name="path"/>, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters and file names must /// be less than 260 characters. /// </exception> /// <exception cref="UnauthorizedAccessException"> /// The caller does not have the required permission. /// </exception> public DirectoryCatalog(string path, string searchPattern, ReflectionContext reflectionContext) { Requires.NotNullOrEmpty(path, nameof(path)); Requires.NotNullOrEmpty(searchPattern, nameof(searchPattern)); Requires.NotNull(reflectionContext, nameof(reflectionContext)); _reflectionContext = reflectionContext; _definitionOrigin = this; Initialize(path, searchPattern); }
public ReflectionMemberExportDefinition(LazyMemberInfo member, ExportDefinition exportDefinition, ICompositionElement?origin) { if (exportDefinition == null) { throw new ArgumentNullException(nameof(exportDefinition)); } _member = member; _exportDefinition = exportDefinition; _origin = origin; }
public PartCreatorMemberImportDefinition( LazyMemberInfo importingLazyMember, ICompositionElement?origin, ContractBasedImportDefinition productImportDefinition) : base(importingLazyMember, CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity, productImportDefinition.RequiredMetadata, productImportDefinition.Cardinality, productImportDefinition.IsRecomposable, false, productImportDefinition.RequiredCreationPolicy, MetadataServices.EmptyMetadata, origin) { ArgumentNullException.ThrowIfNull(productImportDefinition); _productImportDefinition = productImportDefinition; }
public static ContractBasedImportDefinition CreateImportDefinition( Lazy <ParameterInfo> parameter, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, CreationPolicy requiredCreationPolicy, ICompositionElement?origin) { return(CreateImportDefinition(parameter, contractName, requiredTypeIdentity, requiredMetadata, cardinality, requiredCreationPolicy, MetadataServices.EmptyMetadata, false, origin)); }
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)); } }
public static ICompositionElement?FromICompositionElement(ICompositionElement?element) { if (element == null) { return(null); } ICompositionElement?origin = FromICompositionElement(element.Origin); // Otherwise, we need to create a serializable wrapper return(new SerializableCompositionElement(element.DisplayName, origin)); }
public AttributedPartCreationInfo(Type type, PartCreationPolicyAttribute?partCreationPolicy, bool ignoreConstructorImports, ICompositionElement?origin) { if (type == null) { throw new ArgumentNullException(nameof(type)); } _type = type; _ignoreConstructorImports = ignoreConstructorImports; _partCreationPolicy = partCreationPolicy; _origin = origin; }
public PartCreatorParameterImportDefinition( Lazy <ParameterInfo> importingLazyParameter, ICompositionElement?origin, ContractBasedImportDefinition productImportDefinition) : base(importingLazyParameter, CompositionConstants.PartCreatorContractName, CompositionConstants.PartCreatorTypeIdentity, productImportDefinition.RequiredMetadata, productImportDefinition.Cardinality, CreationPolicy.Any, MetadataServices.EmptyMetadata, origin) { if (productImportDefinition == null) { throw new ArgumentNullException(nameof(productImportDefinition)); } _productImportDefinition = productImportDefinition; }
public ReflectionImportDefinition( string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, bool isRecomposable, bool isPrerequisite, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, ICompositionElement?origin) : base(contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, isPrerequisite, requiredCreationPolicy, metadata) { _origin = origin; }
public static ExportDefinition CreateExportDefinition( LazyMemberInfo exportingMember, string contractName, Lazy <IDictionary <string, object?> > metadata, ICompositionElement?origin) { Requires.NotNullOrEmpty(contractName, nameof(contractName)); Requires.IsInMembertypeSet(exportingMember.MemberType, nameof(exportingMember), MemberTypes.Field | MemberTypes.Property | MemberTypes.NestedType | MemberTypes.TypeInfo | MemberTypes.Method); return(new ReflectionMemberExportDefinition( exportingMember, new LazyExportDefinition(contractName, metadata), origin)); }
public ReflectionParameterImportDefinition( Lazy <ParameterInfo> importingLazyParameter, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, ICompositionElement?origin) : base(contractName, requiredTypeIdentity, requiredMetadata, cardinality, false, true, requiredCreationPolicy, metadata, origin) { ArgumentNullException.ThrowIfNull(importingLazyParameter); _importingLazyParameter = importingLazyParameter; }
public ReflectionMemberImportDefinition( LazyMemberInfo importingLazyMember, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, bool isRecomposable, bool isPrerequisite, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, ICompositionElement?origin) : base(contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, isPrerequisite, requiredCreationPolicy, metadata, origin) { ArgumentNullException.ThrowIfNull(contractName); _importingLazyMember = importingLazyMember; }
public static ContractBasedImportDefinition CreateImportDefinition( LazyMemberInfo importingMember, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, bool isRecomposable, bool isPreRequisite, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, bool isExportFactory, ICompositionElement?origin) { Requires.NotNullOrEmpty(contractName, nameof(contractName)); Requires.IsInMembertypeSet(importingMember.MemberType, nameof(importingMember), MemberTypes.Property | MemberTypes.Field); if (isExportFactory) { return(new PartCreatorMemberImportDefinition( importingMember, origin, new ContractBasedImportDefinition( contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, isPreRequisite, CreationPolicy.NonShared, metadata))); } else { return(new ReflectionMemberImportDefinition( importingMember, contractName, requiredTypeIdentity, requiredMetadata, cardinality, isRecomposable, isPreRequisite, requiredCreationPolicy, metadata, origin)); } }
public ReflectionPartCreationInfo( Lazy <Type> partType, bool isDisposalRequired, Lazy <IEnumerable <ImportDefinition> >?imports, Lazy <IEnumerable <ExportDefinition> >?exports, Lazy <IDictionary <string, object?> >?metadata, ICompositionElement?origin) { ArgumentNullException.ThrowIfNull(partType); _partType = partType; _isDisposalRequired = isDisposalRequired; _imports = imports; _exports = exports; _metadata = metadata; _origin = origin; }
public static ComposablePartDefinition CreatePartDefinition( Lazy <Type> partType, bool isDisposalRequired, Lazy <IEnumerable <ImportDefinition> >?imports, Lazy <IEnumerable <ExportDefinition> >?exports, Lazy <IDictionary <string, object?> >?metadata, ICompositionElement?origin) { Requires.NotNull(partType, nameof(partType)); return(new ReflectionComposablePartDefinition( new ReflectionPartCreationInfo( partType, isDisposalRequired, imports, exports, metadata, origin))); }
public static ContractBasedImportDefinition CreateImportDefinition( Lazy <ParameterInfo> parameter, string contractName, string?requiredTypeIdentity, IEnumerable <KeyValuePair <string, Type> >?requiredMetadata, ImportCardinality cardinality, CreationPolicy requiredCreationPolicy, IDictionary <string, object?> metadata, bool isExportFactory, ICompositionElement?origin) { Requires.NotNull(parameter, nameof(parameter)); Requires.NotNullOrEmpty(contractName, nameof(contractName)); if (isExportFactory) { return(new PartCreatorParameterImportDefinition( parameter, origin, new ContractBasedImportDefinition( contractName, requiredTypeIdentity, requiredMetadata, cardinality, false, true, CreationPolicy.NonShared, metadata))); } else { return(new ReflectionParameterImportDefinition( parameter, contractName, requiredTypeIdentity, requiredMetadata, cardinality, requiredCreationPolicy, metadata, origin)); } }
/// <summary> /// Initializes a new instance of the <see cref="CompositionError"/> class /// with the specified error message, and composition element and exception that /// is the cause of the composition error. /// </summary> /// <param name="message"> /// A <see cref="string"/> containing a message that describes the /// <see cref="CompositionError"/>; or <see langword="null"/> to set the /// <see cref="Description"/> property to an empty string (""). /// </param> /// <param name="element"> /// The <see cref="ICompositionElement"/> that is the cause of the /// <see cref="CompositionError"/>; or <see langword="null"/> to set /// the <see cref="CompositionError.Element"/> property to /// <see langword="null"/>. /// </param> /// <param name="exception"> /// The <see cref="Exception"/> that is the underlying cause of the /// <see cref="CompositionError"/>; or <see langword="null"/> to set /// the <see cref="CompositionError.Exception"/> property to <see langword="null"/>. /// </param> public CompositionError(string?message, ICompositionElement?element, Exception?exception) : this(CompositionErrorId.Unknown, message, element, exception) { }
public SerializableCompositionElement(string displayName, ICompositionElement?origin) { _displayName = displayName; _origin = origin; }
public CompositionElement(string?displayName, ICompositionElement?origin) { _displayName = displayName ?? string.Empty; _origin = origin; }
public static ComposablePartDefinition?CreatePartDefinitionIfDiscoverable(Type type, ICompositionElement?origin) { AttributedPartCreationInfo creationInfo = new AttributedPartCreationInfo(type, null, false, origin); if (!creationInfo.IsPartDiscoverable()) { return(null); } return(new ReflectionComposablePartDefinition(creationInfo)); }
public ApplicationCatalog(ICompositionElement definitionOrigin) { Requires.NotNull(definitionOrigin, nameof(definitionOrigin)); _definitionOrigin = definitionOrigin; }
public static ReflectionComposablePartDefinition CreatePartDefinition(Type type, PartCreationPolicyAttribute?partCreationPolicy, bool ignoreConstructorImports, ICompositionElement?origin) { ArgumentNullException.ThrowIfNull(type); AttributedPartCreationInfo creationInfo = new AttributedPartCreationInfo(type, partCreationPolicy, ignoreConstructorImports, origin); return(new ReflectionComposablePartDefinition(creationInfo)); }
public static ComposablePartDefinition CreatePartDefinition(Type type, ICompositionElement?origin) { Requires.NotNull(type, nameof(type)); return(AttributedModelServices.CreatePartDefinition(type, origin, false)); }