/// <summary> /// Checks if the given <see cref="ImportDefinition"/> is based on reflection model. /// </summary> /// <param name="definition">The <see cref="ImportDefinition"/> instance.</param> /// <returns><c>True</c> if the given import definition is based on the /// reflection model. <c>False</c> otherwise.</returns> public static bool IsReflectionImportDefinition(ImportDefinition definition) { if (definition == null) throw new ArgumentNullException("definition"); var name = definition.GetType().Name; return name == "ReflectionMemberImportDefinition" || name == "ReflectionParameterImportDefinition"; }
public static LazyMemberInfo GetImportingMember(ImportDefinition importDefinition) { Requires.NotNull(importDefinition, "importDefinition"); ReflectionMemberImportDefinition reflectionMemberImportDefinition = importDefinition as ReflectionMemberImportDefinition; if (reflectionMemberImportDefinition == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Strings.ReflectionModel_InvalidMemberImportDefinition, importDefinition.GetType()), "importDefinition"); } return reflectionMemberImportDefinition.ImportingLazyMember; }
public static bool IsPartCreatorImportDefinition(ImportDefinition importDefinition) { Requires.NotNull(importDefinition, "importDefinition"); ReflectionImportDefinition reflectionImportDefinition = importDefinition as ReflectionImportDefinition; if (reflectionImportDefinition == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Strings.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()), "importDefinition"); } return (importDefinition is IPartCreatorImportDefinition); }
public static ContractBasedImportDefinition GetPartCreatorProductImportDefinition(ImportDefinition importDefinition) { Requires.NotNull(importDefinition, "importDefinition"); IPartCreatorImportDefinition partCreatorImportDefinition = importDefinition as IPartCreatorImportDefinition; if (partCreatorImportDefinition == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Strings.ReflectionModel_InvalidImportDefinition, importDefinition.GetType()), "importDefinition"); } return partCreatorImportDefinition.ProductImportDefinition; }
public static bool IsReflectionMemberImportDefinition(ImportDefinition definition) { return definition.GetType().Name.Equals("ReflectionMemberImportDefinition"); }
public static Lazy<ParameterInfo> GetImportingParameter(ImportDefinition importDefinition) { Requires.NotNull(importDefinition, "importDefinition"); Contract.Ensures(Contract.Result<Lazy<ParameterInfo>>() != null); ReflectionParameterImportDefinition reflectionParameterImportDefinition = importDefinition as ReflectionParameterImportDefinition; if (reflectionParameterImportDefinition == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, Strings.ReflectionModel_InvalidParameterImportDefinition, importDefinition.GetType()), "importDefinition"); } return reflectionParameterImportDefinition.ImportingLazyParameter; }