コード例 #1
0
        public TypeSubstitutionExpressionVisitor(IDictionary <Type, Type> typeMap)
#endif
        {
            if (typeMap == null)
            {
                throw new ArgumentNullException(nameof(typeMap));
            }

            _subst = new TypeSubstitutor(typeMap);
        }
コード例 #2
0
        public void TypeSubstitutor_Array()
        {
            var subst = new TypeSubstitutor(new Dictionary <Type, Type>
            {
                { typeof(int[]), typeof(long[]) }
            });

            Assert.IsNull(subst.Visit(type: null));
            Assert.AreSame(typeof(string), subst.Visit(typeof(string)));
            Assert.AreSame(typeof(List <string[]> [, ]), subst.Visit(typeof(List <string[]> [, ])));

            Assert.AreSame(typeof(int), subst.Visit(typeof(int)));
            Assert.AreEqual(typeof(long[]), subst.Visit(typeof(int[])));
            Assert.AreSame(typeof(int[, ]), subst.Visit(typeof(int[, ])));
            Assert.AreSame(typeof(Func <int>), subst.Visit(typeof(Func <int>)));
            Assert.AreEqual(typeof(Func <bool, Func <object, long[]>, double>), subst.Visit(typeof(Func <bool, Func <object, int[]>, double>)));
            Assert.AreSame(typeof(int *), subst.Visit(typeof(int *)));
            Assert.AreSame(typeof(int).MakeByRefType(), subst.Visit(typeof(int).MakeByRefType()));
        }
コード例 #3
0
 public void TypeSubstitutor_ArgumentChecks()
 {
     Assert.ThrowsException <ArgumentNullException>(() => _ = new TypeSubstitutor(map: null));
 }
コード例 #4
0
        public TypeSubstitutionExpressionVisitor(TypeSubstitutor typeSubstitutor)
#endif
        {
            _subst = typeSubstitutor ?? throw new ArgumentNullException(nameof(typeSubstitutor));
        }
コード例 #5
0
        /// <summary>
        /// Creates a new type substitution expression visitor with the specified type substitutor.
        /// </summary>
        /// <param name="typeSubstitutor">Type substitutor to map source types onto target types.</param>
#if USE_SLIM
        public TypeSubstitutionExpressionSlimVisitor(TypeSubstitutor typeSubstitutor)
コード例 #6
0
 /// <summary>
 /// Creates a new type substitution query expression visitor with the specified type substitutor.
 /// </summary>
 /// <param name="typeSubstitutor">Type substitutor to map source types onto target types.</param>
 public TypeSubstitutionQueryVisitor(TypeSubstitutor typeSubstitutor)
 {
     _subst = typeSubstitutor ?? throw new ArgumentNullException(nameof(typeSubstitutor));
     _lambdaBodyConverter = new TypeSubstitutionExpressionVisitor(_subst);
 }