Class RestrictionHelper
Helper class for handling restrictions in the archive list system
Inherited Members
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public class RestrictionHelper
Constructors
RestrictionHelper()
Helper class for handling restrictions in the archive list system
Declaration
public RestrictionHelper()
Properties
Count
Get the number of valid restrictions tracked by the helper
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
FieldColumnBindings
Helper class for handling restrictions in the archive list system
Declaration
public Dictionary<string, FieldInfo> FieldColumnBindings { get; }
Property Value
Type | Description |
---|---|
Dictionary<string, FieldInfo> |
Restrictions
Get an enumerator over all current restrictions
Declaration
public IEnumerable<ArchiveRestrictionInfo> Restrictions { get; }
Property Value
Type | Description |
---|---|
IEnumerable<ArchiveRestrictionInfo> |
Methods
AddRestrictions(ArchiveRestrictionInfo[], List<ArchiveColumnInfo>)
Add one or more restrictions to be tracked by the helper, subject to their being one of the otherwise known columns
Declaration
public bool AddRestrictions(ArchiveRestrictionInfo[] restrictions, List<ArchiveColumnInfo> columns)
Parameters
Type | Name | Description |
---|---|---|
ArchiveRestrictionInfo[] | restrictions | Restrictions to add |
List<ArchiveColumnInfo> | columns | Names of valid restrictions |
Returns
Type | Description |
---|---|
bool | true if at least one restriction name matched a valid column |
Remarks
A restriction is valid if it matches a known column, and that column has its CanRestrictBy attribute set to true. The caller will usually be a column provider/extender, who gets a list of valid restriction columns from its ColumnHelper.
AddRestrictions(ArchiveRestrictionInfo[], string[])
Add one or more restrictions to be tracked by the helper, subject to their being one of the otherwise known columns
Declaration
public bool AddRestrictions(ArchiveRestrictionInfo[] restrictions, string[] columnNames)
Parameters
Type | Name | Description |
---|---|---|
ArchiveRestrictionInfo[] | restrictions | Restrictions to add |
string[] | columnNames | Names of valid restrictions |
Returns
Type | Description |
---|---|
bool | true if at least one restriction name matched a valid column |
Remarks
A restriction is valid if it matches a known column, and that column has its CanRestrictBy attribute set to true. The caller will usually be a column provider/extender, who gets a list of valid restriction columns from its ColumnHelper.
AddUnconditionalRestriction(ArchiveRestrictionInfo)
Add a restriction unconditionally
Declaration
public void AddUnconditionalRestriction(ArchiveRestrictionInfo restriction)
Parameters
Type | Name | Description |
---|---|---|
ArchiveRestrictionInfo | restriction |
GetAndDropRestriction(string)
Helper class for handling restrictions in the archive list system
Declaration
public ArchiveRestrictionInfo GetAndDropRestriction(string restrictionName)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName |
Returns
Type | Description |
---|---|
ArchiveRestrictionInfo |
GetAndDropRestrictions(string)
Get a restriction, and if it exists, drop it from the list of restrictions (so this method works once per restriction :-) )
Declaration
public List<ArchiveRestrictionInfo> GetAndDropRestrictions(string restrictionName)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Restriction to look for |
Returns
Type | Description |
---|---|
List<ArchiveRestrictionInfo> | restriction, or null if it was not found |
GetRestriction(string)
Helper class for handling restrictions in the archive list system
Declaration
public ArchiveRestrictionInfo GetRestriction(string restrictionName)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName |
Returns
Type | Description |
---|---|
ArchiveRestrictionInfo |
GetRestrictions(string)
Get a named restriction
Declaration
public List<ArchiveRestrictionInfo> GetRestrictions(string restrictionName)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Restriction to look for |
Returns
Type | Description |
---|---|
List<ArchiveRestrictionInfo> | restriction, or null if it was not found |
GetUniqueIdRestriction(string, string)
Scan the given restriction array to find the given restriction; require it to have an equals or = operator; parse the single scalar value as an int and return it. This is a very common case, where a restriction on a single id is used.
Declaration
public int GetUniqueIdRestriction(string restrictionName, string exceptionText)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Case-insensitive name of restriction to find |
string | exceptionText | Text for exception if the restriction does not exist. If this parameter is null, then no exception will be thrown and the integer value 0 will be returned instead |
Returns
Type | Description |
---|---|
int | Integer value if found, or either 0 or an exception if not found, depending on the exceptiontext parameter |
Exceptions
Type | Condition |
---|---|
SoIllegalOperationException | Thrown if the restriction does not exist, using the given text |
HasAnyRestriction(List<ArchiveColumnInfo>)
Is at least one of the given restrictions present (fast lookup, O(n) where n=restrictions to look for)
Declaration
public bool HasAnyRestriction(List<ArchiveColumnInfo> columns)
Parameters
Type | Name | Description |
---|---|---|
List<ArchiveColumnInfo> | columns |
Returns
Type | Description |
---|---|
bool | true if at least one the given restrictions exist |
HasAnyRestriction(List<string>)
Is at least one of the given restrictions present (fast lookup, O(n) where n=restrictions to look for)
Declaration
public bool HasAnyRestriction(List<string> restrictionNames)
Parameters
Type | Name | Description |
---|---|---|
List<string> | restrictionNames | Non-null list of restrictions to look for |
Returns
Type | Description |
---|---|
bool | true if at least one the given restrictions exist |
HasRestriction(string)
Is a certain restriction present (fast lookup, O(1))
Declaration
public bool HasRestriction(string restrictionName)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Name of restriction to search for |
Returns
Type | Description |
---|---|
bool | true if restriction exists |
ProcessRestrictions(ArchiveSelect)
Process restrictions - update the query automatically for field-mapped restrictions, and call custom delegates for those that have custom mappings
Declaration
public bool ProcessRestrictions(ArchiveSelect targetQuery)
Parameters
Type | Name | Description |
---|---|---|
ArchiveSelect | targetQuery | Query to modify |
Returns
Type | Description |
---|---|
bool | true if at least one restriction was processed |
SetColumnBinding(string, FieldInfo)
Bind a restriction to a database column, for automatic processing
Declaration
public void SetColumnBinding(string restrictionName, FieldInfo binding)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Restriction name |
FieldInfo | binding | Field to bind to |
SetCustomBinding(string, ProcessCustomRestriction)
Bind a restriction to a custom processing delegate
Declaration
public void SetCustomBinding(string restrictionName, RestrictionHelper.ProcessCustomRestriction binding)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Restriction name |
RestrictionHelper.ProcessCustomRestriction | binding | Method to call to process this restriction |
SetCustomBindingByBaseName(string, ProcessCustomRestriction)
Bind a restriction to a custome processing delegate, using only the base part of the restriction name
Declaration
public void SetCustomBindingByBaseName(string restrictionName, RestrictionHelper.ProcessCustomRestriction binding)
Parameters
Type | Name | Description |
---|---|---|
string | restrictionName | Restriction base name |
RestrictionHelper.ProcessCustomRestriction | binding | Method to call to process this restriction |
ToString()
Return a string representation suitable for debugging
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |