Skip to content

Commit

Permalink
remove ThenBy
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Jun 15, 2024
1 parent b0eccbc commit b59bd3c
Show file tree
Hide file tree
Showing 7 changed files with 207 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@

namespace System.Linq.Dynamic.Core.NewtonsoftJson.Config;

/// <summary>
/// Configuration class for System.Linq.Dynamic.Core.NewtonsoftJson which implements the <see cref="ParsingConfig"/>.
/// </summary>
public class NewtonsoftJsonParsingConfig : ParsingConfig
{
public static NewtonsoftJsonParsingConfig Default { get; } = new();
/// <summary>
/// The default ParsingConfig for <see cref="NewtonsoftJsonParsingConfig"/>.
/// </summary>
public new static NewtonsoftJsonParsingConfig Default { get; } = new();

/// <summary>
/// The default <see cref="DynamicJsonClassOptions"/> to use.
/// </summary>
public DynamicJsonClassOptions? DynamicJsonClassOptions { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public static object Min(this JArray source, LambdaExpression lambda)
/// <param name="source">A sequence of values to order.</param>
/// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray OrderBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, params object?[] args)
{
Expand All @@ -579,7 +579,7 @@ public static JArray OrderBy(this JArray source, NewtonsoftJsonParsingConfig con
/// </summary>
/// <param name="source">A sequence of values to order.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray OrderBy(this JArray source, string ordering, params object?[] args)
{
Expand All @@ -593,7 +593,7 @@ public static JArray OrderBy(this JArray source, string ordering, params object?
/// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="comparer">The comparer to use.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray OrderBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, IComparer comparer, params object?[] args)
{
Expand All @@ -607,7 +607,7 @@ public static JArray OrderBy(this JArray source, NewtonsoftJsonParsingConfig con
/// <param name="source">A sequence of values to order.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="comparer">The comparer to use.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray OrderBy(this JArray source, string ordering, IComparer comparer, params object?[] args)
{
Expand Down Expand Up @@ -654,7 +654,7 @@ public static PagedResult PageResult(this JArray source, int page, int pageSize,
/// </summary>
/// <param name="source">A sequence of values to project.</param>
/// <param name="selector">A projection string expression to apply to each element.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>An <see cref="JArray"/> whose elements are the result of invoking a projection string on each element of source.</returns>
public static JArray Select(this JArray source, string selector, params object?[] args)
{
Expand All @@ -667,7 +667,7 @@ public static JArray Select(this JArray source, string selector, params object?[
/// <param name="source">A sequence of values to project.</param>
/// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
/// <param name="selector">A projection string expression to apply to each element.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>An <see cref="JArray"/> whose elements are the result of invoking a projection string on each element of source.</returns>
public static JArray Select(this JArray source, NewtonsoftJsonParsingConfig config, string selector, params object?[] args)
{
Expand Down Expand Up @@ -874,67 +874,67 @@ public static JArray TakeWhile(this JArray source, string predicate, params obje
}
#endregion TakeWhile

#region ThenBy
/// <summary>
/// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
/// </summary>
/// <param name="source">A sequence of values to order.</param>
/// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray ThenBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, params object?[] args)
{
Check.NotNull(source);
Check.NotNull(config);

var queryable = ToQueryable(source, config).OrderBy("0"); // Workaround to get IOrderedQueryable
return ToJArray(() => queryable.ThenBy(ordering, args));
}

/// <summary>
/// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
/// </summary>
/// <param name="source">A sequence of values to order.</param>
/// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="comparer">The comparer to use.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray ThenBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, IComparer comparer, params object?[] args)
{
Check.NotNull(source);
Check.NotNull(config);

var queryable = ToQueryable(source, config).OrderBy("0"); // Workaround to get IOrderedQueryable
return ToJArray(() => queryable.ThenBy(ordering, comparer, args));
}

/// <summary>
/// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
/// </summary>
/// <param name="source">A sequence of values to order.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray ThenBy(this JArray source, string ordering, params object?[] args)
{
return ThenBy(source, NewtonsoftJsonParsingConfig.Default, ordering, args);
}

/// <summary>
/// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
/// </summary>
/// <param name="source">A sequence of values to order.</param>
/// <param name="ordering">An expression string to indicate values to order by.</param>
/// <param name="comparer">The comparer to use.</param>
/// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
/// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
public static JArray ThenBy(this JArray source, string ordering, IComparer comparer, params object?[] args)
{
return ThenBy(source, NewtonsoftJsonParsingConfig.Default, ordering, comparer, args);
}
#endregion ThenBy
//#region ThenBy
///// <summary>
///// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
///// </summary>
///// <param name="source">A sequence of values to order.</param>
///// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
///// <param name="ordering">An expression string to indicate values to order by.</param>
///// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
///// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
//public static JArray ThenBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, params object?[] args)
//{
// Check.NotNull(source);
// Check.NotNull(config);

// var queryable = ToQueryable(source, config).OrderBy("0"); // Workaround to get IOrderedQueryable
// return ToJArray(() => queryable.ThenBy(ordering, args));
//}

///// <summary>
///// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
///// </summary>
///// <param name="source">A sequence of values to order.</param>
///// <param name="config">The <see cref="NewtonsoftJsonParsingConfig"/>.</param>
///// <param name="ordering">An expression string to indicate values to order by.</param>
///// <param name="comparer">The comparer to use.</param>
///// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
///// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
//public static JArray ThenBy(this JArray source, NewtonsoftJsonParsingConfig config, string ordering, IComparer comparer, params object?[] args)
//{
// Check.NotNull(source);
// Check.NotNull(config);

// var queryable = ToQueryable(source, config).OrderBy("0"); // Workaround to get IOrderedQueryable
// return ToJArray(() => queryable.ThenBy(ordering, comparer, args));
//}

///// <summary>
///// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
///// </summary>
///// <param name="source">A sequence of values to order.</param>
///// <param name="ordering">An expression string to indicate values to order by.</param>
///// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
///// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
//public static JArray ThenBy(this JArray source, string ordering, params object?[] args)
//{
// return ThenBy(source, NewtonsoftJsonParsingConfig.Default, ordering, args);
//}

///// <summary>
///// Performs a subsequent ordering of the elements in a sequence in ascending order according to a key.
///// </summary>
///// <param name="source">A sequence of values to order.</param>
///// <param name="ordering">An expression string to indicate values to order by.</param>
///// <param name="comparer">The comparer to use.</param>
///// <param name="args">An object array that contains zero or more objects to insert into the predicate as parameters. Similar to the way String.Format formats strings.</param>
///// <returns>A <see cref="JArray"/> whose elements are sorted according to the specified <paramref name="ordering"/>.</returns>
//public static JArray ThenBy(this JArray source, string ordering, IComparer comparer, params object?[] args)
//{
// return ThenBy(source, NewtonsoftJsonParsingConfig.Default, ordering, comparer, args);
//}
//#endregion ThenBy

#region Where
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
namespace System.Linq.Dynamic.Core.SystemTextJson.Config;

/// <summary>
/// Configuration class for System.Linq.Dynamic.Core.SystemTextJson which implements the <see cref="ParsingConfig"/>.
/// </summary>
public class SystemTextJsonParsingConfig : ParsingConfig
{
public static SystemTextJsonParsingConfig Default { get; } = new();
/// <summary>
/// The default ParsingConfig for <see cref="SystemTextJsonParsingConfig"/>.
/// </summary>
public new static SystemTextJsonParsingConfig Default { get; } = new();
}
Loading

0 comments on commit b59bd3c

Please sign in to comment.