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.

System.Object
   Attribute
      GPStateMethodAttribute
         GPStateParameterlessMethodAttribute

[Visual Basic]
Public Class GPStateMethodAttribute
    Inherits 
    Implements IGPMethodAttribute
[C#]
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.

Remarks

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.

Example

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)
    {
        AccountsOn.Add(a);
    }
    public void TurnOff(SqlAccount a)
    {
        AccountsOn.Remove(a);
    }
    public string IDoStuffState(SqlAccount a)
    {
        return (AccountsOn.Contains(a) ? "On" : "Off");
    }
}

Requirements

Namespace: GPCore.Attributes

Assembly: GPCore (in GPCore.dll)

See Also

GPStateMethodAttribute Members | GPCore.Attributes Namespace