Interface Type: Difference between revisions

From Resonite Wiki
Added page explaining interface types (to be linked on individual interface types pages)
 
mNo edit summary
Line 1: Line 1:
Interface types are [[Reference Types|reference types]] that don't refer to a specific [[Component|component]], but a [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface C# Interface] that can be implemented by one or multiple component classes. Interfaces are used to describe a specific common behavior that similar classed may want to implement. Because clases that implement a specific interface are required to implement the methods and properties defined in that interface, they can all be assigned to a variable of the interface type, making them very userful within Resonite.
Interface types are [[Reference Type|reference types]] that don't refer to a specific [[Component|component]], but a [https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface C# Interface] that can be implemented by one or multiple component classes. Interfaces are used to describe a specific common behavior that similar classed may want to implement. Because clases that implement a specific interface are required to implement the methods and properties defined in that interface, they can all be assigned to a variable of the interface type, making them very userful within Resonite.


{{Note|In C# it is convention to start interface class names with the capital letter 'I'.|information}}
{{Note|In C# it is convention to start interface class names with the capital letter 'I'.|information}}

Revision as of 00:07, 19 January 2024

Interface types are reference types that don't refer to a specific component, but a C# Interface that can be implemented by one or multiple component classes. Interfaces are used to describe a specific common behavior that similar classed may want to implement. Because clases that implement a specific interface are required to implement the methods and properties defined in that interface, they can all be assigned to a variable of the interface type, making them very userful within Resonite.

In C# it is convention to start interface class names with the capital letter 'I'.

Example

An example of an interface type used within Resonite is IButton. It is implemented by multiple button-like components like Button, PhysicalButton and TouchButton. All of those components implement the behavior of a button that can be pressed as defined in IButton. Because of this, you can use either of them as a valid reference to plug into the "Button" input of the Button Events ProtoFlux node, which requires a global of type IButton.