示例#1
0
        internal ParameterData(ParameterDefinition underlyingParameter, MemberDataBase declaringMember)
        {
            var modifer         = ParameterModifier.None;
            var parameterType   = underlyingParameter.ParameterType;
            var byReferenceType = parameterType as ByReferenceType;

            if (byReferenceType != null)
            {
                modifer       = underlyingParameter.IsOut ? ParameterModifier.Out : ParameterModifier.Ref;
                parameterType = byReferenceType.ElementType;
            }

            this.DeclaringMemberKind = declaringMember.MetadataItemKind;
            this.Modifer             = modifer;
            this.Name = underlyingParameter.Name;
            this.Type = TypeData.FromType(parameterType);

            if (underlyingParameter.IsOptional)
            {
                _flags           |= InternalFlags.IsOptional;
                this.DefaultValue = Utilities.PreprocessConstantValue(parameterType, underlyingParameter.GetDefualtValue());
            }

            if (underlyingParameter.CustomAttributes.Any(c => c.AttributeType.EqualsType(typeof(ParamArrayAttribute))))
            {
                _flags |= InternalFlags.IsParamsArray;
            }

            if (underlyingParameter.IsDynamicType())
            {
                _flags |= InternalFlags.IsTypeDynamic;
            }
        }