GPCore - The Gibphone API

GPStateMethodAttribute Class

Use this attribute when defining you own Interface to extend Protocol if you want to allow other people to add a method as an "Action" to a menu, and the method should only be activated in in a certain state.

For a list of all members of this type, see GPStateMethodAttribute Members.


[Visual Basic]
Public Class GPStateMethodAttribute
    Implements IGPMethodAttribute
public class GPStateMethodAttribute : Attribute, IGPMethodAttribute

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.


This should be used for exposing methods to plugins that dont need to know anything about it, except its existence. If this attribute is present in the interface a method must be also be present with the name of the interface plus "State" with its parameters being the same as this methods, to check for the State of the object to know if it should be displayed now.


Here is a sample Interface and its implementation.

public interface IDoStuff
    [GPStateMethod("Turn On","Account","On",false)]
    void TurnOn(SqlAccount a);
    [GPStateMethod("Turn Off","Account","On",true)]
    void TurnOff(SqlAccount a);
    string IDoStuffState(SqlAccount a);
public class DoStuff : IDoStuff
    List<SqlAccount> AccountsOn = new List<SqlAccount>
    public void TurnOn(SqlAccount a)
    public void TurnOff(SqlAccount a)
    public string IDoStuffState(SqlAccount a)
        return (AccountsOn.Contains(a) ? "On" : "Off");


Namespace: GPCore.Attributes

Assembly: GPCore (in GPCore.dll)

See Also

GPStateMethodAttribute Members | GPCore.Attributes Namespace