Skip to content
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

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

greymistcube
Copy link
Contributor

No description provided.

public Avatar GetAvatar(Address address)
{
Info info = Call<InfoAction, Info>(
"GetInfo",
Copy link
Contributor

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.

Comment on lines 18 to 24
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"];
}
Copy link
Contributor

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.

@greymistcube greymistcube self-assigned this Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants