示例#1
0
        /// <summary>
        /// Gets the Csv Column Number
        /// to use when serializing to Csv
        /// </summary>
        /// <returns>
        /// <see cref="CsvColumnAttribute.ColumnNumber"/>
        /// if present against <paramref name="property"/>,
        /// otherwise -1
        /// </returns>
        public static int GetCsvColumnNumber(this PropertyInfo property)
        {
            CsvColumnAttribute attr = property.GetCustomAttribute <CsvColumnAttribute>(true);

            return(attr == null ? -1 : attr.ColumnNumber);
        }
示例#2
0
        /// <summary>
        /// Gets the Csv Column Name
        /// </summary>
        /// <returns>
        /// <see cref="CsvColumnAttribute.ColumnName"/>
        /// if present for <paramref name="property"/>,
        /// otherwise PropertyInfo.Name
        /// </returns>
        public static string GetCsvColumnName(this PropertyInfo property)
        {
            CsvColumnAttribute attr = property.GetCustomAttribute <CsvColumnAttribute>(true);

            return(attr == null || attr.ColumnName == null ? property.Name : attr.ColumnName);
        }