2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2025-05-06 12:02:57 +00:00
This commit is contained in:
Esiur Project 2022-08-27 00:42:01 +03:00
parent 05518b33d7
commit 8b9ce591c5
2 changed files with 16 additions and 1 deletions

View File

@ -359,6 +359,21 @@ class DistributedResource extends IResource {
} }
} }
dynamic setSync(int index, dynamic value) async {
if (_destroyed) throw new Exception("Trying to access a destroyed object.");
if (_suspended) throw new Exception("Trying to access a suspended object.");
if (!_attached) return null;
if (index >= _properties.length)
throw Exception("Property with index `${index}` not found.");
if (_properties[index] == value) return value;
return await set(index, value);
}
/// <summary> /// <summary>
/// Set property value. /// Set property value.
/// </summary> /// </summary>

View File

@ -521,7 +521,7 @@ class TemplateGenerator {
var ptTypeName = getTypeName(template, p.valueType, templates); var ptTypeName = getTypeName(template, p.valueType, templates);
rt.writeln("${ptTypeName} get ${p.name} { return get(${p.index}); }"); rt.writeln("${ptTypeName} get ${p.name} { return get(${p.index}); }");
rt.writeln( rt.writeln(
"set ${p.name}(${ptTypeName} value) { set(${p.index}, value); }"); "set ${p.name}(${ptTypeName} value) { setSync(${p.index}, value); }");
}); });
template.events.where((e) => !e.inherited).forEach((e) { template.events.where((e) => !e.inherited).forEach((e) {