Ejemplo n.º 1
0
        /// <summary>Adds an argument to the signature, with the specified custom modifiers.</summary>
        /// <param name="argument">The argument type.</param>
        /// <param name="requiredCustomModifiers">An array of types representing the required custom modifiers for the argument, such as <see cref="T:System.Runtime.CompilerServices.IsConst" /> or <see cref="T:System.Runtime.CompilerServices.IsBoxed" />. If the argument has no required custom modifiers, specify null.</param>
        /// <param name="optionalCustomModifiers">An array of types representing the optional custom modifiers for the argument, such as <see cref="T:System.Runtime.CompilerServices.IsConst" /> or <see cref="T:System.Runtime.CompilerServices.IsBoxed" />. If the argument has no optional custom modifiers, specify null.</param>
        /// <exception cref="T:System.ArgumentNullException">
        ///   <paramref name="argument" /> is null. -or-An element of <paramref name="requiredCustomModifiers" /> or <paramref name="optionalCustomModifiers" /> is null.</exception>
        /// <exception cref="T:System.ArgumentException">The signature has already been finished. -or-One of the specified custom modifiers is an array type.-or-One of the specified custom modifiers is an open generic type. That is, the <see cref="P:System.Type.ContainsGenericParameters" /> property is true for the custom modifier.</exception>
        public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers)
        {
            if (argument == null)
            {
                throw new ArgumentNullException("argument");
            }
            if (requiredCustomModifiers != null)
            {
                SignatureHelper.ValidateParameterModifiers("requiredCustomModifiers", requiredCustomModifiers);
            }
            if (optionalCustomModifiers != null)
            {
                SignatureHelper.ValidateParameterModifiers("optionalCustomModifiers", optionalCustomModifiers);
            }
            int pos = SignatureHelper.AppendArray(ref this.arguments, argument);

            if (requiredCustomModifiers != null)
            {
                SignatureHelper.AppendArrayAt(ref this.modreqs, requiredCustomModifiers, pos);
            }
            if (optionalCustomModifiers != null)
            {
                SignatureHelper.AppendArrayAt(ref this.modopts, optionalCustomModifiers, pos);
            }
        }