How to get the component instance when right-clicking to show its context menu?

How to get the corresponding component instance (in the following example, the Light component) when right-clicking to expand the component’s context menu?

This MenuItem is not written in the component’s own code, so the component instance cannot be obtained using this. Therefore, I am curious if there is a global property in Unity similar to Selection.activeObject that returns the component corresponding to the current context menu.

9901971--1430385--upload_2024-6-21_21-35-24.png

Resolved:

[MenuItem("CONTEXT/Component/YOUR_MENU_NAME")]
public static void Func(MenuCommand command)
{
    if (command.context is Component component)
    {
        // Do something
    }
}