Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions RestSharp/IRestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,15 @@ public interface IRestRequest
IRestRequest AddBody (object obj);

/// <summary>
/// Calls AddParameter() for all public, readable properties specified in the white list
/// Calls AddParameter() for all public, readable properties specified in the includedProperties list
/// </summary>
/// <example>
/// request.AddObject(product, "ProductId", "Price", ...);
/// </example>
/// <param name="obj">The object with properties to add as parameters</param>
/// <param name="whitelist">The names of the properties to include</param>
/// <param name="includedProperties">The names of the properties to include</param>
/// <returns>This request</returns>
IRestRequest AddObject (object obj, params string[] whitelist);
IRestRequest AddObject (object obj, params string[] includedProperties);

/// <summary>
/// Calls AddParameter() for all public, readable properties of obj
Expand Down
8 changes: 4 additions & 4 deletions RestSharp/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,23 @@ public IRestRequest AddBody (object obj)
}

/// <summary>
/// Calls AddParameter() for all public, readable properties specified in the white list
/// Calls AddParameter() for all public, readable properties specified in the includedProperties list
/// </summary>
/// <example>
/// request.AddObject(product, "ProductId", "Price", ...);
/// </example>
/// <param name="obj">The object with properties to add as parameters</param>
/// <param name="whitelist">The names of the properties to include</param>
/// <param name="includedProperties">The names of the properties to include</param>
/// <returns>This request</returns>
public IRestRequest AddObject (object obj, params string[] whitelist)
public IRestRequest AddObject (object obj, params string[] includedProperties)
{
// automatically create parameters from object props
var type = obj.GetType();
var props = type.GetProperties();

foreach (var prop in props)
{
bool isAllowed = whitelist.Length == 0 || (whitelist.Length > 0 && whitelist.Contains(prop.Name));
bool isAllowed = includedProperties.Length == 0 || (includedProperties.Length > 0 && includedProperties.Contains(prop.Name));

if (isAllowed)
{
Expand Down