Example #1
0
        public IEnumerable <DelimitedColumn> GetDelimitedColumns()
        {
            foreach (var propertyInfo in CsvSerializerHelpers.OrderByProperty(this.type))
            {
                var delimitedColumn = new DelimitedColumn()
                {
                    Name = propertyInfo.Name,
                    Type = propertyInfo.PropertyType,
                };

                yield return(delimitedColumn);
            }
        }
Example #2
0
        public CsvSerializer()
        {
            this.type          = typeof(T);
            this.propertyInfos = CsvSerializerHelpers.OrderByProperty(this.type)
                                 .ToArray();

            this.propertySetters = this.propertyInfos.Select(CoercionHelpers.CreatePropertySetter <T>)
                                   .ToArray();

            if (!this.IsDataContract())
            {
                string message = $@"The type ""{this.type.FullName}"" does not have the [DataContract] attribute!";
                throw new ArgumentException(message);
            }
        }