Exemple #1
0
		private static bool MatchParameterTypes(ParameterInfo[] parameters, Type[] types)
		{
			if (parameters.Length == types.Length)
			{
				for (int i = 0; i < parameters.Length; i++)
				{
					if (!parameters[i].ParameterType.Equals(types[i]))
					{
						return false;
					}
				}
				return true;
			}
			return false;
		}
Exemple #2
0
		public ParameterInfo[] GetIndexParameters()
		{
			ParameterInfo[] parameters = new ParameterInfo[this.PropertySignature.ParameterCount];
			for (int i = 0; i < parameters.Length; i++)
			{
				parameters[i] = new ParameterInfoImpl(this, i);
			}
			return parameters;
		}
Exemple #3
0
		public override ParameterInfo[] GetParameters()
		{
			ParameterInfo[] parameterInfos = new ParameterInfo[parameterTypes.Length];
			for (int i = 0; i < parameterInfos.Length; i++)
			{
				parameterInfos[i] = new ParameterInfoImpl(this, parameterTypes[i], i);
			}
			return parameterInfos;
		}
		internal GenericParameterInfoImpl(GenericMethodInstance method, ParameterInfo parameterInfo)
		{
			this.method = method;
			this.parameterInfo = parameterInfo;
		}
Exemple #5
0
		public override ParameterInfo[] GetParameters()
		{
			ParameterInfo[] parameters = new ParameterInfo[signature.GetParameterCount()];
			for (int i = 0; i < parameters.Length; i++)
			{
				parameters[i] = new ParameterInfoImpl(this, i);
			}
			return parameters;
		}
		public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo parameter)
		{
			return __GetCustomAttributes(parameter, null, false);
		}
		public static IList<CustomAttributeData> __GetCustomAttributes(ParameterInfo parameter, Type attributeType, bool inherit)
		{
			Module module = parameter.Module;
			List<CustomAttributeData> list = null;
			if (module.universe.ReturnPseudoCustomAttributes)
			{
				if (attributeType == null || attributeType.IsAssignableFrom(parameter.Module.universe.System_Runtime_InteropServices_MarshalAsAttribute))
				{
					FieldMarshal spec;
					if (parameter.__TryGetFieldMarshal(out spec))
					{
						if (list == null)
						{
							list = new List<CustomAttributeData>();
						}
						list.Add(CustomAttributeData.CreateMarshalAsPseudoCustomAttribute(parameter.Module, spec));
					}
				}
			}
			ModuleBuilder mb = module as ModuleBuilder;
			int token = parameter.MetadataToken;
			if (mb != null && mb.IsSaved && ModuleBuilder.IsPseudoToken(token))
			{
				token = mb.ResolvePseudoToken(token);
			}
			return GetCustomAttributesImpl(list, module, token, attributeType) ?? EmptyList;
		}
Exemple #8
0
			internal ParameterInfoWrapper(ConstructorInfo ctor, ParameterInfo forward)
			{
				this.ctor = ctor;
				this.forward = forward;
			}
		private static bool MatchParameterTypes(ParameterInfo[] parameters, Type[] types)
		{
			if (parameters.Length != types.Length)
			{
				return false;
			}
			for (int i = 0; i < parameters.Length; i++)
			{
				Type sourceType = types[i];
				Type targetType = parameters[i].ParameterType;
				if (sourceType != targetType
					&& !targetType.IsAssignableFrom(sourceType)
					&& !IsAllowedPrimitiveConversion(sourceType, targetType))
				{
					return false;
				}
			}
			return true;
		}
Exemple #10
0
		public static IList<CustomAttributeData> GetCustomAttributes(ParameterInfo parameter)
		{
			return parameter.GetCustomAttributesData(null);
		}
Exemple #11
0
		public static IList<CustomAttributeData> __GetCustomAttributes(ParameterInfo parameter, Type attributeType, bool inherit)
		{
			return parameter.GetCustomAttributesData(attributeType);
		}
Exemple #12
0
        void AddAttributes(ParameterInfo parameter, DefaultUnresolvedParameter targetParameter)
        {
            if (!targetParameter.IsOut) {
                if (parameter.IsIn)
                    targetParameter.Attributes.Add(inAttribute);
                if (parameter.IsOut)
                    targetParameter.Attributes.Add(outAttribute);
            }
            AddCustomAttributes(parameter.CustomAttributes, targetParameter.Attributes);

            FieldMarshal marshalInfo;
            if (parameter.__TryGetFieldMarshal (out marshalInfo)) {
                targetParameter.Attributes.Add(ConvertMarshalInfo(marshalInfo));
            }
        }
Exemple #13
0
        public IUnresolvedParameter ReadParameter(ParameterInfo parameter)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");
            var type = ReadTypeReference(parameter.ParameterType, typeAttributes: parameter.CustomAttributes);
            var p = new DefaultUnresolvedParameter(type, interningProvider.Intern(parameter.Name ?? "index"));

            if (parameter.ParameterType.IsByRef) {
                if (!parameter.IsIn && parameter.IsOut)
                    p.IsOut = true;
                else
                    p.IsRef = true;
            }
            AddAttributes(parameter, p);

            if (parameter.IsOptional) {
                p.DefaultValue = CreateSimpleConstantValue(type, parameter.RawDefaultValue);
            }

            if (parameter.ParameterType.IsArray) {
                foreach (var att in parameter.CustomAttributes) {
                    if (att.AttributeType.FullName == typeof(ParamArrayAttribute).FullName) {
                        p.IsParams = true;
                        break;
                    }
                }
            }

            return interningProvider.Intern(p);
        }
Exemple #14
0
        public IUnresolvedParameter ReadParameter(ParameterInfo parameter)
        {
            if (parameter == null)
                throw new ArgumentNullException("parameter");
            var customAttributes = parameter.CustomAttributes;
            var parameterType = parameter.ParameterType;
            var type = ReadTypeReference(parameterType, typeAttributes: customAttributes);
            var p = new DefaultUnresolvedParameter(type, interningProvider.Intern(parameter.Name ?? "index"));

            if (parameterType.IsByRef) {
                if (!parameter.IsIn && parameter.IsOut)
                    p.IsOut = true;
                else
                    p.IsRef = true;
            }
            AddAttributes(parameter, p, customAttributes);

            if (parameter.IsOptional) {
                p.DefaultValue = CreateSimpleConstantValue(type, parameter.RawDefaultValue);
            }

            if (parameterType.IsArray) {
                foreach (var att in customAttributes) {
                    var dt = att.Constructor.DeclaringType;
                    if (dt.__Name == "ParamArrayAttribute" && dt.Namespace == "System") {
                        p.IsParams = true;
                        break;
                    }
                }
            }

            return interningProvider.Intern(p);
        }
		internal ParameterInfoWrapper(MemberInfo member, ParameterInfo forward)
		{
			this.member = member;
			this.forward = forward;
		}
 string FormatParameter(ParameterInfo p)
 {
     return String.Format ("{0}{1} {2}", /*p.GetCustomAttribute<ParamArrayAttribute> () != null ? "params " :*/ null, p.ParameterType.CSSwitchName (), p.Name);
 }