Defining Configuration Classes
Configuration classes are plain C# classes decorated with [Tactile.ConfigProvider]. The SDK uses these to deserialize server-side JSON into typed objects.
Basic configuration class
using System.Collections.Generic;using ConfigSchema;
[Tactile.ConfigProvider("IAPConfig")]public class IAPConfig{ [JsonSerializable("InAppProducts", typeof(InAppProductInfo))] public List<InAppProductInfo> InAppProducts { get; set; }}Nested types
Nested types do not need a [ConfigProvider] attribute — only the root class does:
public class InAppProductInfo{ [JsonSerializable("Identifier")] public string Identifier { get; set; }
[JsonSerializable("Title")] public string Title { get; set; }
[JsonSerializable("Price")] public double Price { get; set; }
[JsonSerializable("CurrencyCode")] public string CurrencyCode { get; set; }}Attribute reference
[Tactile.ConfigProvider(string key)]
Maps the class to a top-level JSON key in the server configuration. key must exactly match the key used in the dashboard configuration editor.
[JsonSerializable(string name)]
Maps a property to a JSON field name. name is the key as it appears in the JSON.
[JsonSerializable(string name, Type elementType)]
For List<T> properties — the second parameter specifies the element type for deserialization.
Supported field types
| C# type | JSON type |
|---|---|
string | string |
int | number |
double | number |
float | number |
bool | boolean |
List<T> | array |
| Nested class | object |
Full real-world example
using System.Collections.Generic;
[Tactile.ConfigProvider("ShopConfig")]public class ShopConfig{ [JsonSerializable("FeaturedProductId")] public string FeaturedProductId { get; set; }
[JsonSerializable("DiscountPercent")] public int DiscountPercent { get; set; }
[JsonSerializable("SaleActive")] public bool SaleActive { get; set; }
[JsonSerializable("Products", typeof(ShopProductInfo))] public List<ShopProductInfo> Products { get; set; }}
public class ShopProductInfo{ [JsonSerializable("Id")] public string Id { get; set; }
[JsonSerializable("CoinsAmount")] public int CoinsAmount { get; set; }
[JsonSerializable("PriceUSD")] public double PriceUSD { get; set; }}The corresponding JSON in your bundled configuration file would look like:
{ "ShopConfig": { "FeaturedProductId": "featured_item_123", "DiscountPercent": 10, "SaleActive": true, "Products": [ { "Id": "coins_100", "CoinsAmount": 100, "PriceUSD": 0.99 }, { "Id": "coins_500", "CoinsAmount": 500, "PriceUSD": 3.99 } ] }}The top-level key "ShopConfig" must match the string passed to [ConfigProvider("ShopConfig")]. Each property key must match the name argument in the corresponding [JsonSerializable] attribute.