Beispiel #1
0
    private void SetField(string key, string value)
    {
        PropertyInfo propertyInfo = this.GetType().GetProperty(key, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

        if (propertyInfo == null)
        {
            return;
        }

        if (propertyInfo.PropertyType == typeof(int))
        {
            propertyInfo.SetValue(this, int.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(string))
        {
            propertyInfo.SetValue(this, value, null);
        }
        else if (propertyInfo.PropertyType == typeof(double))
        {
            propertyInfo.SetValue(this, double.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(bool))
        {
            propertyInfo.SetValue(this, bool.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Attribute))
        {
            propertyInfo.SetValue(this, AttributeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Target))
        {
            propertyInfo.SetValue(this, TargetExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Tribe))
        {
            propertyInfo.SetValue(this, TribeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(EnemyTribe))
        {
            propertyInfo.SetValue(this, EnemyTribeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Job))
        {
            propertyInfo.SetValue(this, JobExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(WeaponType))
        {
            propertyInfo.SetValue(this, WeaponTypeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(SelectType))
        {
            propertyInfo.SetValue(this, SelectTypeExtension.ToEnum(value), null);
        }
        // 他の型にも対応させたいときには適当にここに。enumとかもどうにかなりそう。
    }
Beispiel #2
0
        static Equipment Create(JSONObject obj)
        {
            var equipment = new Equipment(
                (int)obj.GetField("id").i,
                obj.GetField("description").str,
                (int)obj.GetField("sell_price").i,
                (int)obj.GetField("code").i,
                (int)obj.GetField("lv").i,
                obj.GetField("name").str,
                obj.GetField("not_found_name").str,
                (int)obj.GetField("power").i,
                (int)obj.GetField("deffense").i,
                (int)obj.GetField("avoidance").i,
                (int)obj.GetField("hit").i,
                AttributeExtension.ToEnum(obj.GetField("attribute").str),
                EnemyTribeExtension.ToEnum(obj.GetField("regist_tribe").str)
                );

            return(equipment);
        }