Exemplo n.º 1
0
 internal WithField(CSharpPattern pattern, TupleFieldInfo field)
     : base(pattern)
 {
     Field = field;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a positional subpattern that matches a component of a tuple.
        /// </summary>
        /// <param name="pattern">The pattern to apply to the object in the corresponding position.</param>
        /// <param name="field">The field in the tuple to match.</param>
        /// <returns>A <see cref="PositionalCSharpSubpattern" /> representing a positional subpattern.</returns>
        public static PositionalCSharpSubpattern PositionalSubpattern(CSharpPattern pattern, TupleFieldInfo field)
        {
            RequiresNotNull(pattern, nameof(pattern));
            RequiresNotNull(field, nameof(field));

            if (field.Index < 0)
            {
                throw Error.TupleFieldIndexMustBePositive();
            }

            return(new PositionalCSharpSubpattern.WithField(pattern, field));
        }