当前位置: 首页>>代码示例>>C#>>正文


C# MemberInfo.GetContractMember方法代码示例

本文整理汇总了C#中System.Reflection.MemberInfo.GetContractMember方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetContractMember方法的具体用法?C# MemberInfo.GetContractMember怎么用?C# MemberInfo.GetContractMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.MemberInfo的用法示例。


在下文中一共展示了MemberInfo.GetContractMember方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetExportContractName

        /// <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);
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:23,代码来源:DefaultConventionContractService.cs

示例2: GetExportTypeIdentity

        /// <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());
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:23,代码来源:ContractServices.cs

示例3: GetImportContractName

        /// <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());
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:24,代码来源:ContractServices.cs

示例4: GetImportTypeIdentity

        /// <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);
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:31,代码来源:ContractServices.cs

示例5: GetImportTypeIdentity

        /// <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));
        }
开发者ID:jbogard,项目名称:MefContrib,代码行数:25,代码来源:ConventionCatalog.cs

示例6: GetImportContractName

        /// <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());
        }
开发者ID:jbogard,项目名称:MefContrib,代码行数:17,代码来源:ConventionCatalog.cs

示例7: GetExportTypeIdentity

        /// <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());
        }
开发者ID:jbogard,项目名称:MefContrib,代码行数:17,代码来源:ConventionCatalog.cs

示例8: GetExportTypeIdentity

        /// <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);
        }
开发者ID:doublekill,项目名称:MefContrib,代码行数:25,代码来源:DefaultConventionContractService.cs


注:本文中的System.Reflection.MemberInfo.GetContractMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。