Click or drag to resize

EmbeddedParser Class

This class manages and parses platform embedded functions. Embedded functions are a sort of simple macro language and are typically used in SQL statements for elements that need to be represented in meta-data, but resolved at the time the SQL statement is executed.

The basic format for an embedded function inside an expression (e.g. a SQL statement) is !fnXXX[flags](params) where ALL embedded functions must start with "!fn" (case-sensitive), be followed by the function name (also case-sensitive), optionally followed by activation flags (currently only "$" is supported indicating that the result should be AnsiQuoted), followed by an open parenthesis and closing parenthesis between which a set of comma-separated parameters may optionally be specified. For example, !fnBitTest(0x00000002, 1) tests whether or not the 1st bit (0-indexed) is set (which it is in this case) and evaluates to 1 if so, else 0.

The parser includes a set of intrinsic functions:

  • fnAppCacheVer - Return the application version number string. The returned format is ver=xxx, where xxx is the application version in production mode, or a timestamp otherwise.
  • fnAppProperty - The value of the specified application property.
  • fnBitTest - Tests for a bit being set. Evaluates to zero if not set. Format is: fnBitTest(value, bitnum) where bitnum is the 0-based index of the bit to test.
  • fnCacheVer - Return a version number for managing included javascript, or style sheets. Ensures the latest versions of files using this function will be up to date and never stale.
  • fnCulture - The name of the current Culture for the current user.
  • fnCultureBase - The name of the current base Culture for the current user (e.g. 'en' for any English language culture).
  • fnDBLookup - Looks up a value in the database. Format is: fnDBLookup(col, table, where). This provides similar functionality to the DBLookup(String, String, String) function.
  • fnFormat - Format data. Format is: fnFormat(value, datatype, format) where datatype is currently limited to d=date/time and format is a standard .Net formatting string.
  • fnNamedFilter - Takes a string that refers to a name of a named filter.
  • fnNewGUID - Generates a new GUID. An optional format parameter may be specified.
  • fnNow - The current date/time with optional timezone defaulting to user's local timezone.
  • fnNowAdd - The current date/time with the specified offset in the form fnNowAdd(period [,count [,timezone]]) where period is one of y, M, d, H, m, s, or f, and defaulting to user's local timezone.
  • fnNowAddUTC - The current date/time in UTC with the specified offset in the form fnNowAddUTC(period [,count]) where period is one of y, M, d, H, m, s, f.
  • fnNowUTC - The current date/time in UTC.
  • fnProfilesFilter - Returns the IN clause formatted string for all of the current user's profiles.
  • fnProxyUserID - The Proxy ID for the current user context.
  • fnTenantID - The value of Session.TenantID.
  • fnTimePeriod - Takes a datetime column name and required time period keyword (e.g. today, yesterday).
  • fnTimePeriodUTC - Takes a UTC datetime column name and required time period keyword (e.g. today, yesterday).
  • fnToday - The current date (with 00:00:00 time component) with optional offset and timezone in the form fnToday([period [,count [,timezone]]]) where period is one of y, M, d, H, m, s, or f, and defaulting to user's local timezone.
  • fnUserGUID - The GUID for the current user.
  • fnUserID - The ID for the current user.
  • fnUserName - The name of the current user.

In addition to these intinsic functions, the parser supports application-specific static substitution functions and dynamic functions. Functions can be registered programmatically by calling RegisterFunction(String, String, String) on the parser or by calling RegisterEmbeddedFunction(String, String, String) on the application.

Static substitution functions can be specified in meta-data via the NetQuarry studio by creating Session Properties and setting the GenEmbeddedFunc attribute on each. Dynamic functions can be configured in meta-data as well by setting up FunctionParser Components. FunctionParser components implement the IFunctionParser interface. The IFunctionParser interface allows the platform to interrogate the component in order to determine which functions it supports and to invoke those functions when encountered during embedded function resolution.

Inheritance Hierarchy
SystemObject
  NetQuarryEmbeddedParser

Namespace:  NetQuarry
Assembly:  EAP.Core (in EAP.Core.dll) Version: 2.0.0.0 (4.6.8.0)
Syntax
[SerializableAttribute]
public class EmbeddedParser

The EmbeddedParser type exposes the following members.

Constructors
  NameDescription
Public methodEmbeddedParser
Creates and initializes a new instance of EmbeddedParse.
Top
Methods
  NameDescription
Public methodContains
Checks for the existence of a particular function.
Public methodDevInfoHtml
Generates an HTML representation of the set of embedded functions appropriate for display to a developer.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodStatic memberExtractFunctions
Parse the specified expression and return the set of embedded functions referenced in the expression.
Protected methodFinalize
Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLoad
Loads intrinsic functions into the parser.
Public methodLoadCustomParsers
Loads custom functions into the parser. Custom functions must be added as components to the application of type functionparser implementing the IFunctionParser interface.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodParse
Parses the string and returns the expanded result.
Public methodRegisterFunction
Adds a simple subsitution function to the collection of functions.
Public methodRegisterParser
Register the functions for the specified IFunctionParser object.
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodEqualValue
Determines if the object value is equal to another object. If the two objects are null, then this returns true. There is special handling for guid comparisons (since a guid could be a string formatted in up to 3 different ways). If the special guid handling is not performed, then the object.Equals method is used.
(Defined by EAPUtil.)
Top
See Also