[ROOT] / doc / toc / ARCCore / Class / IP
AddOrUpdateP , AddP , AddPV , AllIPDerivedEntityCollectionClassesDict , AllIPDerivedTypes , AllIPDerivedTypesDict , AllIPDerivedTypesDictIKType , AllIPDerivedTypesInludingGenericAndAbstract , AllIPDerivedTypesWithPKEnum , AllIPDerivedTypesWithPKEnumApplicationSpecific , AssertIntegrity , Dec , DeepCopy , GetKeysEqualToValue , GetOrAddPV , GetPV , GetValueForJSONSerializer , HandleException , Inc , Initialize , IsValid , Item , Keys , Log , LogExecuteTime , Logger , OnTrySetP , ToJSONSerializeable , ToPropertyStream , ToString , TryAssertIntegrity , TryGetP , TryGetPV , TryGetV , TryParseDtr , TrySetP , TrySetPP , Values
IP = IProperty.
Common central mechanism for implementing PropertyAccess.
'Everything' in your application, especially entity classes (like 'Customer', 'Order' and so on) but also classes which are (in a hierarchical sense) over and under the entity level,
should implement this interface.
Examples of classes implementing this interface as seen from a hierarchical storage viewpoint:
PCollection: Collection of objects, like CustomerCollection.
PRich: Customer object.
PValue<T>: Customer.FirstName.
(note that the topmost level containing all collections should also implement this interface, this can be accomplished with the universal PRich class.)
You should also let internal parts of your application implement this interface. This will make logging and debugging much easier for instance (see ExposingApplicationState).
Methods that must be implemented are:
TrySetP
TryGetP
TryGetV
-GetEnumerator-
and also:
DeepCopy
TryRemoveP
OnTrySetP
TrySetPP
GetKeysEqualToValue
Some of the implementing classes in ARCCore are:
PRich Fully flexible storage. Can store anything. Typical inherited for entity representations like 'Customer' or 'Order'.
PExact<TEnumType> Very MemoryConsumption efficient alternative to PRich.
PConcurrent A (somewhat) thread-safe alternative to PRich which also supports ExposingApplicationState.
PValue<T> Single value storage.
PValueEmpty.
PCollection A class useful for storing a collection of entities (a table in RDBMS-terms) because it implements Indexing.
PReadOnly Experimental as of Feb 2022.
Use these as base classes for your own entities and properties in your ApplicationSpecificCode.
In ARCCore there is also -PCollectionES- which supports EventSourcing.
NOTE: Some ideas for new classes implementing this interface could be:
1) PRichImmutable, a quasi-immutable class for which you could (after initialization) set a flag stopping further updates to the class.
(The difference between ITypeDescriber and IP is that the former must be stored 'inside' an IP.
In RDBMS-terms a ITypeDescriber is the Field stored within a IP which is the Post.)
The more classes you have implementing this interface, the more classes you have that can participiate in the AgoRapide world with flexible concepts like PropertyStream, TaggingOfPropertyKeys, PropertyAccess, ExposingApplicationState.
The mechanism has been designed to be as flexible as possible. Experience shows that a great variety of objects can with great advantage be represented through this mechanism. That is, not only traditional entities like 'Customer', 'Order' and so on can be represented but also objects like internal parts of your application (classes, enums),
the different methods in an API and even reports and aggregations.
(Even the mechanism for describing this mechanism (PK) is an implementation of it).
HINT: Whenever you are creating a new class in your application, instead of using traditional setters and getters / traditional properties, let class inherit IP and use this mechanism instead.
Using IP from the start makes the rich functionality of AgoRapide available without much work. (You can always build traditional setters and getters and / or traditional property storage on top of that mechanism at a later stage if you so prefer)
Reflecting the fact that instances of this interface often contain a collection of objects, this interface implements the following:
1) Indexing. Enables you to query more 'direct' in C# like for instance 'DataStorage["Customer"]["42"]["FirstName"]'.
2) IEnumerable<IKIP>.
3) The Keys and Values pattern from ordinary .NET Dictionary (see Keys and Values.
This functionality is of course not relevant for value only implementations like PValue<T> but technically implemented nonetheless in all cases in order for any hierarchical structure to be 'probed' from the outside in a standardized manner.
TODO: Implement IDictionary<TKey, TValue> also..
See also PropertyAccess.
TODO: Regarding default interface methods defined here in this interface
TODO: and the need for implementing an 'IP' property in implementing classes like IP.
TODO: As AgoRapide matures, considering implementing copies of the default interface methods in a common super class
TODO: for PRich, PConcurrent, PExact (not necessary for PValue, PEmpty and not possible for BaseAttribute).
Note how AgoRapide internally uses this same mechanism ('eating its own dog food'), and also how you are encouraged to document your application through attributes like ClassAttribute and ClassMemberAttribute using the same mechanism.
Note about packing of values: PropertyAccess uses packed values (everything is sent and received as IP) meaning for instance that a string-value would typically be packed inside a PValue<T> object.
Connected with this, classes implementing IP have a choice between
1) Unpacking on receive, packing on send (like used by PExact<TEnumType>) or
2) Storing in packed form (like used by PRich).
The former is more memory efficient (see MemoryConsumption), but less able to store metadata (see PP) and hierarchical data.
(see also PackObjectForStorageInEntityObject and TryGetV.)
See also ITypeDescriber which provides a standardized mechanism for describing single-property values.
AddOrUpdateP | Duplicates functionality of SetP. |
AddP | Adds a property for this object. |
AddPV | 2 items |
AllIPDerivedEntityCollectionClassesDict | All IP-derived types for which is found a corresponding class with name like '{EntityType}Collection' |
AllIPDerivedTypes | All relevant IP-derived types for the whole application. |
AllIPDerivedTypesDict | Provides lookup of a type in AllIPDerivedTypes given its string representation. |
AllIPDerivedTypesDictIKType | Same as AllIPDerivedTypesDict except that value is IKType, not string. |
AllIPDerivedTypesInludingGenericAndAbstract | All relevant IP-derived types (except the interface IP itself) known to the application. |
AllIPDerivedTypesWithPKEnum | All relevant IP-derived types for the whole application for which the also is defined a PropertyKeyEnum. |
AllIPDerivedTypesWithPKEnumApplicationSpecific | All relevant IP-derived types for the ApplicationSpecificCode part of the application for which also is defined a PropertyKeyEnum. |
AssertIntegrity | See TryAssertIntegrity. |
Dec | Decrements given property key by 1. Sets to -1 if not found. Uses long, not integer. |
DeepCopy | Creates a deep copy of this object instance, that is, a copy with all new object instances (except for immutable objects). |
GetKeysEqualToValue | Returns properties which themselves again have key and value equal to the given key and value. |
GetOrAddPV | Gets value. If not set then value will be added |
GetPV | Gets a single property's value for this object. Returns default value if not successful. |
GetValueForJSONSerializer | Practical approach to serializing of IP based values to JSON. |
HandleException | Note that most relevant to use for PConcurrent. |
Inc | Increments given property key by 1. Sets to 1 if not found. Uses long, not integer. |
Initialize | Note that has a default implementation (doing nothing). |
IsValid | Note that by default all properties are 'valid' but because of NoRealDeletion, we must have a mechanism for invalidating properties. This property returns FALSE if property has been invalidated and timestamp for invalidation is not '0001-01-01'. |
Item | Offers string-based direct indexing. |
Keys | Returns all the keys for this instance. |
Log | The 'final' overload of Log that is called by the other overloads. |
LogExecuteTime | Times the execution of the given function and logs details about elapsed time. |
Logger | Describes a logger. |
OnTrySetP | Event handler to be called by TrySetP before it changes a property value (but AFTER it has done any validity checks, that is, after it has 'decided' to return TRUE, in other words, event handler should be called when change is guaranteed to go through, but before it actually has been done). |
ToJSONSerializeable | Prepares the data into a format acceptable for System.Text.Json.JsonSerializer.Serialize. |
ToPropertyStream | Turns object into a PropertyStream |
ToString | The ToString()-implementation in the classes implementing this interface is supposed to give a short concise representation of the object for debugging and logging purposes, that is, intended for human consumption. The most 'important' implementation is probably the one in PRich (ToString) because that one is often the basis for your entity classes like 'Customer', 'Order' and so on |
TryAssertIntegrity | Asserts the integrity of this entity. |
TryGetP | Gets a single property for this object |
TryGetPV | Gets a single property's value for the given property key. |
TryGetV | 2 items |
TryParseDtr | Parses a PropertyStreamLine- beginning with dtr. |
TrySetP | Set property regardless of whether exists or not. |
TrySetPP | SetPP = set property of property. Sets property of entity contained within this class. |
Values | Returns all the values (all the properties) for this instance. |
Generated 2024-11-11 13:57:44.436 UTC