Exemple #1
0
        public static LiteralElement CreateFromInteger(string image, IServiceProvider services)
        {
            LiteralElement element = default(LiteralElement);

            element = CreateSingle(image, services);

            if ((element != null))
            {
                return(element);
            }

            element = CreateDecimal(image, services);

            if ((element != null))
            {
                return(element);
            }

            ExpressionOptions options = (ExpressionOptions)services.GetService(typeof(ExpressionOptions));

            // Convert to a double if option is set
            if (options.IntegersAsDoubles == true)
            {
                return(DoubleLiteralElement.Parse(image, services));
            }

            return(null);
        }
Exemple #2
0
        private static DoubleLiteralElement?CreateDouble(string image)
        {
            if (image.EndsWith("d", StringComparison.OrdinalIgnoreCase))
            {
                image = image.Remove(image.Length - 1);
                return(DoubleLiteralElement.Parse(image));
            }

            return(null);
        }
Exemple #3
0
 private static DoubleLiteralElement CreateDouble(string image, IServiceProvider services)
 {
     if (image.EndsWith("d", StringComparison.OrdinalIgnoreCase) == true)
     {
         image = image.Remove(image.Length - 1);
         return(DoubleLiteralElement.Parse(image, services));
     }
     else
     {
         return(null);
     }
 }
Exemple #4
0
        private static LiteralElement?CreateImplicitReal(string image)
        {
            var realType = builderOptions.RealLiteralDataType;

            switch (realType)
            {
            case RealLiteralDataType.Double:
                return(DoubleLiteralElement.Parse(image));

            case RealLiteralDataType.Single:
                return(SingleLiteralElement.Parse(image));

            case RealLiteralDataType.Decimal:
                return(DecimalLiteralElement.Parse(image));

            default:
                Debug.Fail("Unknown value");
                return(null);
            }
        }
Exemple #5
0
        private static LiteralElement CreateImplicitReal(string image, IServiceProvider services)
        {
            ExpressionOptions   options  = (ExpressionOptions)services.GetService(typeof(ExpressionOptions));
            RealLiteralDataType realType = options.RealLiteralDataType;

            switch (realType)
            {
            case RealLiteralDataType.Double:
                return(DoubleLiteralElement.Parse(image, services));

            case RealLiteralDataType.Single:
                return(SingleLiteralElement.Parse(image, services));

            case RealLiteralDataType.Decimal:
                return(DecimalLiteralElement.Parse(image, services));

            default:
                Debug.Fail("Unknown value");
                return(null);
            }
        }
Exemple #6
0
        public static LiteralElement?CreateFromInteger(string image, ExpressionBuilderOptions options)
        {
            builderOptions = options;
            LiteralElement element = CreateSingle(image);

            if (element != null)
            {
                return(element);
            }

            element = CreateDecimal(image);

            if (element != null)
            {
                return(element);
            }

            if (builderOptions.IntegerAsDouble)
            {
                return(DoubleLiteralElement.Parse(image));
            }

            return(null);
        }