
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
//
// Changes to this file may cause incorrect behavior and will be lost when
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
#nullable enable
namespace HathoraCloud.Models.Shared
{
    using Newtonsoft.Json;
    using System;
    using UnityEngine;
    
    /// <summary>
    /// Types of lobbies a player can create.<br/>
    /// 
    /// <remarks>
    /// <br/>
    /// `private`: the player who created the room must share the roomId with their friends<br/>
    /// <br/>
    /// `public`: visible in the public lobby list, anyone can join<br/>
    /// <br/>
    /// `local`: for testing with a server running locally
    /// </remarks>
    /// </summary>
    public enum LobbyVisibility
    {
        [JsonProperty("private")]
        Private,
        [JsonProperty("public")]
        Public,
        [JsonProperty("local")]
        Local,
    }

    public static class LobbyVisibilityExtension
    {
        public static string Value(this LobbyVisibility value)
        {
            return ((JsonPropertyAttribute)value.GetType().GetMember(value.ToString())[0].GetCustomAttributes(typeof(JsonPropertyAttribute), false)[0]).PropertyName ?? value.ToString();
        }

        public static LobbyVisibility ToEnum(this string value)
        {
            foreach(var field in typeof(LobbyVisibility).GetFields())
            {
                var attributes = field.GetCustomAttributes(typeof(JsonPropertyAttribute), false);
                if (attributes.Length == 0)
                {
                    continue;
                }

                var attribute = attributes[0] as JsonPropertyAttribute;
                if (attribute != null && attribute.PropertyName == value)
                {
                    return (LobbyVisibility)field.GetValue(null);
                }
            }

            throw new Exception($"Unknown value {value} for enum LobbyVisibility");
        }
    }

}