C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
AnalyzeRe.Reference< T > Class Template Reference

Implements the reference entity interface, with support for resolving references using lazy loading. More...

Public Member Functions

 Reference (IReference other)
 Creates a new reference class that refers to the same object referred to by the other reference class.
 
 Reference (string ref_id)
 Creates a new instance of this reference type that refers to an object with the specified id.
 
 Reference (string ref_id, string href)
 Creates a new reference that refers to an object of the current type, with the specified id but with a specific href (URL) which may be different .
 
 Reference (T value)
 Creates a new reference to the specified resource.
 
override bool Equals (object obj)
 Determines whether the two reference objects refer to the same object.
 
override int GetHashCode ()
 Serves as a hash function for reference objects.
 
T GetValue (IEnumerable< Parameter > requestParameters=null, int? timeout=null, bool updateCache=false)
 Gets the resource that this reference refers to. If the reference has not previously been resolved, this is done by requesting it from the server, otherwise the previously resolved instance is returned (unless updateCache is set to true).
 
void Resolve (IEnumerable< Parameter > requestParameters=null, int? timeout=null, bool updateCache=false)
 Resolve this reference by retrieving the referenced object. If this reference is already resolved, this method does nothing. To refresh the resolved object (e.g. if the referenced object is mutable and might have changed) you can set updateCache to true.
 
ShallowCopy< T > ()
 Create a shallow copy of this object.
 
override string ToString ()
 Returns this reference's id, or value type if it has no id.
 

Static Public Member Functions

static string GuessHref (string ref_id, T value=default(T))
 Attempts to guess the URL at which this resource can be resolved based on the resource collection name specified by the type T.
 
static operator Reference< T > (T value)
 Allows an IAPIResource object to be explicitly converted to a new Reference to that object via casting.
 

Properties

string CollectionName [get]
 The name of the collection at which this resource resides.
 
string href [get]
 The HREF that can be used to retrieve the object being referred to.
 
string ref_id [get]
 The id of the object being referred to.
 
string reference_type [get]
 In cases where a model can reference resources belonging to one of a number of collections, this property is used to indicate what type of resource the collection refers to.
 
bool resolved [get]
 Indicates whether this reference has been resolved into an object.
 
Type ResourceType [get]
 Returns the runtime type of resource this reference refers to, or the generic type parameter T if unresolved.
 
T Value [get]
 Returns the object this reference refers to by resolving it with a request to the server.
 

Detailed Description

Implements the reference entity interface, with support for resolving references using lazy loading.

Type Constraints
T :IAPIResource 

Definition at line 19 of file Reference[T].cs.

Inheritance diagram for AnalyzeRe.Reference< T >:
AnalyzeRe.IReference< T > AnalyzeRe.IAPIType

Constructor & Destructor Documentation

◆ Reference() [1/4]

AnalyzeRe.Reference< T >.Reference ( string  ref_id)
inline

Creates a new instance of this reference type that refers to an object with the specified id.

Parameters
ref_idThe id of the object being referred to.

Definition at line 86 of file Reference[T].cs.

◆ Reference() [2/4]

AnalyzeRe.Reference< T >.Reference ( string  ref_id,
string  href 
)
inline

Creates a new reference that refers to an object of the current type, with the specified id but with a specific href (URL) which may be different .

Parameters
ref_idThe id of the object being referred to.
hrefThe HREF of the object being referred to.

Definition at line 92 of file Reference[T].cs.

◆ Reference() [3/4]

AnalyzeRe.Reference< T >.Reference ( IReference< T other)
inline

Creates a new reference class that refers to the same object referred to by the other reference class.

Parameters
otherThe reference class to copy reference information from.

Definition at line 119 of file Reference[T].cs.

◆ Reference() [4/4]

AnalyzeRe.Reference< T >.Reference ( T  value)
inline

Creates a new reference to the specified resource.

Parameters
valueThe resource to create a reference to.

Definition at line 139 of file Reference[T].cs.

Member Function Documentation

◆ Equals()

override bool AnalyzeRe.Reference< T >.Equals ( object  obj)
inline

Determines whether the two reference objects refer to the same object.

Parameters
objThe reference object to compare to this one.
Returns
True if the two reference objects are equivalent.

Definition at line 278 of file Reference[T].cs.

◆ GetHashCode()

override int AnalyzeRe.Reference< T >.GetHashCode ( )
inline

Serves as a hash function for reference objects.

Returns
A hash code for the current Reference.

Definition at line 293 of file Reference[T].cs.

◆ GetValue()

T AnalyzeRe.Reference< T >.GetValue ( IEnumerable< Parameter requestParameters = null,
int timeout = null,
bool  updateCache = false 
)
inline

Gets the resource that this reference refers to. If the reference has not previously been resolved, this is done by requesting it from the server, otherwise the previously resolved instance is returned (unless updateCache is set to true).

Parameters
requestParametersOptional - Additional parameters to include in the GET request resolving the resource, only used if the resource is not already resolved, or if updateCache is set to true.
timeoutOptional (Default: no timeout) - The desired request timeout (in milliseconds) after which the request will time out.
updateCacheOptional (Default: false) - Set to true to ignore the previously resolved reference value (if any) and retrieve an updated copy of the resource from the server. If false, and this reference was previously resolved, a reference to the previously resolved resource will be returned.
Exceptions
RequestTimeoutExceptionIf the server takes longer than timeout milliseconds to return the resource.
Returns
The resource that this reference refers to.

Definition at line 192 of file Reference[T].cs.

◆ GuessHref()

static string AnalyzeRe.Reference< T >.GuessHref ( string  ref_id,
T  value = default(T) 
)
inlinestatic

Attempts to guess the URL at which this resource can be resolved based on the resource collection name specified by the type T.

Returns
The guessed URL at which this resource can be resolved.

Definition at line 163 of file Reference[T].cs.

◆ operator Reference< T >()

static AnalyzeRe.Reference< T >.operator Reference< T > ( T  value)
explicitstatic

Allows an IAPIResource object to be explicitly converted to a new Reference to that object via casting.

◆ Resolve()

void AnalyzeRe.Reference< T >.Resolve ( IEnumerable< Parameter requestParameters = null,
int timeout = null,
bool  updateCache = false 
)
inline

Resolve this reference by retrieving the referenced object. If this reference is already resolved, this method does nothing. To refresh the resolved object (e.g. if the referenced object is mutable and might have changed) you can set updateCache to true.

Parameters
requestParametersOptional - Additional parameters to include in the GET request resolving the resource, only used if the resource is not already resolved.
timeoutOptional (Default: no timeout) - The desired request timeout (in milliseconds) after which the request will time out.
updateCacheOptional (Default: false) - Set to true to ignore any previously resolved reference value (if any) and re-retrieve an updated copy of the resource from the server. If false, and this reference was previously resolved, a reference to the previously resolved resource will be returned.
Exceptions
RequestTimeoutExceptionIf the server takes longer than timeout milliseconds to return the resource.

Definition at line 214 of file Reference[T].cs.

◆ ShallowCopy< T >()

T AnalyzeRe.IAPIType.ShallowCopy< T > ( )
inherited

Create a shallow copy of this object.

Returns
A shallow copy of this object.

Implemented in AnalyzeRe.APIType.

Type Constraints
T :IAPIType 

◆ ToString()

override string AnalyzeRe.Reference< T >.ToString ( )
inline

Returns this reference's id, or value type if it has no id.

Returns
The content of the ref_id property.

Definition at line 310 of file Reference[T].cs.

Property Documentation

◆ CollectionName

string AnalyzeRe.Reference< T >.CollectionName
get

The name of the collection at which this resource resides.

Definition at line 40 of file Reference[T].cs.

◆ href

string AnalyzeRe.IReference< out T >.href
getinherited

The HREF that can be used to retrieve the object being referred to.

Definition at line 22 of file IReference.cs.

◆ ref_id

string AnalyzeRe.IReference< out T >.ref_id
getinherited

The id of the object being referred to.

Definition at line 17 of file IReference.cs.

◆ reference_type

string AnalyzeRe.IReference< out T >.reference_type
getinherited

In cases where a model can reference resources belonging to one of a number of collections, this property is used to indicate what type of resource the collection refers to.

Definition at line 13 of file IReference.cs.

◆ resolved

bool AnalyzeRe.Reference< T >.resolved
get

Indicates whether this reference has been resolved into an object.

Definition at line 44 of file Reference[T].cs.

◆ ResourceType

Type AnalyzeRe.Reference< T >.ResourceType
get

Returns the runtime type of resource this reference refers to, or the generic type parameter T if unresolved.

Definition at line 49 of file Reference[T].cs.

◆ Value

T AnalyzeRe.Reference< T >.Value
get

Returns the object this reference refers to by resolving it with a request to the server.

Definition at line 57 of file Reference[T].cs.


The documentation for this class was generated from the following file: