예제 #1
0
    public static bool AddUIntKeyTable <T>(UIntKeyTable <T> table, string text, CallBackUIntKeyReadCSV <T> cb, string name_table, Progress progress = null) where T : new()
    {
        CSVReader cSVReader = new CSVReader(text, name_table, false);
        float     num       = 1f;

        if (progress != null)
        {
            num = progress.value;
        }
        float num2 = 1f - num;
        float num3 = (float)text.Length;

        while (cSVReader.NextLine())
        {
            string value = string.Empty;
            if ((bool)cSVReader.Pop(ref value))
            {
                if (value.Length > 0)
                {
                    uint key = uint.Parse(value);
                    T    val = new T();
                    if (!cb(cSVReader, val, ref key))
                    {
                        return(false);
                    }
                    bool flag = !table.Add(key, val);
                }
                if (progress != null)
                {
                    progress.value = num + num2 * (float)cSVReader.GetPosition() / num3;
                }
            }
        }
        return(true);
    }
예제 #2
0
    public static UIntKeyTable <T> CreateUIntKeyTable <T>(string text, CallBackUIntKeyReadCSV <T> cb, string name_table, Progress progress = null) where T : new()
    {
        UIntKeyTable <T> uIntKeyTable = new UIntKeyTable <T>();

        if (!AddUIntKeyTable(uIntKeyTable, text, cb, name_table, progress))
        {
            uIntKeyTable.Clear();
        }
        return(uIntKeyTable);
    }
예제 #3
0
    public static UIntKeyTable <List <T> > CreateUIntKeyListTable <T>(string text, CallBackUIntKeyReadCSV <T> cb, string name_table) where T : new()
    {
        UIntKeyTable <List <T> > uIntKeyTable = new UIntKeyTable <List <T> >();

        if (!AddUIntKeyListTable(uIntKeyTable, text, cb, name_table))
        {
            uIntKeyTable.Clear();
        }
        return(uIntKeyTable);
    }
예제 #4
0
    public static bool AddUIntKeyListTable <T>(UIntKeyTable <List <T> > table, string text, CallBackUIntKeyReadCSV <T> cb, string name_table) where T : new()
    {
        CSVReader cSVReader = new CSVReader(text, name_table, false);

        while (cSVReader.NextLine())
        {
            string value = string.Empty;
            if ((bool)cSVReader.Pop(ref value) && value.Length > 0)
            {
                uint key = uint.Parse(value);
                T    val = new T();
                if (!cb(cSVReader, val, ref key))
                {
                    return(false);
                }
                List <T> list = table.Get(key);
                if (list == null)
                {
                    list = new List <T>();
                    table.Add(key, list);
                }
                list.Add(val);
            }
        }
        return(true);
    }