Transparent Proxy is a rapid development feature eliminating the need to author commands and queries. The proxy acts like an instance of your model. It intercepts method calls and maps to command and query objects of type
ProxyQuery which are then passed to an instance of
The easiest way to create a proxy is using
Which is actually just short for:
Here’s what’s happening under the hood:
ProxyCommandcontaining the method signature and arguments
IEngine<T>instance owned by the proxy
The exact same thing happens with queries, except
ProxyQuery is used
The proxy has the same type as the model, but not all members are supported. The following rules apply:
Void methods are interpreted as commands, non-void methods as queries. If a command method is non-void it must be tagged with a
CommandAttribute, otherwise it will be interpreted as a query.
If your command or query returns results that don’t need to be cloned, use the
Make sure that method input and output (arguments and return value) is serializable.
Just because it’s easy doesn’t mean you can pretend every method call is local. Prefer a chunky over a chatty interaction between your client code and proxy.
Remember that objects returned from queries are copies. The following code will not work as intended because the object returned by
GetReminder() is a copy of the real object.
Prior to verion 0.18, overloads were not supported. Only method names were used to identify method calls. If you introduce overloads to system with journal entries created prior to v0.18, you must use
IsDefault on the original method.
Commands and queries are mapped to
ProxyQuery objects. You can map to user defined types with the MapTo property. The type must have a constructor taking the same arguments as the method.
To exclude a method from being proxied, add a
Properties in NET are just syntactic sugar. Getters and setters are compiled into methods. Everything that applies to methods apply to setters and getters as well. This means you can use the attributes described above on setters and getter of properties and indexers:
NoProxy‘Can also be applied to a properties getter or setter: