/// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="parameter"></param>
 /// <param name="importDescription"></param>
 /// <param name="creationPolicy"></param>
 public ProviderParameterImportDefinition(System.Reflection.ParameterInfo parameter, ImportDescription importDescription, System.ComponentModel.Composition.CreationPolicy creationPolicy) : base(CompositionServices.GetContractNameFromImportDescription(parameter, importDescription), CompositionServices.GetTypeIdentityFromImportDescription(parameter, importDescription), CompositionServices.GetMetadataFromImportDescription(parameter, importDescription), System.ComponentModel.Composition.Primitives.ImportCardinality.ExactlyOne, importDescription.Recomposable, importDescription.Prerequisite, creationPolicy)
 {
     parameter.Require("parameter").NotNull();
     importDescription.Require("importDescription").NotNull();
     this.AllowDefault = importDescription.AllowDefault;
     this.Parameter    = parameter;
 }
Пример #2
0
        /// <summary>
        /// Recupera o nome do contrato do <see cref="MemberInfo"/> e <see cref="ImportDescription"/>.
        /// </summary>
        /// <param name="member">Informações do membro.</param>
        /// <param name="importDescription">Informações sobre a definição do import.</param>
        /// <returns>Nome do contrato.</returns>
        public static string GetContractNameFromImportDescription(Lazy <MemberInfo> member, ImportDescription importDescription)
        {
            member.Require("member").NotNull();
            importDescription.Require("importDescription").NotNull();
            if (!string.IsNullOrEmpty(importDescription.ContractName))
            {
                return(importDescription.ContractName);
            }
            if (importDescription.ContractType != null)
            {
                return(AttributedModelServices.GetContractName(importDescription.ContractType));
            }
            var memberValue = member.Value;

            if (memberValue == null)
            {
                throw new InvalidOperationException("member is null");
            }
            if (memberValue.MemberType == MemberTypes.Method)
            {
                return(AttributedModelServices.GetTypeIdentity((MethodInfo)memberValue));
            }
            else if (memberValue.MemberType == MemberTypes.Constructor)
            {
                return(AttributedModelServices.GetContractName(memberValue.GetDefaultTypeFromMember()));
            }
            return(AttributedModelServices.GetContractName(memberValue.GetDefaultTypeFromMember()));
        }
Пример #3
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="member"></param>
 /// <param name="importDescription"></param>
 /// <param name="creationPolicy">Política de criação.</param>
 public ProviderImportDefinition(Lazy <MemberInfo> member, ImportDescription importDescription, System.ComponentModel.Composition.CreationPolicy creationPolicy) : base(CompositionServices.GetContractNameFromImportDescription(member, importDescription), CompositionServices.GetTypeIdentityFromImportDescription(member, importDescription), CompositionServices.GetMetadataFromImportDescription(member, importDescription), GetCardinality(member, importDescription.AllowDefault), importDescription.Recomposable, importDescription.Prerequisite, creationPolicy)
 {
     member.Require("member").NotNull();
     importDescription.Require("importDescription").NotNull();
     this.AllowDefault = importDescription.AllowDefault;
     _member           = member;
 }
Пример #4
0
        /// <summary>
        /// Recupera os metadados de um descrição de import.
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="importDescription"></param>
        /// <returns></returns>
        public static IEnumerable <KeyValuePair <string, Type> > GetMetadataFromImportDescription(this ParameterInfo parameter, ImportDescription importDescription)
        {
            parameter.Require("parameter").NotNull();
            importDescription.Require("importDescription").NotNull();
            var metadata = new Dictionary <string, Type>();

            return(metadata);
        }
Пример #5
0
 /// <summary>
 /// Recupera o nome do contrato do <see cref="ParameterInfo"/> e <see cref="ExportDescription"/>
 /// </summary>
 /// <param name="member">Informações sobre o membro.</param>
 /// <param name="importDescription">Informações sobre a definição de export.</param>
 /// <returns>Nome do contrato.</returns>
 public static string GetContractNameFromImportDescription(ParameterInfo member, ImportDescription importDescription)
 {
     member.Require("member").NotNull();
     importDescription.Require("importDescription").NotNull();
     if (!string.IsNullOrEmpty(importDescription.ContractName))
     {
         return(importDescription.ContractName);
     }
     if (importDescription.ContractType != null)
     {
         return(AttributedModelServices.GetContractName(importDescription.ContractType));
     }
     return(AttributedModelServices.GetContractName(member.ParameterType));
 }