コード例 #1
0
        public void ExpressionTupletizer_IsTuple()
        {
            AssertEx.ThrowsException <ArgumentNullException>(() => ExpressionTupletizer.IsTuple(type: null), ex => Assert.AreEqual("type", ex.ParamName));

            foreach (var t in new[] {
                typeof(Tuple <int>),
                typeof(Tuple <int, int>),
                typeof(Tuple <int, int, int>),
                typeof(Tuple <int, int, int, int>),
                typeof(Tuple <int, int, int, int, int>),
                typeof(Tuple <int, int, int, int, int, int>),
                typeof(Tuple <int, int, int, int, int, int, int>),
                typeof(Tuple <int, int, int, int, int, int, int, Tuple <int> >),
                typeof(Tuple <int, int, int, int, int, int, int, Tuple <int, int> >),
                typeof(Tuple <int, int, int, int, int, int, int, Tuple <int, int, int, int, int, int, int, Tuple <int, int, int> > >),
            })
            {
                Assert.IsTrue(IsTuple(t));
            }

            foreach (var t in new[] {
                typeof(int),
                typeof(List <int>),
                typeof(Tuple <>),
                typeof(Tuple <,>),
                typeof(Tuple <int, int, int, int, int, int, int, /*TRest*/ int>),
            })
            {
                Assert.IsFalse(IsTuple(t));
            }
        }
コード例 #2
0
                private static bool IsTuple(Expression expression)
                {
                    if (expression.NodeType == ExpressionType.New)
                    {
                        // TODO: All of this code really should move up, closer to where we know we're using tuples.

                        if (ExpressionTupletizer.IsTuple(expression.Type))
                        {
                            return(true);
                        }
                    }

                    return(false);
                }
コード例 #3
0
 private static bool IsTuple(Type type)
 {
     return(ExpressionTupletizer.IsTuple(type));
 }