Skip to main content

Definition

Assembly: CloudNimble.Breakdance.DotHttp.dll Namespace: CloudNimble.Breakdance.DotHttp Inheritance: System.Object

Syntax

CloudNimble.Breakdance.DotHttp.VariableResolver

Summary

Resolves {{variable}} placeholders in .http file content.

Remarks

Supports simple variables, dynamic variables (datetime,datetime, randomInt, etc.), and response references for request chaining per the Microsoft .http file specification.

Examples

var resolver = new VariableResolver();
resolver.SetVariable("baseUrl", "https://api.example.com");
resolver.SetVariable("apiKey", "my-secret-key");
var result = resolver.Resolve("GET {{baseUrl}}/users?key={{apiKey}}");
// result = "GET https://api.example.com/users?key=my-secret-key"

Constructors

.ctor

Syntax

public VariableResolver()

.ctor Inherited

Inherited from object

Syntax

public Object()

Methods

Clear

Clears all stored variables.

Syntax

public void Clear()

Examples

var resolver = new VariableResolver();
resolver.SetVariable("foo", "bar");
resolver.Clear();
// All variables are now removed

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetResponseReferenceNames

Extracts all response reference names from the input.

Syntax

public System.Collections.Generic.HashSet<string> GetResponseReferenceNames(string input)

Parameters

NameTypeDescription
inputstringThe input string.

Returns

Type: System.Collections.Generic.HashSet<string> Set of request names that are referenced.

Examples

var resolver = new VariableResolver();
var input = "Authorization: Bearer {{login.response.body.$.token}}";
var names = resolver.GetResponseReferenceNames(input);
// names contains "login"

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

GetVariableNames

Extracts all variable names from the input string.

Syntax

public System.Collections.Generic.HashSet<string> GetVariableNames(string input)

Parameters

NameTypeDescription
inputstringThe input string.

Returns

Type: System.Collections.Generic.HashSet<string> Set of variable names found.

Examples

var resolver = new VariableResolver();
var input = "{{baseUrl}}/users/{{userId}}";
var names = resolver.GetVariableNames(input);
// names contains "baseUrl" and "userId"

HasResponseReferences

Checks if a string contains response references ({{name.response.*}}).

Syntax

public bool HasResponseReferences(string input)

Parameters

NameTypeDescription
inputstringThe input string to check.

Returns

Type: bool True if response references are present.

Examples

var resolver = new VariableResolver();
var hasRefs = resolver.HasResponseReferences("Bearer {{login.response.body.$.token}}");
// hasRefs = true

HasUnresolvedVariables

Checks if a string contains any unresolved variable references.

Syntax

public bool HasUnresolvedVariables(string input)

Parameters

NameTypeDescription
inputstringThe input string to check.

Returns

Type: bool True if unresolved variables remain.

Examples

var resolver = new VariableResolver();
resolver.SetVariable("baseUrl", "https://api.example.com");
var resolved = resolver.Resolve("{{baseUrl}}/{{userId}}");
var hasUnresolved = resolver.HasUnresolvedVariables(resolved);
// hasUnresolved = true (userId was not set)

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

Resolve

Resolves all variable references in the input string.

Syntax

public string Resolve(string input)

Parameters

NameTypeDescription
inputstringThe input string containing {{variable}} placeholders.

Returns

Type: string The resolved string with variables replaced.

Examples

var resolver = new VariableResolver();
resolver.SetVariable("baseUrl", "https://api.example.com");
var result = resolver.Resolve("GET {{baseUrl}}/users");
// result = "GET https://api.example.com/users"

ResolveDynamicVariables

Resolves dynamic variables like datetime,datetime, randomInt, $timestamp, etc.

Syntax

public string ResolveDynamicVariables(string input)

Parameters

NameTypeDescription
inputstringThe input string.

Returns

Type: string The resolved string.

Examples

var resolver = new VariableResolver();
var result = resolver.ResolveDynamicVariables("ID: {{$guid}}");
// result = "ID: 550e8400-e29b-41d4-a716-446655440000" (example GUID)

ResolveSimpleVariables

Resolves simple {{variable}} placeholders.

Syntax

public string ResolveSimpleVariables(string input)

Parameters

NameTypeDescription
inputstringThe input string.

Returns

Type: string The resolved string.

Examples

var resolver = new VariableResolver();
resolver.SetVariable("name", "John");
var result = resolver.ResolveSimpleVariables("Hello, {{name}}!");
// result = "Hello, John!"

SetVariable

Sets a variable value for resolution.

Syntax

public void SetVariable(string name, string value)

Parameters

NameTypeDescription
namestringThe variable name (without @ prefix or wrapper).
valuestringThe variable value.

Examples

var resolver = new VariableResolver();
resolver.SetVariable("baseUrl", "https://api.example.com");

SetVariables

Sets multiple variables at once.

Syntax

public void SetVariables(System.Collections.Generic.IDictionary<string, string> variables)

Parameters

NameTypeDescription
variablesSystem.Collections.Generic.IDictionary<string, string>Dictionary of variable names and values.

Examples

var resolver = new VariableResolver();
resolver.SetVariables(new Dictionary&lt;string, string&gt;
{
    ["baseUrl"] = "https://api.example.com",
    ["apiKey"] = "secret-key"
});

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?