Class ValueParser
Inherited Members
Namespace: Xareus.Scenarios
Assembly: Xareus.Scenarios.dll
Syntax
public static class ValueParser
Fields
EVENT_CONTEXT
Declaration
public static readonly string EVENT_CONTEXT
Field Value
Type | Description |
---|---|
string |
EXTERNAL_CONTEXT
Declaration
public static readonly string EXTERNAL_CONTEXT
Field Value
Type | Description |
---|---|
string |
SCENARIO_CONTEXT
Declaration
public static readonly string SCENARIO_CONTEXT
Field Value
Type | Description |
---|---|
string |
SEQUENCE_CONTEXT
Declaration
public static readonly string SEQUENCE_CONTEXT
Field Value
Type | Description |
---|---|
string |
Methods
CanConvertToParameter(Type, ITypeDescriptorContext)
Helper method to check if there is a valid converter from the current type to the Parameter type
Declaration
public static bool CanConvertToParameter(Type type, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
Type | type | The current type to check the conversion to Parameter to |
ITypeDescriptorContext | context |
Returns
Type | Description |
---|---|
bool |
ConvertFromParameter(Parameter, Type, ITypeDescriptorContext)
Helper method to convert a parameter to any other type if possible.
Declaration
public static object ConvertFromParameter(Parameter parameter, Type conversionType, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
Parameter | parameter | The string value to convert |
Type | conversionType | The type to convert the parameter to |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
object |
ConvertFromParameter<T>(Parameter, ITypeDescriptorContext)
Helper method to convert a parameter to any other type if possible.
Declaration
public static T ConvertFromParameter<T>(Parameter parameter, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
Parameter | parameter | the parameter to convert |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The type to convert to |
ConvertFromString(string, Type, ITypeDescriptorContext)
Helper method to convert a string to any other type if possible.
Declaration
public static object ConvertFromString(string value, Type conversionType, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
string | value | the string value to convert |
Type | conversionType | The type to convert the string to |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
object |
ConvertFromString<T>(string, ITypeDescriptorContext)
Helper method to convert a string to any other type if possible.
Declaration
public static T ConvertFromString<T>(string value, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
string | value | the string value to convert |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The type to convert to |
ConvertTo(Type, object, ITypeDescriptorContext)
Helper method to convert a type to any other type if possible.
Declaration
public static object ConvertTo(Type typeToConvertTo, object value, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
Type | typeToConvertTo | The current type to check the conversion to Parameter to |
object | value | the value to convert |
ITypeDescriptorContext | context |
Returns
Type | Description |
---|---|
object |
ConvertToParameter(object, Type, ITypeDescriptorContext)
Helper method to convert an object to a parameter if possible
Declaration
public static Parameter ConvertToParameter(object value, Type type, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
object | value | The object value to convert |
Type | type | The type to convert from |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
Parameter |
ConvertToParameter<T>(T, ITypeDescriptorContext)
Helper method to convert an object to a parameter if possible
Declaration
public static Parameter ConvertToParameter<T>(T value, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The object value to convert |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
Parameter |
Type Parameters
Name | Description |
---|---|
T | The type to convert from |
ConvertToString<T>(T, ITypeDescriptorContext)
Helper method to convert an object to a string if possible
Declaration
public static string ConvertToString<T>(T value, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
T | value | The object value to convert |
ITypeDescriptorContext | context | An optional context for the converter |
Returns
Type | Description |
---|---|
string |
Type Parameters
Name | Description |
---|---|
T | The type to convert from |
ConvertTo<T>(object, ITypeDescriptorContext)
Helper method to convert a type to any other type if possible.
Declaration
public static T ConvertTo<T>(object value, ITypeDescriptorContext context = null)
Parameters
Type | Name | Description |
---|---|---|
object | value | the value to convert |
ITypeDescriptorContext | context |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | The type to convert to |
GetContext(ref string, IContext, IContext, IContext, IContext)
Declaration
[Obsolete("Use GetContext(string, ContextHolder) instead.")]
public static IContext GetContext(ref string path, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
IContext | externalContext | |
IContext | scenarioContext | |
IContext | sequenceContext | |
IContext | eventContext |
Returns
Type | Description |
---|---|
IContext |
GetContextAndInnerPath(string, ContextHolder)
Extract the context and the internal path from a full path. If no context is specified, returns null for the context and the provided full path as path
Declaration
public static (IContext, string) GetContextAndInnerPath(string path, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
ContextHolder | contexts |
Returns
Type | Description |
---|---|
(IContext, string) | Tuple containing the context (or null if not found) and the innerPath in the context (or fullpath is the context was not found) |
GetContextStringAndVariablePath(string)
Extract the variable path from the given path. If no context is specified, returns null as context string and the provided full path as path
Declaration
public static (string, string) GetContextStringAndVariablePath(string path)
Parameters
Type | Name | Description |
---|---|---|
string | path |
Returns
Type | Description |
---|---|
(string, string) |
Parse(string, string, ContextHolder)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
public static object Parse(string valueType, string value, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
string | valueType | The type of the value |
string | value | The value |
ContextHolder | contexts | The contexts |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if not path is specified |
Parse(string, string, IContext, IContext, IContext, IContext)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
[Obsolete("Use Parse(string, string, ContextHolder) instead.")]
public static object Parse(string valueType, string value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
string | valueType | The type of the value |
string | value | The value |
IContext | externalContext | The external context |
IContext | scenarioContext | The scenario context |
IContext | sequenceContext | The context conveyed by the sequence |
IContext | eventContext | The context in which the event was triggered |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if not path is specified |
Parse(string, ContextHolder)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
public static object Parse(string value, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value |
ContextHolder | contexts | The contexts |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if not path is specified |
Parse(string, IContext, IContext, IContext, IContext)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
[Obsolete("Use Parse(string, ContextHolder) instead.")]
public static object Parse(string value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value |
IContext | externalContext | The external context |
IContext | scenarioContext | The scenario context |
IContext | sequenceContext | The context conveyed by the sequence |
IContext | eventContext | The context in which the event was triggered |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if not path is specified |
Parse(Type, string, ContextHolder)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
public static object Parse(Type valueType, string value, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
Type | valueType | The type of the value |
string | value | The value |
ContextHolder | contexts | The contexts |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if no path is specified |
Parse(Type, string, IContext, IContext, IContext, IContext)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
[Obsolete("Use Parse(Type, string, ContextHolder) instead.")]
public static object Parse(Type valueType, string value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
Type | valueType | The type of the value |
string | value | The value |
IContext | externalContext | The external context |
IContext | scenarioContext | The scenario context |
IContext | sequenceContext | The context conveyed by the sequence |
IContext | eventContext | The context in which the event was triggered |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if no path is specified |
Parse(Type, Parameter, ContextHolder)
Parses a parameter into an object. If the parameter contains a value field, then a string parse occurs
Declaration
public static object Parse(Type valueType, Parameter parameter, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
Type | valueType | The type of the value |
Parameter | parameter | The parameter holding the values |
ContextHolder | contexts | The contexts |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if no path is specified |
Parse(Type, Parameter, IContext, IContext, IContext, IContext)
Parses a parameter into an object. If the parameter contains a value field, then a string parse occurs
Declaration
[Obsolete("Use Parse(Type, Parameter, ContextHolder) instead.")]
public static object Parse(Type valueType, Parameter parameter, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
Type | valueType | The type of the value |
Parameter | parameter | The parameter holding the values |
IContext | externalContext | The external context |
IContext | scenarioContext | The scenario context |
IContext | sequenceContext | The context conveyed by the sequence |
IContext | eventContext | The context in which the event was triggered |
Returns
Type | Description |
---|---|
object | The conversion. The context can be returned if no path is specified |
ParseScenario(string, IContext, IContext, IContext, IContext)
Declaration
[Obsolete("Use Parse(string, ContextHolder) instead.")]
public static Scenario ParseScenario(string value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
string | value | |
IContext | externalContext | |
IContext | scenarioContext | |
IContext | sequenceContext | |
IContext | eventContext |
Returns
Type | Description |
---|---|
Scenario |
Parse<T>(string, ContextHolder)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
public static T Parse<T>(string value, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value |
ContextHolder | contexts | The contexts |
Returns
Type | Description |
---|---|
T | The conversion |
Type Parameters
Name | Description |
---|---|
T |
Parse<T>(string, IContext, IContext, IContext, IContext)
Converts a value according to the rules listed bellow (precedence matters).
$(ANYCONTEXT.<path>?.<key>)
recovers the value from the given context in the given path.
Use everydefined parser to try to convert the value
<float>
is converted to a float.
<string>
is the initial value.
Declaration
[Obsolete("Use Parse<T>(string, ContextHolder) instead.")]
public static T Parse<T>(string value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext)
Parameters
Type | Name | Description |
---|---|---|
string | value | The value |
IContext | externalContext | The external context |
IContext | scenarioContext | The scenario context |
IContext | sequenceContext | The context conveyed by the sequence |
IContext | eventContext | The context in which the event was triggered |
Returns
Type | Description |
---|---|
T | The conversion |
Type Parameters
Name | Description |
---|---|
T |
SetValue<T>(string, T, ContextHolder)
Sets a value in one of the contexts
Declaration
public static bool SetValue<T>(string path, T value, ContextHolder contexts)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
T | value | |
ContextHolder | contexts |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T |
SetValue<T>(string, T, IContext, IContext, IContext, IContext)
Sets a value in one of the contexts
Declaration
[Obsolete("Use SetValue<T>(string, T, ContextHolder) instead.")]
public static bool SetValue<T>(string path, T value, IContext externalContext, IContext scenarioContext, IContext sequenceContext, IContext eventContext = null)
Parameters
Type | Name | Description |
---|---|---|
string | path | |
T | value | |
IContext | externalContext | |
IContext | scenarioContext | |
IContext | sequenceContext | |
IContext | eventContext |
Returns
Type | Description |
---|---|
bool |
Type Parameters
Name | Description |
---|---|
T |