Sets resource access rules.
NuGet Package: DevExpress.Data
public bool TrySetRules( params IAccessRule rules )
Public Function TrySetRules( ParamArray rules As IAccessRule() ) As Boolean
An array of access rules.
true, if the specified rule collection is registered successfully. Otherwise, false.
Before you set access rules, specify the resources for which these rules should be checked. To do this, use one of the following static properties:
// Images can be loaded only from the "C:\\StaticResources\\" file directory and "http://mysite.dev" site bool success = DevExpress.Security.Resources.AccessSettings.StaticResources.TrySetRules( DevExpress.Security.Resources.DirectoryAccessRule.Allow("C:\\StaticResources\\"), DevExpress.Security.Resources.UrlAccessRule.Allow("http://mysite.dev")) ; if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")
// JSON data can be loaded only from URLs; Excel data cannot be loaded from file directories (Excel data load from URLs is not supported) bool success = DevExpress.Security.Resources.AccessSettings.DataResources.TrySetRules( DevExpress.Security.Resources.UrlAccessRule.Allow(), DevExpress.Security.Resources.DirectoryAccessRule.Deny()) ; if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")
// Style sheets cannot be loaded from file directories; only XML report layout serialization format is allowed bool success = DevExpress.Security.Resources.AccessSettings.ReportingSpecificResources.TrySetRules( DevExpress.Security.Resources.DirectoryAccessRule.Deny(), DevExpress.Security.Resources.SerializationFormatRule.Deny(SerializationFormat.Xml)) ; if (!success) System.Diagnostics.Debug.Print("Cannot change rules. The rules are already set.")
The TrySetRules(IAccessRules) method can be called only once at runtime to prevent you from overriding rules. You should call this method when the application starts, before a control (Web End-User ReportDesigner) sets its own rules. Otherwise, the TrySetRules(IAccessRules) method does not register the specified rule collection and returns false.
You can use the SetRules(IAccessRule) method to set access rules. This method raises an exception if the rules are set earlier (if the reporting control has already set its rules).
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the TrySetRules(IAccessRule) method.
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.