Class SentryCollection
Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.
Inherited Members
Namespace: SuperOffice.CRM.Security
Assembly: SoDataBase.dll
Syntax
public class SentryCollection : IEnumerable, ICloneable, ISentryIgnorable
Constructors
SentryCollection()
Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.
Declaration
public SentryCollection()
Properties
Count
Returns the number of sentries in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
IsSentryIgnored
Get value indicating whether sentry is ignored on the current object for the current thread.
Declaration
public bool IsSentryIgnored { get; }
Property Value
Type | Description |
---|---|
bool |
this[TableInfo]
Get Sentry from a TableInfo.
Declaration
public Sentry this[TableInfo tableInfo] { get; }
Parameters
Type | Name | Description |
---|---|---|
TableInfo | tableInfo |
Property Value
Type | Description |
---|---|
Sentry | Sentry for this TableInfo. If this sentry does not exist, null is returned. |
this[int]
Returns the correct Sentry-object based on the index (0-based).
Declaration
public Sentry this[int pos] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | pos | index of the sentry int he collection. |
Property Value
Type | Description |
---|---|
Sentry | Sentry at this index. |
Methods
Add(Sentry)
Adds a sentry to the collection, ex.
SentryCollection sc = new SentryCollection;
sc.Add( new ContactSentry() );
sc.Add( new ProjectSentry() );
sc.Add( new ContactSentry() ); // will be ignored - can't add same sentry type twice
Declaration
public void Add(Sentry sentry)
Parameters
Type | Name | Description |
---|---|---|
Sentry | sentry |
Add(SentryCollection)
Adds all the sentries in the collection to the collection, ex.
SentryCollection sc1 = new SentryCollection;
SentryCollection sc2 = new SentryCollection;
sc1.Add( new ContactSentry() );
sc2.Add( new ProjectSentry() );
sc1.Add( sc2 );
Declaration
public void Add(SentryCollection sentries)
Parameters
Type | Name | Description |
---|---|---|
SentryCollection | sentries |
AddLookup(ISoDataLookup)
Add the lookup to all the sentries in the collection
Declaration
public void AddLookup(ISoDataLookup lookup)
Parameters
Type | Name | Description |
---|---|---|
ISoDataLookup | lookup |
BeginIgnoreSentryCheck()
Starts the process of ignoring sentry on the object implementing the interface on the current thread.
Declaration
public IgnoreSentryCheck BeginIgnoreSentryCheck()
Returns
Type | Description |
---|---|
IgnoreSentryCheck | Disposable object that calls EndIgnoreSentryCheck() on Dispose. |
CanFieldDo(FieldInfo, EFieldRight)
Determine if the current user has at least one of the required access rights to a field belonging to the row this collection of sentries is protecting.
Checks each sentry in the collection to see if they have an opinion on the matter.
Declaration
public virtual bool CanFieldDo(FieldInfo field, EFieldRight rights)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | field | field we want to know about |
EFieldRight | rights | Rights we want to have to field |
Returns
Type | Description |
---|---|
bool | True if we have at least one of the rights to the field. |
CanFieldDoAll(FieldInfo, EFieldRight)
Determine if the current user has all of the required access rights to a field belonging to the row this collection of sentries is protecting.
Checks each sentry in the collection to see if they have an opinion on the matter.
Declaration
public virtual bool CanFieldDoAll(FieldInfo field, EFieldRight rights)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | field | field we want to know about |
EFieldRight | rights | Rights we want to have to field |
Returns
Type | Description |
---|---|
bool | True if we have all of the rights to the field. |
CanTableDo(TableInfo, ETableRight)
Determine if the current user has at least one of the required access rights to the row this sentry is protecting. Call each sentry in turn to see if it covers this table, and if so, ask its opinion and combine the results using the AND operation.
Declaration
public virtual bool CanTableDo(TableInfo table, ETableRight rights)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | table | the table we are interested in checking the rights to |
ETableRight | rights | one or more of the ETableRight values combined as bitflags |
Returns
Type | Description |
---|---|
bool | True if the user has at least one of the required access rights to the table. |
Examples
SentryCollection c = new SentryCollection(); c.Add( new ContactSentry() ); c.Add( new PersonSentry() ); bool canModify = c.CanTableDo( ETableRight.Insert & ETableRight.Update, false );
CanTableDoAll(TableInfo, ETableRight)
Determine if the current user has all of the required access rights to the row this sentry is protecting. Call each sentry in turn to see if it covers this table, and if so, ask its opinion and combine the results using the AND operation.
Declaration
public virtual bool CanTableDoAll(TableInfo table, ETableRight rights)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | table | the table we are interested in checking the rights to |
ETableRight | rights | one or more of the ETableRight values combined as bitflags |
Returns
Type | Description |
---|---|
bool | True if the user has all of the required access rights to the table. |
Examples
SentryCollection c = new SentryCollection(); c.Add( new ContactSentry() ); c.Add( new PersonSentry() ); bool canModify = c.CanTableDoAll( ETableRight.Insert & ETableRight.Update );
ClearRights()
Clear old data from the sentries, resetting the field-rights. Forces a recomputation of the rights using the new row-data.
Declaration
public void ClearRights()
EndIgnoreSentryCheck()
Ends the process of ignoring sentry on the object implementing the interface on the current thread.
Declaration
public void EndIgnoreSentryCheck()
FieldRight(FieldInfo)
Returns the fieldright for the given table.
Declaration
public FieldRight FieldRight(FieldInfo field)
Parameters
Type | Name | Description |
---|---|---|
FieldInfo | field | Field we want sentry information about |
Returns
Type | Description |
---|---|
FieldRight | Returns a new fieldright with full rights if the field is not covered by this sentry. |
Remarks
Always returns Update right (Read+Write) when IgnoreSentry is set.
GetEnumerator()
See MSDN-documentation for IEnumerator.
Declaration
public IEnumerator GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator | a new enumerator |
GetRowSentry()
Get a copy of the sentries holding the same references to table and field info.
Declaration
public SentryCollection GetRowSentry()
Returns
Type | Description |
---|---|
SentryCollection | Copy of the sentry collection with new sentries holding the original table and field infos. |
GetSentryCollectionForTable(TableInfo)
Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.
Declaration
public SentryCollection GetSentryCollectionForTable(TableInfo tableInfo)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | tableInfo |
Returns
Type | Description |
---|---|
SentryCollection |
GetSentryForTable(TableInfo)
Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.
Declaration
public Sentry GetSentryForTable(TableInfo tableInfo)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | tableInfo |
Returns
Type | Description |
---|---|
Sentry |
GetTableSentries(TableInfo)
Get all the sentries involved in the provided table. See remarks!
Declaration
public IEnumerable<Sentry> GetTableSentries(TableInfo table)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | table | Table to find sentries for. |
Returns
Type | Description |
---|---|
IEnumerable<Sentry> | Enumerator for sentries covering a given table. |
Remarks
The primary task is to a) find the sentry that covers this instance, i.e., this particular TableInfo object. As a fallback for historical reasons, if no such match can be found, we then b) go on to match on the Definition, which ignores instances in the query and aliasing and just looks for the 'same' table by number.
If that also fails, c) a further search is made using the CanCoverTable(TableInfo) method, looking for sentries that do not have this table as their primary, but still have opinions about the table. This is an important mechanism to cover dependent table (email dependent on person, for instance). In each case, multiple sentries can theoretically be present for a single table (don't think that happens in practice, but the design allows for it). However, once case a, b or c yields at least one sentry, the search stops.Remove(Sentry)
Remove the sentries from the collection
Declaration
public void Remove(Sentry sentry)
Parameters
Type | Name | Description |
---|---|---|
Sentry | sentry |
RemoveLookup(ISoDataLookup)
Remove the lookup from all the sentries in the collection
Declaration
public void RemoveLookup(ISoDataLookup lookup)
Parameters
Type | Name | Description |
---|---|---|
ISoDataLookup | lookup |
TableRight(TableInfo)
Returns the tableright for the given table, based on combining the rights from all the sentries in the collection. The most restrictive right is returned (the bitmasks are ANDed together).
The table right contains the rights mask and a reason why some rights are restricted.
Declaration
public TableRight TableRight(TableInfo table)
Parameters
Type | Name | Description |
---|---|---|
TableInfo | table |
Returns
Type | Description |
---|---|
TableRight | Will return a new tableright with full rights if the table is not covered by this sentry. |
ToString()
Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |