internal SoftEnumBase(SoftEnumType type, string name, int value, int index) { m_type = type; m_name = name; m_value = value; m_index = index; }
public static IEnumerable <SoftEnumBase> ListValues(SoftEnumType type) { SoftEnumBase[] values = new SoftEnumBase[type.m_values.Length]; Array.Copy(type.m_values, values, type.m_values.Length); foreach (var val in values) { yield return(val); } }
public bool TryRegisterNewType(SoftEnumType type) { if (m_types.Where(t => ReferenceEquals(t.GetType(), type.GetType())).Count() > 0) { return(false); } else { m_types.Add(type); return(true); } }
public static SoftEnumBase GetValue(SoftEnumType type, string name = "", int value = -1) { if (String.IsNullOrEmpty(name)) { foreach (var val in type.m_values) { if (val.Value == value) { return(val); } } } else { foreach (var val in type.m_values) { if (val.Name == name) { return(val); } } } return(null); }
public static Creator <TType> Create(SoftEnumType type) { var creator = new Creator <TType>(type as TType); return(creator); }