Open huoshan12345 opened 3 years ago
This is a good suggestion and can be implemented. But this involves the depth of the class, and the scheme may affect performance. Do you have any more detailed suggestions?
@alexinea I think we can support it on Leo. But it is not a high-performance implementation, there will be the loss of string parsing. If we put linked calls into the BTF dictionary, this will cause a lot of trouble, such as linked lists. Will this affect Typed if I store B in a new leo instance?
We need to solve the problem of circular references:
class A{
public B One {get;set;}
}
class B{
public B(A a) => Two = a;
public A Two {get;}
}
When creating the Leo instance of B, will you create the Leo instance of A again in a loop? If you give me the Leo instances of A and B at the same time, and specify the relationship between them, then it should not be a problem to add support for the Typed component.
Maybe we can use an interface like v["B", "name"]
I think this requirement is great. We can try it.
V ["B", "name"] this has changed the user's original intention, they hope that B.name, in fact, string parsing and new leo objects have lost performance, maybe we need to use the BTF dictionary to learn the user's calls and dynamically generate delegates.
@huoshan12345 After discussion, this feature will be transferred to LeoVisitor. The Leo layer will not support this feature because Leo is currently a complete minimum operating unit. If the relevant code is not configured, this feature may upset the existing performance balance. This feature brings high complexity.
@NMSAzulX Thanks very much. That's will be exciting if this feature is added.
Some ideas:
If a path is used, the member access operator (or member separator) should be chosen carefully.
A single dot(i.e. A.B
) is a common choice. However it may be ambiguous because it is actually an allowed-character for an identifier of a property/field of a type that created dynamically.
The []
operator for members of IList<T>
can be considered to support.
e.g. SomeClass.SomeList[2].SomeField
We supported it experimentally. The current limited support is the form A.B.C
for the GetValue method
Like:
Currently, this feature does not support arrays, nor does it support the SetValue method (this involves synchronization of objects).
Hi all, Leo is a great lib. I would like to request a feature that a value can be gotten or set by path for nested class. For example
Thank you for consideration.