Example #1
0
        public int CompareTo(object obj)
        {
            if (obj == null || obj.GetType() != typeof(NuGenParameter))
            {
                throw new NotSupportedException();
            }

            NuGenParameter otherParameter = (NuGenParameter)obj;

            return(OrdinalIndex.CompareTo(otherParameter.OrdinalIndex));
        }
		private void EnumParameters(NuGenIMetaDataImport2 import)
		{
			NuGenAssembly assembly = BaseTypeDefinition.ModuleScope.Assembly;
			IntPtr enumHandle = IntPtr.Zero;
			uint[] parameterTokens = new uint[NuGenProject.DefaultArrayCount];
			uint count = 0;
			import.EnumParams(ref enumHandle, Token, parameterTokens, Convert.ToUInt32(parameterTokens.Length), out count);

			if (count > 0)
			{
				Parameters = new List<NuGenParameter>();
			}

			while (count > 0)
			{
				for (uint parameterTokensIndex = 0; parameterTokensIndex < count; parameterTokensIndex++)
				{
					uint methodToken;
					uint parameterToken = parameterTokens[parameterTokensIndex];
					uint ordinalIndex;
					uint nameLength;
					uint attributeFlags;
					uint elementType;
					IntPtr defaultValue;
					uint defaultValueLength;

					import.GetParamProps(parameterToken, out methodToken, out ordinalIndex, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out nameLength, out attributeFlags, out elementType, out defaultValue, out defaultValueLength);

					if (nameLength > NuGenProject.DefaultCharArray.Length)
					{
						NuGenProject.DefaultCharArray = new char[nameLength];

						import.GetParamProps(parameterToken, out methodToken, out ordinalIndex, NuGenProject.DefaultCharArray, Convert.ToUInt32(NuGenProject.DefaultCharArray.Length), out nameLength, out attributeFlags, out elementType, out defaultValue, out defaultValueLength);
					}

					NuGenParameter parameter = new NuGenParameter(import, assembly.AllTokens, parameterToken, this, ordinalIndex, NuGenHelperFunctions.GetString(NuGenProject.DefaultCharArray, 0, nameLength), attributeFlags, elementType, defaultValue, defaultValueLength);
					Parameters.Add(parameter);
					assembly.AllTokens[Token] = parameter;
				}

				import.EnumParams(ref enumHandle, Token, parameterTokens, Convert.ToUInt32(parameterTokens.Length), out count);
			}

			import.CloseEnum(enumHandle);

			if (Parameters != null)
			{
				Parameters.Sort();

				foreach (NuGenParameter parameter in Parameters)
				{
					parameter.ReadMarshalInformation(import, assembly.AllTokens, Parameters.Count);
				}
			}
		}