Class Response<TModel>
An API response
Namespace: Seltzr.Responses
Assembly: Seltzr.dll
Syntax
public class Response<TModel>
where TModel : class
Type Parameters
TModel
The model that the response contains
Constructors
Initializes a new instance of the Response<TModel> class.
public Response()
Methods
Gets all of the properties on this Response<TModel> that should be included in the serialized body
public PropertyInfo[] GetIncludedProperties()
Returns
All of the properties on this Response<TModel> that should be included in the serialized body
Gets all of the properties on this Response<TModel> that should not be included in the serialized body
public PropertyInfo[] GetOmittedProperties()
Returns
All of the properties on this Response<TModel> that should not be included in the serialized body
Populates the model property on this Response<TModel>
public virtual void Populate(TModel[] models, bool shouldStrip)
Parameters
models
TModel[]
The model dataset
shouldStrip
Boolean
true to strip the array if there's only one element, false otherwise
Sets the value of all properties on this Response<TModel> that have the ResponseValueAttribute with the given name applied to them. If no such properties exist, no action will occur.
public virtual void Set(string name, object value)
Parameters
name
String
The name given to the ResponseValueAttribute on the properties to set
value
Object
The value to assign to that property
Sets the value of all properties on this Response<TModel> that have the given attribute applied to them. If no such properties exist, no action will occur.
public virtual void Set<TAttribute>(object value)
where TAttribute : Attribute
Parameters
value
Object
The value to assign to that property
Type Parameters
TAttribute
The attribute to match on the properties to set
Sets the value of all properties on this Response<TModel> that have the ResponseValueAttribute with the given name applied to them. If no such properties exist, no action will occur.
public virtual void SetString(string name, string value)
Parameters
name
String
The name given to the ResponseValueAttribute on the properties to set
value
String
The string value to assign to that property
Remarks
This method will attempt to convert the string value to a supported type if the type of the matching property is not string.
Sets the value of all properties on this Response<TModel> that have the given attribute applied to them. If no such properties exist, no action will occur.
public virtual void SetString<TAttribute>(string value)
where TAttribute : Attribute
Parameters
value
String
The string value to assign to that property
Type Parameters
TAttribute
The attribute to match on the properties to set
Remarks
This method will attempt to convert the string value to a supported type if the type of the matching property is not string.