C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
AnalyzeRe.APITypes.Reference Class Referenceabstract

Implements the basic reference entity interface, but has no support for resolving references. More...

Public Member Functions

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 by requesting it from the server.
 
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.
 
virtual T ShallowCopy< T > ()
 Create a shallow copy of this object.

See also
ExtensionMethods.DeepCopy<T>

for a serializer-based copy method.

 
override string ToString ()
 Returns this reference's id.
 

Protected Member Functions

 Reference (string ref_id, string href)
 Creates a new reference class that refers to an object with the specified id, type, and HREF. Normally called only by the serializer when a response containing a reference is received by the server.
 
virtual void AfterMembersCloned (APIType originalResource)
 Invoked following construction if the current instance has been created using a member-wise clone of some other instance. Override if your derived APIType class contains some members that should not be cloned.
 

Properties

string CollectionName [get]
 The name of the collection at which this resource resides.
 
string href [get, protected set]
 The HREF that can be used to retrieve the object being referred to.
 
string ref_id [get, protected set]
 The id of the object being referred to.
 
string reference_type [get, protected set]
 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 the reference has been resolved and the value is available.
 
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 resolved object being referred to.
 

Detailed Description

Implements the basic reference entity interface, but has no support for resolving references.

Definition at line 14 of file Reference.cs.

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

Constructor & Destructor Documentation

◆ Reference()

AnalyzeRe.APITypes.Reference.Reference ( string  ref_id,
string  href 
)
inlineprotected

Creates a new reference class that refers to an object with the specified id, type, and HREF. Normally called only by the serializer when a response containing a reference is received by the server.

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

Definition at line 46 of file Reference.cs.

Member Function Documentation

◆ AfterMembersCloned()

virtual void AnalyzeRe.APIType.AfterMembersCloned ( APIType  originalResource)
inlineprotectedvirtualinherited

Invoked following construction if the current instance has been created using a member-wise clone of some other instance. Override if your derived APIType class contains some members that should not be cloned.

Overriding implementations should be sure to invoke base.AfterMembersCloned().

A sane question for a code reviewer to ask might be: "Why not avoid copying those members in the first place?" The answer is that there is no framework-supported method of excluding members from a MemberwiseClone. The only officially supported solution is to not use the object.MemberwiseClone method at all and instead have each class implement it's own Copy method. In our case, most objects have no need to specialize their copy implementation (even though they could - the ShallowCopy<T> method is marked virtual). It's simpler to simply "correct" any special-case members after the fact, and requires less error-prone code than if the code were responsible for ensuring no members were missed in a copy. It's also faster than any reflection-based approach, even though such an approach could benefit from custom attributes meant to exclude certain members from copying.

Reimplemented in AnalyzeRe.APITypes.APIResource_WithDataEndpoint, AnalyzeRe.APIResourceView.BaseAPIResourceView, AnalyzeRe.Distributions.CustomDistribution, AnalyzeRe.LossSets.LossSet_WithData, AnalyzeRe.Optimization.Candidate, AnalyzeRe.Optimization.OptimizationView, and AnalyzeRe.StaticSimulation.

Definition at line 37 of file APIType.cs.

◆ Equals()

override bool AnalyzeRe.APITypes.Reference.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 57 of file Reference.cs.

◆ GetHashCode()

override int AnalyzeRe.APITypes.Reference.GetHashCode ( )
inline

Serves as a hash function for reference objects.

Returns
A hash code for the current Reference.

Definition at line 66 of file Reference.cs.

◆ GetValue()

T AnalyzeRe.IReference< out T >.GetValue ( IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null,
bool  updateCache = false 
)
inherited

Gets the resource that this reference refers to by requesting it from the server.

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.

◆ Resolve()

void AnalyzeRe.IReference< out T >.Resolve ( IEnumerable< Parameter >  requestParameters = null,
int?  timeout = null,
bool  updateCache = false 
)
inherited

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.

◆ ShallowCopy< T >()

virtual T AnalyzeRe.APIType.ShallowCopy< T > ( )
inlinevirtualinherited

Create a shallow copy of this object.

See also
ExtensionMethods.DeepCopy<T>

for a serializer-based copy method.

Returns
A shallow copy of this object.

If this object contains any members that reference the current object (this), the class should override this method to avoid cloning a reference to the old class.

Implements AnalyzeRe.IAPIType.

Type Constraints
T :IAPIType 

Definition at line 14 of file APIType.cs.

◆ ToString()

override string AnalyzeRe.APITypes.Reference.ToString ( )
inline

Returns this reference's id.

Returns
The content of the ref_id property.

Definition at line 75 of file Reference.cs.

Property Documentation

◆ CollectionName

string AnalyzeRe.IReference< out T >.CollectionName
getinherited

The name of the collection at which this resource resides.

Definition at line 27 of file IReference[T].cs.

◆ href

string AnalyzeRe.APITypes.Reference.href
getprotected set

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

Implements AnalyzeRe.IReference< out T >.

Definition at line 37 of file Reference.cs.

◆ ref_id

string AnalyzeRe.APITypes.Reference.ref_id
getprotected set

The id of the object being referred to.

Implements AnalyzeRe.IReference< out T >.

Definition at line 32 of file Reference.cs.

◆ reference_type

string AnalyzeRe.APITypes.Reference.reference_type
getprotected set

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.

This property is currently only used behind-the-scenes for serialization and deserialization of reference types. The supported way of specifying the reference type in this library is to instantiate a Reference<T> with the appropriate generic type argument.

Implements AnalyzeRe.IReference< out T >.

Definition at line 28 of file Reference.cs.

◆ resolved

bool AnalyzeRe.IReference< out T >.resolved
getinherited

Indicates whether the reference has been resolved and the value is available.

Definition at line 16 of file IReference[T].cs.

◆ ResourceType

Type AnalyzeRe.IReference< out T >.ResourceType
getinherited

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

Definition at line 32 of file IReference[T].cs.

◆ Value

T AnalyzeRe.IReference< out T >.Value
getinherited

Returns the resolved object being referred to.

Definition at line 23 of file IReference[T].cs.


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