2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2026-04-03 17:58:21 +00:00
This commit is contained in:
2024-06-22 03:50:54 +03:00
parent 8a30c92e19
commit 26794f08e7
32 changed files with 1508 additions and 595 deletions

View File

@@ -14,6 +14,7 @@ class FactoryEntry<T> {
final Function instanceCreator;
final Function arrayCreator = () => <T>[];
final RepresentationType representationType;
final Function mapCreator = () => Map<T, dynamic>();
bool isMapKeySubType(Map map) {
return map is Map<T, dynamic>;

View File

@@ -31,7 +31,7 @@ import '../Data/PropertyValue.dart';
// old
// abstract class IStore extends IResource
// new
abstract mixin class IStore implements IResource {
abstract class IStore implements IResource {
AsyncReply<IResource?> get(String path);
// AsyncReply<IResource?> retrieve(int iid);
AsyncReply<bool> put(IResource resource);

View File

@@ -482,7 +482,8 @@ class Instance extends IEventHandler {
if (pi.parents.count == 0) break;
p = pi.parents.firstOrNull!;
p = pi.parents.first;
}
return l.join("/");

View File

@@ -510,6 +510,11 @@ class Warehouse {
return _factory[type]?.arrayCreator.call() as List<T>;
}
static Map<T, dynamic> createMap<T>(Type keyType) {
return _factory[keyType]?.mapCreator.call() as Map<T, dynamic>;
}
static AsyncReply<T> newResource<T extends IResource>(String name,
[IStore? store = null,
IResource? parent = null,
@@ -759,6 +764,8 @@ class Warehouse {
RepresentationType(RepresentationTypeIdentifier.Int64, false)))
..addAll(_getTypeEntries<bool>(() => false,
RepresentationType(RepresentationTypeIdentifier.Bool, false)))
..addAll(_getTypeEntries<Float32>(() => 0.0,
RepresentationType(RepresentationTypeIdentifier.Float64, false)))
..addAll(_getTypeEntries<double>(() => 0.0,
RepresentationType(RepresentationTypeIdentifier.Float64, false)))
..addAll(_getTypeEntries<String>(() => "",