diff --git a/lib/src/Net/IIP/DistributedResource.dart b/lib/src/Net/IIP/DistributedResource.dart index 90797c9..cabc73b 100644 --- a/lib/src/Net/IIP/DistributedResource.dart +++ b/lib/src/Net/IIP/DistributedResource.dart @@ -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); + } + /// /// Set property value. /// diff --git a/lib/src/Proxy/TemplateGenerator.dart b/lib/src/Proxy/TemplateGenerator.dart index ef66303..c923d79 100644 --- a/lib/src/Proxy/TemplateGenerator.dart +++ b/lib/src/Proxy/TemplateGenerator.dart @@ -521,7 +521,7 @@ class TemplateGenerator { var ptTypeName = getTypeName(template, p.valueType, templates); rt.writeln("${ptTypeName} get ${p.name} { return get(${p.index}); }"); 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) {