Class ParameterSubstitution
Class for substituting @-prefixed parameters with their values
Inheritance
Inherited Members
Namespace: Innovator.Client
Assembly: Innovator.Client.dll
Syntax
public class ParameterSubstitution : IEnumerable<KeyValuePair<string, object>>, IEnumerable
Remarks
This class will substitute values into an AML template. Using this class to perform the substitution (via creating a Command) provides several benefits over other techniques (e.g. System.String.Format(System.String,System.Object[]))
String values will be properly escaped for AML. | For example, Items 1 & 2 are > Item 3 will be encoded as
Items 1 & 2 are > Item 3 . If you don't want this to happen, add an
exclamation mark after your parameter name (e.g. using "<prop>@0</prop>"
will encode the string while using "<prop>@0!</prop>" will not perform
any encoding |
Basic .Net types will be handled properly | For example, true will be encoded as 1 and
new DateTime(2000, 1, 1) will be encoded as 2000-01-01T00:00:00 |
Parameters can appear in AML attributes, elements, or in SQL strings. Since AML attributes always are surrounded by quotes, be sure to put your parameter name in quotes as well (whether they are single quotes or double quotes). In SQL, parameters are not quoted as not all values need to be quoted. Rather, the replacement process will decide whether or not quotes are needed. For example,
<Item type='Part' action='@0'>
<state condition='in'>(select name from innovator.table where id = @1)</state>
</Item>
Constructors
| Improve this Doc View SourceParameterSubstitution()
Initializes a new ParameterSubstitution instance for substituting @-prefixed parameters with their values.
Declaration
public ParameterSubstitution()
Remarks
A new instance should be created for each substitution operation
Properties
| Improve this Doc View SourceItemCount
Gets the number of Item
tags found in the query
Declaration
public int ItemCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Mode
Whether the query is AML or SQL
Declaration
public ParameterSubstitutionMode Mode { get; set; }
Property Value
Type | Description |
---|---|
ParameterSubstitutionMode |
ParamCount
Gets the number of parameters for which values were specified
Declaration
public int ParamCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ParameterAccessListener
Gets or sets a callback function which will be called when a parameter is accessed
Declaration
public Action<string> ParameterAccessListener { get; set; }
Property Value
Type | Description |
---|---|
System.Action<System.String> |
Style
Gets or sets the style of parameters being used
Declaration
public ParameterStyle Style { get; set; }
Property Value
Type | Description |
---|---|
ParameterStyle |
Methods
| Improve this Doc View SourceAddIndexedParameters(Object[])
Adds the array of values as parameters where each value is named according to its index in the arra
Declaration
public void AddIndexedParameters(object[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Object[] | values | The array of values. |
AddParameter(String, Object)
Adds the parameter.
Declaration
public void AddParameter(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the parameter. |
System.Object | value | The value of the parameter. |
ClearParameters()
Clears the parameters.
Declaration
public void ClearParameters()
GetEnumerator()
Returns an enumerator that iterates through the list of parameters
Declaration
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<System.String, System.Object>> | A System.Collections.Generic.IEnumerator<T> that can be used to iterate through the collection. |
Implements
Substitute(String, IServerContext)
Substitutes the stored parameters into the specified query.
Declaration
public string Substitute(string query, IServerContext context)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The query. |
IServerContext | context | The context. |
Returns
Type | Description |
---|---|
System.String | A string of the new query |
Substitute(String, IServerContext, TextWriter)
Substitutes the stored parameters into the specified query.
Declaration
public void Substitute(string query, IServerContext context, TextWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The query. |
IServerContext | context | The context. |
System.IO.TextWriter | writer | System.IO.TextWriter into which the new query is written |
Substitute(String, IServerContext, StringBuilder)
Substitutes the stored parameters into the specified query.
Declaration
public void Substitute(string query, IServerContext context, StringBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The query. |
IServerContext | context | The context. |
System.Text.StringBuilder | builder | System.Text.StringBuilder into which the new query is written |
Substitute(String, IServerContext, XmlWriter)
Substitutes the stored parameters into the specified query.
Declaration
public void Substitute(string query, IServerContext context, XmlWriter writer)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | The query. |
IServerContext | context | The context. |
System.Xml.XmlWriter | writer | System.Xml.XmlWriter into which the new query is written |
Explicit Interface Implementations
| Improve this Doc View SourceIEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator |