/// <summary>
        /// Gets contract name for the provided <see cref="IExportConvention"/>.
        /// </summary>
        /// <param name="exportConvention">The <see cref="IExportConvention"/> that the contract name should be retreived for.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that is being exported.</param>
        /// <returns>A <see cref="string"/> containing the contract name for the export.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="member"/> or <paramref name="exportConvention"/> parameter was <see langword="null"/>.</exception>
        public override string GetExportContractName(IExportConvention exportConvention, MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member", "The member cannot be null.");
            }

            var contractMember =
                member.GetContractMember();

            var defaultContractName =
                this.DefaultConventions.Where(x => x.TargetType.Equals(contractMember))
                .Select(x => x.ContractName).LastOrDefault();

            return defaultContractName ?? base.GetExportContractName(exportConvention, member);
        }
        /// <summary>
        /// Gets export type identity based on the provided hints.
        /// </summary>
        /// <param name="contractType">The <see cref="Type"/> of the type identity to use for the export.</param>
        /// <param name="member">A <see cref="MemberInfo"/> instance for the member that is being exported.</param>
        /// <returns>A <see cref="string"/> containing the type identity.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="member"/> parameter was <see langword="null"/>.</exception>
        public static string GetExportTypeIdentity(Type contractType, MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member", "The member cannot be null.");
            }

            if (contractType != null)
            {
                return AttributedModelServices.GetTypeIdentity(contractType);
            }

            return member.MemberType.Equals(MemberTypes.Method) ?
                AttributedModelServices.GetTypeIdentity((MethodInfo)member) :
                AttributedModelServices.GetTypeIdentity(member.GetContractMember());
        }
        /// <summary>
        /// Gets the import contract name based on the provided hints.
        /// </summary>
        /// <param name="contractName">A <see cref="string"/> containing the name of the contract to use for the import.</param>
        /// <param name="contractType">The <see cref="Type"/> of the contract to use for the import.</param>
        /// <param name="member">A <see cref="MemberInfo"/> instance for the member that is being imported.</param>
        /// <returns>A <see cref="string"/> containing the contract name.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="member"/> parameter was <see langword="null"/>.</exception>
        public static string GetImportContractName(string contractName, Type contractType, MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member", "The member cannot be null.");
            }

            if (contractName != null)
            {
                return contractName;
            }

            return contractType != null ?
                AttributedModelServices.GetTypeIdentity(contractType) :
                AttributedModelServices.GetTypeIdentity(member.GetContractMember());
        }
        /// <summary>
        /// Gets import type identity based on the provided hints.
        /// </summary>
        /// <param name="contractType">The <see cref="Type"/> of the type identity to use for the import.</param>
        /// <param name="member">A <see cref="MemberInfo"/> instance for the member that is being imported.</param>
        /// <returns>A <see cref="string"/> containing the type identity.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="member"/> parameter was <see langword="null"/>.</exception>
        public static string GetImportTypeIdentity(Type contractType, MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member", "The member cannot be null.");
            }

            if (contractType == null)
            {
                return AttributedModelServices.GetTypeIdentity(member.GetContractMember());
            }

            if (contractType.Equals(typeof(object)))
            {
                return null;
            }

            var memberType =
                member.GetContractMember();

            return memberType.IsSubclassOf(typeof(Delegate)) ?
                AttributedModelServices.GetTypeIdentity(memberType.GetMethod("Invoke")) :
                AttributedModelServices.GetTypeIdentity(contractType);
        }
Example #5
0
        /// <summary>
        /// Gets type identity for the provided <see cref="IImportConvention"/>.
        /// </summary>
        /// <param name="importConvention">The <see cref="IImportConvention"/> that the type identity should be retreived for.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that is being imported.</param>
        /// <returns>A <see cref="string"/> containing the type identity for the imported.</returns>
        private static string GetImportTypeIdentity(IImportConvention importConvention, MemberInfo member)
        {
            if (importConvention.ContractType == null)
            {
                return AttributedModelServices.GetTypeIdentity(member.GetContractMember());
            }

            if (importConvention.ContractType.Invoke(member).Equals(typeof(object)))
            {
                return null;
            }

            var memberType =
                member.GetContractMember();

            return memberType.IsSubclassOf(typeof(Delegate)) ?
                AttributedModelServices.GetTypeIdentity(memberType.GetMethod("Invoke")) :
                AttributedModelServices.GetTypeIdentity(importConvention.ContractType.Invoke(member));
        }
Example #6
0
        /// <summary>
        /// Gets contract name for the provided <see cref="IImportConvention"/>.
        /// </summary>
        /// <param name="importConvention">The <see cref="IImportConvention"/> that the contract name should be retreived for.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that is being imported.</param>
        /// <returns>A <see cref="string"/> containing the contract name for the import.</returns>
        private static string GetImportContractName(IImportConvention importConvention, MemberInfo member)
        {
            if (importConvention.ContractName != null)
            {
                return importConvention.ContractName.Invoke(member);
            }

            return importConvention.ContractType != null ?
                AttributedModelServices.GetTypeIdentity(importConvention.ContractType.Invoke(member)) :
                AttributedModelServices.GetTypeIdentity(member.GetContractMember());
        }
Example #7
0
        /// <summary>
        /// Gets type identity for the provided <see cref="IExportConvention"/>.
        /// </summary>
        /// <param name="exportConvention">The <see cref="IExportConvention"/> that the type identity should be retreived for.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that is being exported.</param>
        /// <returns>A <see cref="string"/> containing the type identity for the export.</returns>
        private static string GetExportTypeIdentity(IExportConvention exportConvention, MemberInfo member)
        {
            if (exportConvention.ContractType != null)
            {
                return AttributedModelServices.GetTypeIdentity(exportConvention.ContractType.Invoke(member));
            }

            return member.MemberType.Equals(MemberTypes.Method) ?
                AttributedModelServices.GetTypeIdentity((MethodInfo)member) :
                AttributedModelServices.GetTypeIdentity(member.GetContractMember());
        }
        /// <summary>
        /// Gets type identity for the provided <see cref="IExportConvention"/>.
        /// </summary>
        /// <param name="exportConvention">The <see cref="IExportConvention"/> that the type identity should be retreived for.</param>
        /// <param name="member">The <see cref="MemberInfo"/> that is being exported.</param>
        /// <returns>A <see cref="string"/> containing the type identity for the export.</returns>
        /// <exception cref="ArgumentNullException">The value of the <paramref name="member"/> or <paramref name="exportConvention"/> parameter was <see langword="null"/>.</exception>
        public override string GetExportTypeIdentity(IExportConvention exportConvention, MemberInfo member)
        {
            if (member == null)
            {
                throw new ArgumentNullException("member", "The member cannot be null.");
            }

            var contractMember =
                member.GetContractMember();

            var defaultContractType =
                this.DefaultConventions.Where(x => x.TargetType.Equals(contractMember))
                .Select(x => x.ContractType).LastOrDefault();

            return defaultContractType != null ? 
                AttributedModelServices.GetTypeIdentity(defaultContractType) : 
                base.GetExportTypeIdentity(exportConvention, member);
        }