示例#1
0
        /// <summary>
        /// このインスタンスの値を<see cref="CsvColumn"/>に変換します。
        /// </summary>
        /// <returns><see cref="CsvColumn"/>。</returns>
        internal CsvColumn ToCsvColumn()
        {
            Validate();

            var type     = typeof(T);
            var property = type.GetProperty(this.propertyName);

            if (property == null)
            {
                throw new InvalidOperationException($"The property name {this.propertyName} is invalid.");
            }

            var attribute = new CsvColumnAttribute(this.index)
            {
                Name = this.name
            };
            var csvProperty = new CsvProperty(type, this.propertyName, CreateAttributesDictionary());
            var converter   = GetConverter(property);

            return(new CsvColumn(attribute, csvProperty, converter));
        }
示例#2
0
文件: CsvColumn.cs 项目: yamahix/NCsv
 /// <summary>
 /// <see cref="CsvColumn"/>クラスの新しいインスタンスを初期化します。
 /// </summary>
 /// <param name="attribute"><see cref="CsvColumnAttribute"/>。</param>
 /// <param name="property"><see cref="CsvProperty"/>。</param>
 /// <param name="converter"><see cref="CsvConverter"/>。</param>
 public CsvColumn(CsvColumnAttribute attribute, CsvProperty property, CsvConverter converter)
 {
     this.attribute = attribute;
     this.property  = property;
     this.converter = converter;
 }