Пример #1
0
        /// <summary>
        /// Deserialize Csv object
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="textSerialized"></param>
        /// <returns></returns>
        public T Deserialize(string textSerialized)
        {
            StringList listElements = new StringList(textSerialized.Split(_separator));
            T          element      = CreateInstanceManager <T> .CreateInstance(listElements);

            element.Construct();
            return(element);
        }
Пример #2
0
        public Y DeserializeList <Y>(ICollection <object> textListSerialized) where Y : ListSerializable <T>
        {
            Y elements = CreateInstanceManager <T> .CreateInstance <Y>();

            foreach (Row row in textListSerialized)
            {
                elements.Add(Deserialize(row));
            }
            return(elements);
        }
Пример #3
0
        /// <summary>
        /// Deserialize Csv object list
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="textSerialized"></param>
        /// <returns></returns>
        public Y DeserializeList <Y>(string textListSerialized) where Y : ListSerializable <T>
        {
            StringList lines = new StringList(textListSerialized.Split("\r\n"));

            if (_headers != null && _headers.Join(_separator) == lines[0])
            {
                //there is a header line
                lines.Remove(lines[0]);
            }
            Y elements = CreateInstanceManager <T> .CreateInstance <Y>();

            foreach (string text in lines.Where(l => !string.IsNullOrEmpty(l)))
            {
                elements.Add(Deserialize(text));
            }
            return(elements);
        }
Пример #4
0
        public T Deserialize(object textSerialized)
        {
            StringList element = new StringList();

            if (!(textSerialized is Row))
            {
                throw new ArgumentException("The parmeter " + nameof(textSerialized) + " is not a valid excel row");
            }
            Row row = textSerialized as Row;

            foreach (Cell cell in row)
            {
                element.Add(cell.Value);
            }
            T lineObject = CreateInstanceManager <T> .CreateInstance(element);

            lineObject.Construct();
            return(lineObject);
        }
Пример #5
0
        public T StringToObject(string objectSerialize)
        {
            StringList list = new StringList(objectSerialize.Split(SeparatorsColumn()));

            return(CreateInstanceManager <T> .CreateInstance(list));
        }