#nullable disable using System; using System.Collections.Generic; using System.Reflection; namespace SMAPI.Tests.ModApiProvider.Framework { /// A mod-provided API which provides basic events, properties, and methods. public class SimpleApi : BaseApi { /********* ** Test interface *********/ /**** ** Events ****/ /// A simple event field. public event EventHandler OnEventRaised; /// A simple event property with custom add/remove logic. public event EventHandler OnEventRaisedProperty { add => this.OnEventRaised += value; remove => this.OnEventRaised -= value; } /**** ** Properties ****/ /// A simple numeric property. public int NumberProperty { get; set; } /// A simple object property. public object ObjectProperty { get; set; } /// A simple list property. public List ListProperty { get; set; } /// A simple list property with an interface. public IList ListPropertyWithInterface { get; set; } /// A property with nested generics. public IDictionary> GenericsProperty { get; set; } /// A property using an enum available to both mods. public BindingFlags EnumProperty { get; set; } /// A read-only property. public int GetterProperty => 42; /**** ** Methods ****/ /// A simple method with no return value. public void GetNothing() { } /// A simple method which returns a number. public int GetInt(int value) { return value; } /// A simple method which returns an object. public object GetObject(object value) { return value; } /// A simple method which returns a list. public List GetList(string value) { return new() { value }; } /// A simple method which returns a list with an interface. public IList GetListWithInterface(string value) { return new List { value }; } /// A simple method which returns nested generics. public IDictionary> GetGenerics(string key, string value) { return new Dictionary> { [key] = new List { value } }; } /// A simple method which returns a lambda. public Func GetLambda(Func value) { return value; } /********* ** Helper methods *********/ /// Raise the event. /// The value to pass to the event. public void RaiseEventField(int value) { this.OnEventRaised?.Invoke(null, value); } } }