-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/actionbase #3917
base: main
Are you sure you want to change the base?
Refactor/actionbase #3917
Conversation
018ce3b
to
8214808
Compare
public Avatar GetAvatar(Address address) | ||
{ | ||
Info info = Call<InfoAction, Info>( | ||
"GetInfo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about using nameof(InfoAction.GetInfo)
instead of literal strings.
public void LoadPlainValue(IValue plainValue) | ||
{ | ||
Dictionary dict = (Dictionary)plainValue; | ||
_name = (Text)dict["name"]; | ||
_name = (Text)dict["type_id"]; | ||
_call = (Text)dict["call"]; | ||
_args = dict["args"]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a pattern like below?
void IAction.LoadPlainValue(IValue plainValue)
{
if (_isLoaded)
{
throw new InvalidOperationException("Action is already loaded.");
}
Dictionary dict = (Dictionary)plainValue;
_name = (Text)dict["type_id"];
_exec = (Text)dict["exec"];
_args = dict["args"];
_isLoaded = true;
}
It has two advantages: limited access and avoiding duplicate calls.
No description provided.