Beispiel #1
0
        // ヘルパーメソッド
        static public IdWithType Create(IdType type, uint id)
        {
            var res = new IdWithType();

            res.Value  = 0;
            res.Value |= (((uint)type) << 24) & 0xFF000000;
            res.Value |= id & 0x00FFFFFF;
            return(res);
        }
Beispiel #2
0
        public override object ConvertFromString(TypeConverterOptions options, string text)
        {
            IdWithType res;

            if (IdWithType.TryParse(text, out res))
            {
                return(res);
            }
            return(IdWithType.Empty);
        }
Beispiel #3
0
        static public bool TryParse(string str, out IdWithType res)
        {
            res = IdWithType.Empty;

            // フォーマット : ID_{{IdType}}_{{MAIN_ID}}_{SUB_ID}
            // 正規表現 : @"ID_([a-zA-Z]*?)_(\d{3,3})_(\d{3,3})"
            var match = regex.Match(str);

            if (match == Match.Empty)
            {
                return(false);
            }

            var type = (IdType)Enum.Parse(typeof(IdType), match.Groups[1].Value, true);
            var main = UInt32.Parse(match.Groups[2].Value);
            var sub  = UInt32.Parse(match.Groups[3].Value);

            res = IdWithType.Create(type, (main * 1000) + sub);
            return(true);
        }
Beispiel #4
0
 // IdWhitType -> Id を取得
 static public uint GetId(IdWithType id)
 {
     return(id.Value & 0x00FFFFFF);
 }
Beispiel #5
0
 // IdWhitType -> IdType を取得
 static public IdType GetIdType(IdWithType id)
 {
     return((IdType)((id.Value >> 24) & 0xFF));
 }