Show / Hide Table of Contents

Class RestrictionHelper

Helper class for handling restrictions in the archive list system

Inheritance
Object
RestrictionHelper
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.ArchiveLists
Assembly: SoDataBase.dll
Syntax
public class RestrictionHelper

Constructors

RestrictionHelper()

Declaration
public RestrictionHelper()

Properties

Count

Get the number of valid restrictions tracked by the helper

Declaration
public int Count { get; }
Property Value
Type Description
Int32

FieldColumnBindings

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
Boolean

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
Boolean

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)

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)

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
Int32

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
Boolean

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
Boolean

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
Boolean

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
Boolean

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, RestrictionHelper.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, RestrictionHelper.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
Overrides
Object.ToString()

Extension Methods

EnumUtil.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
Converters.MapEnums<From, To>(From)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top