Skip to content

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