Class AppState
A complete App state - usually cached in memory.
Has many internal features for partial updates etc.
But the primary purpose is to make sure the whole app is always available with everything.
It also manages and caches relationships between entities of the same app.
Implements
Inherited Members
Namespace: ToSic.Eav.Apps
Assembly: ToSic.Eav.Core.dll
Syntax
[InternalApi_DoNotUse_MayChangeWithoutNotice("this is just fyi")]
public class AppState : AppBase<MyServicesEmpty>, IHasLog, IMetadataSource, ICacheExpiring, ITimestamped, IAppIdentity, IZoneIdentity, IAppIdentityLight, IHasMetadata
Fields
| Improve this Doc View SourceDynamicUpdatesCount
Show how many times the app has been Dynamically updated - in case we run into cache rebuild problems.
Declaration
public int DynamicUpdatesCount
Field Value
Type | Description |
---|---|
int |
FirstLoadCompleted
Shows that the initial load has completed
Declaration
protected bool FirstLoadCompleted
Field Value
Type | Description |
---|---|
bool |
Loading
Shows that the app is loading / building up the data.
Declaration
protected bool Loading
Field Value
Type | Description |
---|---|
bool |
Properties
| Improve this Doc View SourceCacheTimestamp
System time-stamp of when the data in this cached thing was initialized or updated. Depending on the implementation, this may go up-stream and return an up-stream value.
Declaration
public long CacheTimestamp { get; }
Property Value
Type | Description |
---|---|
long | A timestamp as a long number |
ContentTypes
All ContentTypes in this App
Declaration
public IEnumerable<IContentType> ContentTypes { get; }
Property Value
Type | Description |
---|---|
IEnumerable<IContentType> |
Folder
The app-folder, which is pre-initialized very early on. Needed to pre-load file based content-types
Declaration
public string Folder { get; set; }
Property Value
Type | Description |
---|---|
string |
List
The simple list of all entities, used everywhere
Declaration
public IImmutableList<IEntity> List { get; }
Property Value
Type | Description |
---|---|
IImmutableList<IEntity> |
Metadata
Metadata describing this App
Declaration
public IMetadataOf Metadata { get; }
Property Value
Type | Description |
---|---|
IMetadataOf |
Name
The app-folder, which is pre-initialized very early on. Needed to pre-load file based content-types
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
Relationships
Manages all relationships between Entities
Declaration
public AppRelationshipManager Relationships { get; }
Property Value
Type | Description |
---|---|
AppRelationshipManager |
Methods
| Improve this Doc View SourceCacheChanged(long)
Detect if the cache has newer data. It's called using the TimeStamp of the dependent object which may still have old data.
Declaration
public bool CacheChanged(long dependentTimeStamp)
Parameters
Type | Name | Description |
---|---|---|
long | dependentTimeStamp | New time stamp of a dependent object, which could have an older timestamp. |
Returns
Type | Description |
---|---|
bool | True if the timestamps differ, false if it's the same |
Remarks
This is implemented in each object, because sometimes it compares its own timestamp, sometimes that of another underlying object.
DoInLock(ILog, Action)
Experiment to try to ensure the same entity cannot be created twice
Declaration
public void DoInLock(ILog parentLog, Action transaction)
Parameters
Type | Name | Description |
---|---|---|
ILog | parentLog | |
Action | transaction |
GetContentType(int)
Get a content-type by number / id. Will also check global types if needed.
Declaration
[PublicApi]
public IContentType GetContentType(int contentTypeId)
Parameters
Type | Name | Description |
---|---|---|
int | contentTypeId | id of the type as stored in the repository |
Returns
Type | Description |
---|---|
IContentType | a type object or null if not found |
GetContentType(string)
Get a content-type by name. Will also check global types if needed.
Declaration
[PublicApi]
public IContentType GetContentType(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | name of the type |
Returns
Type | Description |
---|---|
IContentType | a type object or null if not found |
GetMetadata<TMetadataKey>(int, TMetadataKey, string)
Get any metadata from the current data source (usually an app)
Declaration
public IEnumerable<IEntity> GetMetadata<TMetadataKey>(int targetType, TMetadataKey key, string contentTypeName = null)
Parameters
Type | Name | Description |
---|---|---|
int | targetType | The type-id of the target we're accessing, like 10=cms-object, 4=entity |
TMetadataKey | key | The key which is used for lookup |
string | contentTypeName | Optional content-type name, to only retrieve metadata of that type |
Returns
Type | Description |
---|---|
IEnumerable<IEntity> | A list (may be empty) of metadata items found for this target |
Type Parameters
Name | Description |
---|---|
TMetadataKey |
Remarks
It does not return metadata describing the source (app), but metadata stored in this app, describing something else.
GetMetadata<TKey>(TargetTypes, TKey, string)
Get any metadata from the current data source (usually an app)
Declaration
public IEnumerable<IEntity> GetMetadata<TKey>(TargetTypes targetType, TKey key, string contentTypeName = null)
Parameters
Type | Name | Description |
---|---|---|
TargetTypes | targetType | The TargetTypes constant of the target we're accessing, like TargetTypes.Entity |
TKey | key | The key which is used for lookup |
string | contentTypeName | Optional content-type name, to only retrieve metadata of that type |
Returns
Type | Description |
---|---|
IEnumerable<IEntity> | A list (may be empty) of metadata items found for this target |
Type Parameters
Name | Description |
---|---|
TKey | Key-Type used - string, int or guid |
Remarks
It does not return metadata describing the source (app), but metadata stored in this app, describing something else.