Beispiel #1
0
        private static string Process(this ConstantExpression constantExpression)
        {
            var stringify = _stringificationRulesResolver.RequiresStringification(constantExpression.Type);
            var value     = constantExpression.Value;

            var converter   = ConverterExtensions.GetConverter(null, constantExpression.Type);
            var valueString = converter.ConvertBack(value);

            if (valueString == null)
            {
                return(null);
            }

            return(stringify ? valueString.WrapWithQuotes() : valueString);
        }
        public void RequiresStringification_ReturnsTrue()
        {
            var forString           = _stringificationRulesResolver.RequiresStringification(typeof(string));
            var forDateTime         = _stringificationRulesResolver.RequiresStringification(typeof(DateTime));
            var forNullableDateTime = _stringificationRulesResolver.RequiresStringification(typeof(DateTime?));

            Assert.IsTrue(forString);
            Assert.IsTrue(forDateTime);
            Assert.IsTrue(forNullableDateTime);
        }