Пример #1
0
    void PraseTranslation(string rawCsv)
    {
        var lines     = Regex.Split(rawCsv, LINE_SPLIT_REX);
        var header    = Regex.Split(lines[0], SPLIT_REX);
        var nameIndex = System.Array.FindIndex(header, (item) => { return(item == headerKeys[0]); });
        var dataIndex = System.Array.FindIndex(header, (item) => { return(item == headerKeys[1]); });
        var valeIndex = System.Array.FindIndex(header, (item) => { return(item == headerKeys[2]); });

        for (var i = 1; i < lines.Length; i++)
        {
            var values         = Regex.Split(lines[i], SPLIT_REX);
            var nameClassIndex = values[nameIndex];
            var data           = values[dataIndex]; // level
            var value          = values[valeIndex];
            if (!string.IsNullOrEmpty(nameClassIndex))
            {
                classInstance = new Dictionary <string, object>();
                if (!baseData.ContainsKey(nameClassIndex))
                {
                    baseData.Add(nameClassIndex, classInstance);
                }
                continue;
            }
            if (!string.IsNullOrEmpty(data))
            {
                if (!classInstance.ContainsKey(data))
                {
                    classInstance.Add(data, value);
                }
            }
        }
        var jsonSerialize  = JsonConvert.SerializeObject(baseData);
        var gameConfigData = JsonConvert.DeserializeObject <GameConfigData>(jsonSerialize);

        //var gameConfigData = GetObject<GameConfigData>(baseData);
        Debug.Assert(gameConfigData != null, "game config data has be null ");
        OnUpdateGameConfigData.OnNext(gameConfigData);
        OnCompleted.OnNext(this.GetHashCode());
    }