예제 #1
0
        public void ZeroValueTupleTests()
        {
            var info = TupleInfo.GetInfo <ValueTuple>();

            info.TupleType.Should().Be(typeof(ValueTuple));
            info.ItemTypes.Should().BeEmpty();
            info.CreateNew(new object[0]).Should().Be(ValueTuple.Create());
        }
예제 #2
0
        public void EightTupleTests()
        {
            var info = TupleInfo.GetInfo <Tuple <int, int, int, int, int, int, int, Tuple <int> > >();

            info.TupleType.Should().Be(typeof(Tuple <int, int, int, int, int, int, int, Tuple <int> >));
            info.ItemTypes.Should().Equal(Enumerable.Repeat(typeof(int), 8));
            info.CreateNew(new object[] { 1, 2, 3, 4, 5, 6, 7, 8 }).Should().Be(Tuple.Create(1, 2, 3, 4, 5, 6, 7, 8));
        }
예제 #3
0
        public void OneTupleTests()
        {
            var info = TupleInfo.GetInfo <Tuple <int> >();

            info.TupleType.Should().Be(typeof(Tuple <int>));
            info.ItemTypes.Should().Equal(typeof(int));
            info.CreateNew(new object[] { 1 }).Should().Be(new Tuple <int>(1));
        }
예제 #4
0
 public void IsTuple()
 {
     TupleInfo.IsTuple(null).Should().BeFalse();
     TupleInfo.IsTuple("ValueTuple").Should().BeFalse();
     TupleInfo.IsTuple(ValueTuple.Create(true)).Should().BeTrue();
     TupleInfo.IsTuple(default(ValueTuple)).Should().BeTrue();
     TupleInfo.IsTuple(Tuple.Create(true)).Should().BeTrue();
     TupleInfo.IsTuple(default(ValueTuple?)).Should().BeFalse();
 }
예제 #5
0
 public void IsTupleType()
 {
     TupleInfo.IsTupleType(typeof(object)).Should().BeFalse();
     TupleInfo.IsTupleType(typeof(string)).Should().BeFalse();
     TupleInfo.IsTupleType(typeof(ValueTuple <bool>)).Should().BeTrue();
     TupleInfo.IsTupleType(typeof(ValueTuple)).Should().BeTrue();
     TupleInfo.IsTupleType(typeof(Tuple <bool>)).Should().BeTrue();
     TupleInfo.IsTupleType(typeof(Tuple)).Should().BeFalse();
 }
예제 #6
0
        internal static DbValueTypeStrategy GetStrategy(Type type)
        {
            if (s_strategies.TryGetValue(type, out var strategy))
            {
                return(strategy);
            }

            if (TupleInfo.IsTupleType(type))
            {
                return(DbValueTypeStrategy.Tuple);
            }

            if (type.GetTypeInfo().IsEnum)
            {
                return(DbValueTypeStrategy.Enum);
            }

            return(DbValueTypeStrategy.DtoProperties);
        }
예제 #7
0
        void Tuple(out TupleInfo ti, string locality)
        {
            object val = null; List <object> items = new List <object>();

            Expect(7);
            Constant(out val);
            items.Add(val);
            while (la.kind == 8)
            {
                Get();
                Constant(out val);
                items.Add(val);
            }
            Expect(9);
            ti = new TupleInfo()
            {
                Items = items, Locality = locality
            };
        }
예제 #8
0
        void LocatedItem()
        {
            TupleInfo ti = null; Process p = null;

            Expect(1);
            string locality = t.val;

            Expect(6);
            if (la.kind == 7)
            {
                Tuple(out ti, locality);
                this.tuples.Add(ti);
            }
            else if (StartOf(1))
            {
                Process(out p, locality);
                this.Processes.Add(new ProcessDefinition(p, GetProcName(locality), true));
            }
            else
            {
                SynErr(25);
            }
        }
 void Tuple(out TupleInfo ti, string locality)
 {
     object val = null; List<object> items = new List<object>();
     Expect(7);
     Constant(out val);
     items.Add(val);
     while (la.kind == 8) {
     Get();
     Constant(out val);
     items.Add(val);
     }
     Expect(9);
     ti = new TupleInfo(){Items = items, Locality = locality};
 }
예제 #10
0
 public void IsNullableValueTupleType()
 {
     TupleInfo.IsTupleType(typeof(ValueTuple <bool>?)).Should().BeTrue();
     TupleInfo.IsTupleType(typeof(ValueTuple?)).Should().BeTrue();
 }
예제 #11
0
 public void WeakNonTupleType()
 {
     Invoking(() => TupleInfo.GetInfo(typeof(int)))
     .Should().Throw <InvalidOperationException>();
 }
예제 #12
0
 public void StrongNonTupleType()
 {
     Invoking(() => TupleInfo.GetInfo <int>())
     .Should().Throw <InvalidOperationException>();
 }