Skip to content

Instantly share code, notes, and snippets.

@baba-s
Created Aug 28, 2017
Embed
What would you like to do?
using System.Collections.Generic;
/// <summary>
/// <para>NONE:不明</para>
/// <para>FLAME:炎</para>
/// <para>THUNDER:雷</para>
/// <para>ICE:氷</para>
/// </summary>
public enum PARAM_TYPE
{
/// <para>不明</para>
NONE,
/// <para>炎</para>
FLAME,
/// <para>雷</para>
THUNDER,
/// <para>氷</para>
ICE,
/// <para>番兵</para>
SIZEOF,
}
/// <summary>
/// <para>NONE:不明</para>
/// <para>SOLDIER:王国兵士</para>
/// <para>SORCERER:魔法使い</para>
/// <para>HUNTER:狩人</para>
/// </summary>
public enum JOB_TYPE
{
/// <para>不明</para>
NONE,
/// <para>王国兵士</para>
SOLDIER,
/// <para>魔法使い</para>
SORCERER,
/// <para>狩人</para>
HUNTER,
/// <para>番兵</para>
SIZEOF,
}
/// <summary>
/// PARAM_TYPE 型の等価比較をサポートするクラス
/// </summary>
public sealed class ParamTypeComparer : IEqualityComparer<PARAM_TYPE>
{
public bool Equals( PARAM_TYPE x, PARAM_TYPE y )
{
return x == y;
}
public int GetHashCode( PARAM_TYPE obj )
{
return ( int )obj;
}
}
/// <summary>
/// JOB_TYPE 型の等価比較をサポートするクラス
/// </summary>
public sealed class JobTypeComparer : IEqualityComparer<JOB_TYPE>
{
public bool Equals( JOB_TYPE x, JOB_TYPE y )
{
return x == y;
}
public int GetHashCode( JOB_TYPE obj )
{
return ( int )obj;
}
}
/// <summary>
/// PARAM_TYPE 型の汎用機能を管理するクラス
/// </summary>
public static partial class ParamTypeUtils
{
private static PARAM_TYPE[] m_list = null;
private static PARAM_TYPE[] m_listWithoutNone = null;
/// <summary>
/// PARAM_TYPE 型の要素数 4 を返します
/// </summary>
public static int Count { get { return 4; } }
/// <summary>
/// PARAM_TYPE.NONE を除く PARAM_TYPE 型の要素数 3 を返します
/// </summary>
public static int CountWithoutNone { get { return 3; } }
/// <summary>
/// <para>PARAM_TYPE の要素の一覧を返します</para>
/// <para>PARAM_TYPE.NONE</para>
/// <para>PARAM_TYPE.FLAME</para>
/// <para>PARAM_TYPE.THUNDER</para>
/// <para>PARAM_TYPE.ICE</para>
/// </summary>
public static PARAM_TYPE[] List
{
get
{
if ( m_list == null )
{
m_list = new PARAM_TYPE[]
{
PARAM_TYPE.NONE,
PARAM_TYPE.FLAME,
PARAM_TYPE.THUNDER,
PARAM_TYPE.ICE,
};
}
return m_list;
}
}
/// <summary>
/// <para>PARAM_TYPE.NONE を除く PARAM_TYPE の要素の一覧を返します</para>
/// <para>PARAM_TYPE.FLAME</para>
/// <para>PARAM_TYPE.THUNDER</para>
/// <para>PARAM_TYPE.ICE</para>
/// </summary>
public static PARAM_TYPE[] ListWithoutNone
{
get
{
if ( m_listWithoutNone == null )
{
m_listWithoutNone = new PARAM_TYPE[]
{
PARAM_TYPE.FLAME,
PARAM_TYPE.THUNDER,
PARAM_TYPE.ICE,
};
}
return m_listWithoutNone;
}
}
/// <summary>
/// <para>アッパーケースの文字列を PARAM_TYPE の要素に変換します</para>
/// <para>"NONE": PARAM_TYPE.NONE</para>
/// <para>"FLAME": PARAM_TYPE.FLAME</para>
/// <para>"THUNDER": PARAM_TYPE.THUNDER</para>
/// <para>"ICE": PARAM_TYPE.ICE</para>
/// </summary>
public static PARAM_TYPE FromString( string str )
{
switch ( str )
{
case "NONE": return PARAM_TYPE.NONE;
case "FLAME": return PARAM_TYPE.FLAME;
case "THUNDER": return PARAM_TYPE.THUNDER;
case "ICE": return PARAM_TYPE.ICE;
}
return 0;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>PARAM_TYPE.NONE: "NONE"</para>
/// <para>PARAM_TYPE.FLAME: "FLAME"</para>
/// <para>PARAM_TYPE.THUNDER: "THUNDER"</para>
/// <para>PARAM_TYPE.ICE: "ICE"</para>
/// </summary>
public static string ToUpper( this PARAM_TYPE self )
{
switch ( self )
{
case PARAM_TYPE.NONE: return "NONE";
case PARAM_TYPE.FLAME: return "FLAME";
case PARAM_TYPE.THUNDER: return "THUNDER";
case PARAM_TYPE.ICE: return "ICE";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>PARAM_TYPE.NONE: "none"</para>
/// <para>PARAM_TYPE.FLAME: "flame"</para>
/// <para>PARAM_TYPE.THUNDER: "thunder"</para>
/// <para>PARAM_TYPE.ICE: "ice"</para>
/// </summary>
public static string ToLower( this PARAM_TYPE self )
{
switch ( self )
{
case PARAM_TYPE.NONE: return "none";
case PARAM_TYPE.FLAME: return "flame";
case PARAM_TYPE.THUNDER: return "thunder";
case PARAM_TYPE.ICE: return "ice";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>PARAM_TYPE.NONE: "None"</para>
/// <para>PARAM_TYPE.FLAME: "Flame"</para>
/// <para>PARAM_TYPE.THUNDER: "Thunder"</para>
/// <para>PARAM_TYPE.ICE: "Ice"</para>
/// </summary>
public static string ToUpperCamel( this PARAM_TYPE self )
{
switch ( self )
{
case PARAM_TYPE.NONE: return "None";
case PARAM_TYPE.FLAME: return "Flame";
case PARAM_TYPE.THUNDER: return "Thunder";
case PARAM_TYPE.ICE: return "Ice";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>PARAM_TYPE.NONE: "none"</para>
/// <para>PARAM_TYPE.FLAME: "flame"</para>
/// <para>PARAM_TYPE.THUNDER: "thunder"</para>
/// <para>PARAM_TYPE.ICE: "ice"</para>
/// </summary>
public static string ToLowerCamel( this PARAM_TYPE self )
{
switch ( self )
{
case PARAM_TYPE.NONE: return "none";
case PARAM_TYPE.FLAME: return "flame";
case PARAM_TYPE.THUNDER: return "thunder";
case PARAM_TYPE.ICE: return "ice";
}
return string.Empty;
}
/// <summary>
/// <para>コメントの文字列に変換します</para>
/// <para>PARAM_TYPE.NONE: "不明"</para>
/// <para>PARAM_TYPE.FLAME: "炎"</para>
/// <para>PARAM_TYPE.THUNDER: "雷"</para>
/// <para>PARAM_TYPE.ICE: "氷"</para>
/// </summary>
public static string ToComment( this PARAM_TYPE self )
{
switch ( self )
{
case PARAM_TYPE.NONE: return "不明";
case PARAM_TYPE.FLAME: return "";
case PARAM_TYPE.THUNDER: return "";
case PARAM_TYPE.ICE: return "";
}
return string.Empty;
}
}/// <summary>
/// JOB_TYPE 型の汎用機能を管理するクラス
/// </summary>
public static partial class JobTypeUtils
{
private static JOB_TYPE[] m_list = null;
private static JOB_TYPE[] m_listWithoutNone = null;
/// <summary>
/// JOB_TYPE 型の要素数 4 を返します
/// </summary>
public static int Count { get { return 4; } }
/// <summary>
/// JOB_TYPE.NONE を除く JOB_TYPE 型の要素数 3 を返します
/// </summary>
public static int CountWithoutNone { get { return 3; } }
/// <summary>
/// <para>JOB_TYPE の要素の一覧を返します</para>
/// <para>JOB_TYPE.NONE</para>
/// <para>JOB_TYPE.SOLDIER</para>
/// <para>JOB_TYPE.SORCERER</para>
/// <para>JOB_TYPE.HUNTER</para>
/// </summary>
public static JOB_TYPE[] List
{
get
{
if ( m_list == null )
{
m_list = new JOB_TYPE[]
{
JOB_TYPE.NONE,
JOB_TYPE.SOLDIER,
JOB_TYPE.SORCERER,
JOB_TYPE.HUNTER,
};
}
return m_list;
}
}
/// <summary>
/// <para>JOB_TYPE.NONE を除く JOB_TYPE の要素の一覧を返します</para>
/// <para>JOB_TYPE.SOLDIER</para>
/// <para>JOB_TYPE.SORCERER</para>
/// <para>JOB_TYPE.HUNTER</para>
/// </summary>
public static JOB_TYPE[] ListWithoutNone
{
get
{
if ( m_listWithoutNone == null )
{
m_listWithoutNone = new JOB_TYPE[]
{
JOB_TYPE.SOLDIER,
JOB_TYPE.SORCERER,
JOB_TYPE.HUNTER,
};
}
return m_listWithoutNone;
}
}
/// <summary>
/// <para>アッパーケースの文字列を JOB_TYPE の要素に変換します</para>
/// <para>"NONE": JOB_TYPE.NONE</para>
/// <para>"SOLDIER": JOB_TYPE.SOLDIER</para>
/// <para>"SORCERER": JOB_TYPE.SORCERER</para>
/// <para>"HUNTER": JOB_TYPE.HUNTER</para>
/// </summary>
public static JOB_TYPE FromString( string str )
{
switch ( str )
{
case "NONE": return JOB_TYPE.NONE;
case "SOLDIER": return JOB_TYPE.SOLDIER;
case "SORCERER": return JOB_TYPE.SORCERER;
case "HUNTER": return JOB_TYPE.HUNTER;
}
return 0;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>JOB_TYPE.NONE: "NONE"</para>
/// <para>JOB_TYPE.SOLDIER: "SOLDIER"</para>
/// <para>JOB_TYPE.SORCERER: "SORCERER"</para>
/// <para>JOB_TYPE.HUNTER: "HUNTER"</para>
/// </summary>
public static string ToUpper( this JOB_TYPE self )
{
switch ( self )
{
case JOB_TYPE.NONE: return "NONE";
case JOB_TYPE.SOLDIER: return "SOLDIER";
case JOB_TYPE.SORCERER: return "SORCERER";
case JOB_TYPE.HUNTER: return "HUNTER";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>JOB_TYPE.NONE: "none"</para>
/// <para>JOB_TYPE.SOLDIER: "soldier"</para>
/// <para>JOB_TYPE.SORCERER: "sorcerer"</para>
/// <para>JOB_TYPE.HUNTER: "hunter"</para>
/// </summary>
public static string ToLower( this JOB_TYPE self )
{
switch ( self )
{
case JOB_TYPE.NONE: return "none";
case JOB_TYPE.SOLDIER: return "soldier";
case JOB_TYPE.SORCERER: return "sorcerer";
case JOB_TYPE.HUNTER: return "hunter";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>JOB_TYPE.NONE: "None"</para>
/// <para>JOB_TYPE.SOLDIER: "Soldier"</para>
/// <para>JOB_TYPE.SORCERER: "Sorcerer"</para>
/// <para>JOB_TYPE.HUNTER: "Hunter"</para>
/// </summary>
public static string ToUpperCamel( this JOB_TYPE self )
{
switch ( self )
{
case JOB_TYPE.NONE: return "None";
case JOB_TYPE.SOLDIER: return "Soldier";
case JOB_TYPE.SORCERER: return "Sorcerer";
case JOB_TYPE.HUNTER: return "Hunter";
}
return string.Empty;
}
/// <summary>
/// <para>アッパーケースの文字列に変換します</para>
/// <para>JOB_TYPE.NONE: "none"</para>
/// <para>JOB_TYPE.SOLDIER: "soldier"</para>
/// <para>JOB_TYPE.SORCERER: "sorcerer"</para>
/// <para>JOB_TYPE.HUNTER: "hunter"</para>
/// </summary>
public static string ToLowerCamel( this JOB_TYPE self )
{
switch ( self )
{
case JOB_TYPE.NONE: return "none";
case JOB_TYPE.SOLDIER: return "soldier";
case JOB_TYPE.SORCERER: return "sorcerer";
case JOB_TYPE.HUNTER: return "hunter";
}
return string.Empty;
}
/// <summary>
/// <para>コメントの文字列に変換します</para>
/// <para>JOB_TYPE.NONE: "不明"</para>
/// <para>JOB_TYPE.SOLDIER: "王国兵士"</para>
/// <para>JOB_TYPE.SORCERER: "魔法使い"</para>
/// <para>JOB_TYPE.HUNTER: "狩人"</para>
/// </summary>
public static string ToComment( this JOB_TYPE self )
{
switch ( self )
{
case JOB_TYPE.NONE: return "不明";
case JOB_TYPE.SOLDIER: return "王国兵士";
case JOB_TYPE.SORCERER: return "魔法使い";
case JOB_TYPE.HUNTER: return "狩人";
}
return string.Empty;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment