Visual Guard Expression & Action ?

Using an expression to modify the value of a property

Estimated reading: 2 minutes 1403 views

  • #CurrentValue: This variable contains the current value of the

    property. The type of the value depends on the type of the property to change.
  • #Permission: A VGIPermission object containing the permission for which the security action

    is executed. You can access to the value of a permission argument by using the syntax:

    #Permission[‘myarg’].
  • #EventArgs: This variable references the arguments passed to the

    event that raises the security action. This variable is available only when the

    security action is raised for a specific event. The type of this variable depends

    of the type of the event handler used to handles the event. For example,  when

    you create an action raised on the ‘Validating’ event of a textbox, the type of

    the  #EventArgs variable will be ‘CancelEventArgs’

    since the type of the event is ‘CancelEventHandler’.
  • #UserId: A string value containing the Visual Guard repository

    Id of the user for which the action is executed.
  • #UserName: A string value containing the name of the user

    for which the action is executed.
  • #Principal: A VGIPrincipal object containing the principal for which the action is executed.

    You can use this variable to check whether the user is authenticated or not (#Principal.Identity.IsAuthenticated)

    or if the current user is member of a specific role (#Principal.IsInRole(‘administrator’)).


Evaluation of the expression

Error on expression at design time


Examples of expression

  • Expression
#CurrentValue and _txbCountry.Text == #Permission['Country']
  • Expression
#CurrentValue.Length == 0 ? string.Format('Country = ''{0}''',#Permission['Country']) : string.Format('({1}) And Country = ''{0}''',#Permission['Country'], #CurrentValue)