/// <summary> /// Changes the input type to the specified type. /// </summary> /// <remarks> /// This functionality can be used when a pattern is pass to an expression or statement that applies the pattern. /// </remarks> /// <param name="inputType">The new input type.</param> /// <returns>The original pattern rewritten to use the specified input type.</returns> public override CSharpPattern ChangeType(Type inputType) { if (inputType == InputType) { return(this); } return(CSharpPattern.List(ObjectPatternInfo(PatternInfo(inputType, NarrowedType), Variable), LengthAccess, IndexerAccess, Patterns)); }
/// <summary> /// Creates a new expression that is like this one, but using the supplied children. If all of the children are the same, it will return this expression. /// </summary> /// <param name="variable">The <see cref="Variable" /> property of the result.</param> /// <param name="lengthAccess">The <see cref="LengthAccess" /> property of the result.</param> /// <param name="indexerAccess">The <see cref="IndexerAccess" /> property of the result.</param> /// <param name="patterns">The <see cref="Patterns" /> property of the result.</param> /// <returns>This expression if no children changed, or an expression with the updated children.</returns> public ListCSharpPattern Update(ParameterExpression variable, LambdaExpression lengthAccess, LambdaExpression indexerAccess, IEnumerable <CSharpPattern> patterns) { if (variable == Variable && lengthAccess == LengthAccess && indexerAccess == IndexerAccess && SameElements(ref patterns, Patterns)) { return(this); } return(CSharpPattern.List(ObjectPatternInfo(_info, variable), lengthAccess, indexerAccess, patterns)); }