コード例 #1
0
        /// <summary>
        /// Initialize a new instance of the <see cref="ParameterDescriptor"/> class.
        /// </summary>
        /// <param name="methodDescriptor">The parent <see cref="MethodDescriptor"/>.</param>
        /// <param name="parameterInfo">The <see cref="ParameterInfo"/> to wrap.</param>
        internal ParameterDescriptor(MethodDescriptor methodDescriptor, ParameterInfo parameterInfo)
            : base(parameterInfo.ParameterType, parameterInfo.Name)
        {
            if (parameterInfo.IsOutParam())
            {
                var memberInfo = parameterInfo.Member;
                var declaringType = memberInfo.DeclaringType;
                throw new ArgumentException(string.Format("Cannot apply rules to an 'out' parameter. Type = '{0}'. Method = '{1}'. Parameter = '{2}'", declaringType.ToUserFriendlyString(), memberInfo.Name, parameterInfo.Name), "parameterInfo");
            }
            Position = parameterInfo.Position;
            Method = methodDescriptor;
			AddRulesForParameterInfo(parameterInfo);
        }