using System; using UnityEngine; namespace Unity.Services.Core.Configuration { /// /// Wrapper for project configuration values. /// [Serializable] class ConfigurationEntry { [SerializeField] string m_Value; /// /// Get the stored configuration value. /// public string Value => m_Value; [SerializeField] bool m_IsReadOnly; /// /// If true, can't be changed. /// public bool IsReadOnly { get => m_IsReadOnly; internal set => m_IsReadOnly = value; } /// /// Create a new instance of the class. /// /// /// Required for serialization. /// public ConfigurationEntry() {} /// /// Create a new instance of the class. /// /// /// The value to store. /// /// /// If true, the value can't be changed after construction. /// public ConfigurationEntry(string value, bool isReadOnly = false) { m_Value = value; m_IsReadOnly = isReadOnly; } /// /// Set only if is false. /// Does nothing otherwise. /// /// /// The new value to store. /// /// /// Return true if is false; /// return false otherwise. /// public bool TrySetValue(string value) { if (IsReadOnly) { return false; } m_Value = value; return true; } public static implicit operator string(ConfigurationEntry entry) => entry.Value; public static implicit operator ConfigurationEntry(string value) => new ConfigurationEntry(value); } }