GetResult¶
GetResult<T> issues a GET request through the shared HTTP funnel and materializes a single value of type T, applying type-specific coercion rules so callers never have to hand-write conversion code for primitives, strings, or byte arrays.
| Field | Value |
|---|---|
| Operation ID | OP-01 |
| Trigger | Direct call by a consuming application. |
| Inputs | methodUriSegment (relative URI appended to the service base URI); generic type argument T. |
| Outputs | A single T, or default(T). |
| Primary components | JsonHttpClient.GetResult<T>(string) |
| Entry point | src/SAIF.Web.API.Clients/JsonHttpClient.cs |
Steps¶
- Execute the HTTP GET through the shared request funnel.
- Embedded logic (BR-CLI-001, BR-CLI-002, BR-CLI-003, BR-CLI-005, BR-CLI-006, BR-CLI-010, BR-CLI-011):
- Build the RestSharp client, assign the authenticator, clear default content handlers, and add identity/on-behalf-of-user headers.
- Execute the request, retry on a configured status set, and enforce success before returning.
Origin: This step is implemented in GetJsonResponse (
SAIF.Web.API.Clients) and executed on behalf of this operation. - On failure: any non-success status surfaces as aSAIF.API.Exceptions.SAIFExceptionsubclass from the delegate. 2. IfTisstring: trim surrounding"quotes from the raw content andConvert.ChangeTypetoT(BR-CLI-013). - Returns immediately; no JSON parse is performed. 3. Else ifT.IsPrimitive:Convert.ChangeType(content, typeof(T))on the raw, untrimmed content (BR-CLI-013). - On failure: a malformed or quoted primitive payload throwsFormatException/InvalidCastExceptionuncaught to the caller. 4. Else ifTisbyte[]: trim"andConvert.FromBase64String(BR-CLI-013). - On failure: non-base64 content throwsFormatExceptionuncaught. 5. Else if content isnullor the literal string"null": returndefault(T)(BR-CLI-013). - Short-circuits deserialization. 6. Else: deserialize toT[]viaGetContentArray<T>and return element[0](BR-CLI-012). - Embedded logic: - Normalize the JSON payload shape (array, object, or scalar) intoT[].Origin: This step is implemented in GetContentArray\<T> (
SAIF.Web.API.Clients) and executed on behalf of this operation. - On failure: wrapped incatch (InvalidCastException) → return default(T). An empty result array throwsIndexOutOfRangeException, which this catch does not handle*.
Process flow¶
The following diagrams visualize this operation's control flow, split by concern so each renders at a readable width.
The first diagram shows the string and primitive type-check branches:
flowchart TD
Start(["GetResult<T><br>called"]) --> Funnel["Execute GET via<br>GetJsonResponse"]
Funnel --> TypeCheck{Type of T?}
TypeCheck -->|string| Trim["Trim quotes,<br>Convert.ChangeType"] --> EndOk([Return T])
TypeCheck -->|primitive| Convert["Convert.ChangeType on<br>raw content"] --> EndOk
The second diagram shows the byte array and null type-check branches:
flowchart TD
TypeCheck{Type of T?} -->|byte array| Base64["Trim quotes,<br>FromBase64String"] --> EndOk([Return T])
TypeCheck -->|null / literal null| Default[Return default T] --> EndOk
The third diagram shows the fallback (other) type-check branch:
flowchart TD
TypeCheck{Type of T?} -->|other| Deserialize["GetContentArray, take<br>element 0"] --> EndOk([Return T])
Failure and edge-case behavior¶
- A malformed or quoted primitive payload throws
FormatException/InvalidCastExceptionuncaught to the caller (step 3). - Non-base64 content for a
byte[]target throwsFormatExceptionuncaught (step 4). - An empty result array from
GetContentArray<T>raisesIndexOutOfRangeException, which the surroundingcatch (InvalidCastException)does not handle*.
Related documentation¶
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
src/SAIF.Web.API.Clients/JsonHttpClient.cs