Privilege

Description

sealed class Tinman.Core.Privileges.Privilege

Instances of this class are used to represent privileges that the Tinman 3D SDK needs for accessing native system resources.

Code-X compliant code is self-contained and thus cannot access any third-party APIs or native system resources. Such accesses may only be performed from within native code regions, see CxStatementCode. For each such native code region in the Tinman 3D SDK, there is a pre-defined Privilege object. Before initialization with TinmanModule.Initialize, privileges may be associated with a IPrivilegePredicate which then decides whether to grant the privilege. Once initialization has finished, privilege predicates cannot be changed anymore.

Per convention, the Privilege objects for a TinmanModule subclass are defined in separate static class within the same namespace, using the name suffix Privileges instead of Module, for example:

ExampleApplicationModule
ExampleApplicationPrivileges

The documentation of the TinmanModule subclass should contain a reference to the privileges class.

Public / Constructors

Privilege


public constructor Privilege → (2)

identifier in : string

[not-empty]
The privilege identifier.

flags in : PrivilegeFlags

The privilege flags that specify the required input.

Creates a new instance of Privilege.

Public / Methods

Is​Granted


[Pure] [ThreadSafe]
public method IsGranted → (1)

info opt : PrivilegeInfo = default(PrivilegeInfo)

The privilege information.

returns → bool

true if this privilege is granted,
false if this privilege is withhold.

Checks if this privilege is granted.

Restrict


public method Restrict → (1)

predicate in : IPrivilegePredicate

[not-null]
The predicate to apply to this privilege, which must provide all required information, see IPrivilegePredicate.Flags.

Restricts this privilege by requiring that the given predicate in returns true before granting it.

This method may only be called while the Tinman 3D SDK is still uninitialized, see TinmanModule.IsInitialized. By default, all privileges have no restrictions.

Throw​If​Not​Granted


[Pure] [ThreadSafe]
public method ThrowIfNotGranted → (2)

source in : string

The error source tag.

info opt : PrivilegeInfo = default(PrivilegeInfo)

The privilege information.

Throws an IOException if the given privilege is not granted.

This method delegates to IsGranted in order to determine whether the privilege is held and uses IOException.MissingPrivilege to construct the exception, if necessary.

IOException

If not allowed because the privilege is not granted.