Beispiel #1
0
        public static LiteralElement CreateFromInteger(string image, IServiceProvider services)
        {
            LiteralElement element = CreateSingle(image, services);
            var            flag    = element != null;
            LiteralElement createFromInteger;

            if (flag)
            {
                createFromInteger = element;
            }
            else
            {
                element = CreateDecimal(image, services);
                var flag2 = element != null;
                if (flag2)
                {
                    createFromInteger = element;
                }
                else
                {
                    var options           = (ExpressionOptions)services.GetService(typeof(ExpressionOptions));
                    var integersAsDoubles = options.IntegersAsDoubles;
                    createFromInteger = integersAsDoubles ? DoubleLiteralElement.Parse(image, services) : null;
                }
            }
            return(createFromInteger);
        }
Beispiel #2
0
        private static LiteralElement CreateImplicitReal(string image, IServiceProvider services)
        {
            var            options            = (ExpressionOptions)services.GetService(typeof(ExpressionOptions));
            LiteralElement createImplicitReal = null;

            switch (options.RealLiteralDataType)
            {
            case RealLiteralDataType.Single:
                createImplicitReal = SingleLiteralElement.Parse(image, services);
                break;

            case RealLiteralDataType.Double:
                createImplicitReal = DoubleLiteralElement.Parse(image, services);
                break;

            case RealLiteralDataType.Decimal:
                createImplicitReal = DecimalLiteralElement.Parse(image, services);
                break;

            default:
                Debug.Fail("Unknown value");
                break;
            }
            return(createImplicitReal);
        }
Beispiel #3
0
        private static DoubleLiteralElement CreateDouble(string image, IServiceProvider services)
        {
            var flag = image.EndsWith("d", StringComparison.OrdinalIgnoreCase);
            DoubleLiteralElement createDouble;

            if (flag)
            {
                image        = image.Remove(image.Length - 1);
                createDouble = DoubleLiteralElement.Parse(image, services);
            }
            else
            {
                createDouble = null;
            }
            return(createDouble);
        }