Show / Hide Table of Contents

Class SentryCollection

Collects zero or more sentries together in an group. Makes it easy to perform aggregated queries across the collection.

Inheritance
Object
SentryCollection
Implements
IEnumerable
ICloneable
ISentryIgnorable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.CRM.Security
Assembly: SoDataBase.dll
Syntax
public class SentryCollection : IEnumerable, ICloneable, ISentryIgnorable

Constructors

SentryCollection()

Declaration
public SentryCollection()

Properties

Count

Returns the number of sentries in the collection.

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

IsSentryIgnored

Declaration
public bool IsSentryIgnored { get; }
Property Value
Type Description
Boolean

Item[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.

Item[Int32]

Returns the correct Sentry-object based on the index (0-based).

Declaration
public Sentry this[int pos] { get; set; }
Parameters
Type Name Description
Int32 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()

Declaration
public IgnoreSentryCheck BeginIgnoreSentryCheck()
Returns
Type Description
IgnoreSentryCheck

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
Boolean

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
Boolean

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
Boolean

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
Boolean

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()

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)

Declaration
public SentryCollection GetSentryCollectionForTable(TableInfo tableInfo)
Parameters
Type Name Description
TableInfo tableInfo
Returns
Type Description
SentryCollection

GetSentryForTable(TableInfo)

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()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()

Explicit Interface Implementations

ICloneable.Clone()

Declaration
object ICloneable.Clone()
Returns
Type Description
Object

Implements

System.Collections.IEnumerable
System.ICloneable
ISentryIgnorable

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