-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fields as query parameter (#199)
* Added fields as query parameter * Added xml comments * Also fixed tabs * Added a correct ToString method * Fixed to string method of FieldsetProperty * Added test for fields not known to type
- Loading branch information
1 parent
952e792
commit 3fd7e12
Showing
14 changed files
with
215 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Saule.Queries.Fieldset | ||
{ | ||
/// <summary> | ||
/// Context for fieldset operations | ||
/// </summary> | ||
public class FieldsetContext | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FieldsetContext"/> class. | ||
/// </summary> | ||
/// <param name="queryParams">query string that might contain Fieldset keyword</param> | ||
public FieldsetContext(IEnumerable<KeyValuePair<string, string>> queryParams) | ||
{ | ||
Properties = | ||
from query in queryParams | ||
where query.Key.StartsWith(Constants.QueryNames.Fieldset) | ||
let type = query.Key.Substring(Constants.QueryNames.Fieldset.Length + 1) | ||
let fields = query.Value.Split(',') | ||
select new FieldsetProperty(type, fields); | ||
} | ||
|
||
/// <summary> | ||
/// Gets including properties | ||
/// </summary> | ||
public IEnumerable<FieldsetProperty> Properties { get; internal set; } | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return Properties != null && Properties.Any() ? string.Join("&", Properties.Select(p => p.ToString())) : string.Empty; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
namespace Saule.Queries.Fieldset | ||
{ | ||
/// <summary> | ||
/// Property for fieldset | ||
/// </summary> | ||
public class FieldsetProperty | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FieldsetProperty"/> class. | ||
/// </summary> | ||
/// <param name="type">type for field filter</param> | ||
/// <param name="fields">fields to serialize filter</param> | ||
public FieldsetProperty(string type, string[] fields) | ||
{ | ||
Type = type; | ||
Fields = fields; | ||
} | ||
|
||
/// <summary> | ||
/// Gets property type | ||
/// </summary> | ||
public string Type { get; } | ||
|
||
/// <summary> | ||
/// Gets property fields | ||
/// </summary> | ||
public string[] Fields { get; } | ||
|
||
/// <inheritdoc/> | ||
public override string ToString() | ||
{ | ||
return $"fields[{Type}]={string.Join(",", Fields)}"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.