List <object> limbo = new List <object>(); // maybe make this static? it would prevent multithreading but it would give a smaller memory footprint, idk atm
        public object FromString(string str)
        {
            str = str.Trim('\r', '\n', ' ', '[', ']');

            var values = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            limbo.Clear(); // the intermediate list is so we can make sure every element deserializes correctly before making the array
            foreach (string value in values)
            {
                limbo.Add(InternalParser.FromString(value.Trim()));
            }
            var array = Array.CreateInstance(ElementType, limbo.Count);

            for (int i = 0; i < limbo.Count; i++)
            {
                array.SetValue(limbo[i], i);
            }
            return(array);
        }
Beispiel #2
0
 protected override object ParseString(string str)
 {
     return(parser.FromString(str));
 }