Ejemplo n.º 1
0
 public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
 {
     return string.Format(
         "{0} eq {1}",
         expressionWriter(expression.Object),
         expressionWriter(expression.Arguments[0]));
 }
Ejemplo n.º 2
0
        public static string Write(object value, ODataExpressionConverterSettings settings)
        {
            if (value == null)
            {
                return("null");
            }
            var type = value.GetType();

            //if (type.IsEnum)
            //{
            //    return string.Format("{0}", (int)value);
            //}

            var writer = settings.ValueWriters.FirstOrDefault(x => x.Handles(type));

            if (writer != null)
            {
                return(writer.Write(value, settings));
            }

            if (typeof(Nullable <>).IsAssignableFrom(type))
            {
                var genericParameter = type.GetGenericArguments()[0];

                return(Write(Convert.ChangeType(value, genericParameter, CultureInfo.CurrentCulture), settings));
            }


            return(value.ToString());
        }
Ejemplo n.º 3
0
        public static string Write(object value, ODataExpressionConverterSettings settings)
        {
            if (value == null)
            {
                return "null";
            }
            var type = value.GetType();

            //if (type.IsEnum)
            //{
            //    return string.Format("{0}", (int)value);
            //}

            var writer = settings.ValueWriters.FirstOrDefault(x => x.Handles(type));

            if (writer != null)
            {
                return writer.Write(value, settings);
            }

            if (typeof(Nullable<>).IsAssignableFrom(type))
            {
                var genericParameter = type.GetGenericArguments()[0];

                return Write(Convert.ChangeType(value, genericParameter, CultureInfo.CurrentCulture), settings);
            }

            return value.ToString();
        }
Ejemplo n.º 4
0
 public ODataQueryProvider(IODataDataClient client, ODataExpressionConverterSettings settings)
 {
     this.Settings        = settings;
     this.client          = client;
     _expressionProcessor = new ExpressionProcessor(settings);
     _parameterBuilder    = new ParameterBuilder();
 }
Ejemplo n.º 5
0
        public string Write(object value, ODataExpressionConverterSettings settings)
        {
            var enumType = value.GetType();
            string assembly;
            string typename;
            settings.SerializationBinder.BindToName(enumType, out assembly, out typename);

            return string.Format("{0}'{1}'", typename, value);
        }
Ejemplo n.º 6
0
        public string Write(object value, ODataExpressionConverterSettings settings)
        {
            var    enumType = value.GetType();
            string assembly;
            string typename;

            settings.SerializationBinder.BindToName(enumType, out assembly, out typename);

            return(string.Format("{0}'{1}'", typename, value));
        }
Ejemplo n.º 7
0
        public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
        {
            var arguments = expression.Arguments.Select(x => expressionWriter(x)).ToList();
            string objectValue = null;

            if (expression.Object != null) //instance method not static
            {
                objectValue = expressionWriter(expression.Object);
            }
            return odataFunction(objectValue, arguments, settings);
        }
Ejemplo n.º 8
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterMember<DateTime>(nameof(DateTime.Date));
     settings.RegisterMember<DateTime>(nameof(DateTime.Day));
     settings.RegisterMember<DateTime>(nameof(DateTime.Year));
     settings.RegisterMember<DateTime>(nameof(DateTime.Hour));
     settings.RegisterMember<DateTime>(nameof(DateTime.MaxValue), "maxdatetime");
     settings.RegisterMember<DateTime>(nameof(DateTime.Minute));
     settings.RegisterMember<DateTime>(nameof(DateTime.MinValue), "mindatetime");
     settings.RegisterMember<DateTime>(nameof(DateTime.Month));
     settings.RegisterMember<DateTime>(nameof(DateTime.Now));
     settings.RegisterMember<DateTime>(nameof(DateTime.Second));
 }
Ejemplo n.º 9
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterMember <DateTime>(nameof(DateTime.Date));
     settings.RegisterMember <DateTime>(nameof(DateTime.Day));
     settings.RegisterMember <DateTime>(nameof(DateTime.Year));
     settings.RegisterMember <DateTime>(nameof(DateTime.Hour));
     settings.RegisterMember <DateTime>(nameof(DateTime.MaxValue), "maxdatetime");
     settings.RegisterMember <DateTime>(nameof(DateTime.Minute));
     settings.RegisterMember <DateTime>(nameof(DateTime.MinValue), "mindatetime");
     settings.RegisterMember <DateTime>(nameof(DateTime.Month));
     settings.RegisterMember <DateTime>(nameof(DateTime.Now));
     settings.RegisterMember <DateTime>(nameof(DateTime.Second));
 }
Ejemplo n.º 10
0
        internal static void RegisterWriters(ODataExpressionConverterSettings settings)
        {
            settings.RegisterMethod <string>(nameof(string.Contains));
            settings.RegisterMethod <string>(nameof(string.EndsWith));
            settings.RegisterMethod <string>(nameof(string.StartsWith));
            settings.RegisterMethod <string>(nameof(string.IndexOf));
            settings.RegisterMethod <string>(nameof(string.ToLower));
            settings.RegisterMethod <string>(nameof(string.ToLowerInvariant), "tolower");
            settings.RegisterMethod <string>(nameof(string.ToUpper));
            settings.RegisterMethod <string>(nameof(string.ToUpperInvariant), "toupper");
            settings.RegisterMethod <string>(nameof(string.Trim));

            settings.RegisterMember <string>(nameof(string.Length));

            settings.RegisterValueWriter <string>(x => $"'{x}'");
        }
Ejemplo n.º 11
0
        public string Handle(MethodCallExpression expression, Func<Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
        {
            var firstArg = expressionWriter(expression.Arguments[0]);
            var method = expression.Method.Name.ToLowerInvariant();
            string parameter = null;
            var lambdaParameter = expression.Arguments[1] as LambdaExpression;
            if (lambdaParameter != null)
            {
                var first = lambdaParameter.Parameters.First();
                parameter = first.Name ?? first.ToString();
            }

            var predicate = expressionWriter(expression.Arguments[1]);

            return string.Format("{0}/{1}({2}:{3})", firstArg, method, parameter, predicate);
        }
Ejemplo n.º 12
0
        internal static void RegisterWriters(ODataExpressionConverterSettings settings)
        {
            settings.RegisterMethod<string>(nameof(string.Contains));
            settings.RegisterMethod<string>(nameof(string.EndsWith));
            settings.RegisterMethod<string>(nameof(string.StartsWith));
            settings.RegisterMethod<string>(nameof(string.IndexOf));
            settings.RegisterMethod<string>(nameof(string.ToLower));
            settings.RegisterMethod<string>(nameof(string.ToLowerInvariant), "tolower");
            settings.RegisterMethod<string>(nameof(string.ToUpper));
            settings.RegisterMethod<string>(nameof(string.ToUpperInvariant), "toupper");
            settings.RegisterMethod<string>(nameof(string.Trim));

            settings.RegisterMember<string>(nameof(string.Length));

            settings.RegisterValueWriter<string>(x => $"'{x}'");
        }
Ejemplo n.º 13
0
 public string Write(object value, ODataExpressionConverterSettings settings)
 {
     return odataFunction(value, settings);
 }
Ejemplo n.º 14
0
 public ExpressionWriter(ODataExpressionConverterSettings settings)
 {
     this.settings = settings;
 }
Ejemplo n.º 15
0
 public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings)
 {
     return expression.Member.Name.ToLowerInvariant();
 }
Ejemplo n.º 16
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterMethod(typeof(Math), nameof(Math.Floor));
     settings.RegisterMethod(typeof(Math), nameof(Math.Ceiling));
     settings.RegisterMethod(typeof(Math), nameof(Math.Round));
 }
Ejemplo n.º 17
0
        public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
        {
            var    arguments   = expression.Arguments.Select(x => expressionWriter(x)).ToList();
            string objectValue = null;

            if (expression.Object != null) //instance method not static
            {
                objectValue = expressionWriter(expression.Object);
            }
            return(odataFunction(objectValue, arguments, settings));
        }
Ejemplo n.º 18
0
 public string Write(object value, ODataExpressionConverterSettings settings)
 {
     return(odataFunction(value, settings));
 }
Ejemplo n.º 19
0
        public override string Write(object value, ODataExpressionConverterSettings settings)
        {
            var boolean = (bool)value;

            return(boolean ? "true" : "false");
        }
Ejemplo n.º 20
0
 public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
 {
     return(string.Format(
                "{0} eq {1}",
                expressionWriter(expression.Object),
                expressionWriter(expression.Arguments[0])));
 }
Ejemplo n.º 21
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterValueWriter(new GuidValueWriter());
 }
Ejemplo n.º 22
0
        public string Write(object value, ODataExpressionConverterSettings settings)
        {
            Guid guid = (Guid)value;

            return(string.Format("guid'{0}'", guid.ToString().ToLower()));
        }
Ejemplo n.º 23
0
        public string Write(object value, ODataExpressionConverterSettings settings)
        {
            Guid guid = (Guid)value;

            return string.Format("guid'{0}'", guid.ToString().ToLower());
        }
Ejemplo n.º 24
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterMethod(typeof(Math), nameof(Math.Floor));
     settings.RegisterMethod(typeof(Math), nameof(Math.Ceiling));
     settings.RegisterMethod(typeof(Math), nameof(Math.Round));
 }
Ejemplo n.º 25
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
     settings.RegisterValueWriter(new GuidValueWriter());
 }
Ejemplo n.º 26
0
 public ExpressionProcessor(ODataExpressionConverterSettings settings) : this(settings, new ExpressionWriter(settings))
 {
 }
Ejemplo n.º 27
0
 public ExpressionWriter(ODataExpressionConverterSettings settings)
 {
     this.settings = settings;
 }
Ejemplo n.º 28
0
 public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings)
 {
     return(expression.Member.Name.ToLowerInvariant());
 }
Ejemplo n.º 29
0
        internal static void RegisterWriters(ODataExpressionConverterSettings settings)
        {
            settings.RegisterMethod(typeof(Enum), nameof(Enum.HasFlag), (opj, args) => $"{opj} has {args.Single()}");

            settings.RegisterValueWriter(new EnumValueWriter());
        }
Ejemplo n.º 30
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
 }
Ejemplo n.º 31
0
 internal static void RegisterWriters(ODataExpressionConverterSettings settings)
 {
 }
Ejemplo n.º 32
0
 public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings)
 {
     return(odataFunction(settings));
 }
Ejemplo n.º 33
0
        public override string Write(object value, ODataExpressionConverterSettings settings)
        {
            var base64 = Convert.ToBase64String((byte[])value);

            return(string.Format("X'{0}'", base64));
        }
Ejemplo n.º 34
0
        public string Handle(MethodCallExpression expression, Func <Expression, string> expressionWriter, ODataExpressionConverterSettings settings)
        {
            var    firstArg        = expressionWriter(expression.Arguments[0]);
            var    method          = expression.Method.Name.ToLowerInvariant();
            string parameter       = null;
            var    lambdaParameter = expression.Arguments[1] as LambdaExpression;

            if (lambdaParameter != null)
            {
                var first = lambdaParameter.Parameters.First();
                parameter = first.Name ?? first.ToString();
            }

            var predicate = expressionWriter(expression.Arguments[1]);

            return(string.Format("{0}/{1}({2}:{3})", firstArg, method, parameter, predicate));
        }
Ejemplo n.º 35
0
 public string Handle(MemberExpression expression, ODataExpressionConverterSettings settings)
 {
     return odataFunction(settings);
 }
Ejemplo n.º 36
0
        internal static void RegisterWriters(ODataExpressionConverterSettings settings)
        {
            settings.RegisterMethod(typeof(Enum), nameof(Enum.HasFlag), (opj, args) => $"{opj} has {args.Single()}");

            settings.RegisterValueWriter(new EnumValueWriter());
        }
Ejemplo n.º 37
0
 public abstract string Write(object value, ODataExpressionConverterSettings settings);
Ejemplo n.º 38
0
 public ExpressionProcessor(ODataExpressionConverterSettings settings, IExpressionWriter writer)
 {
     this.settings = settings;
     _writer       = writer;
 }