-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some smaller stuff to csv handler, not perfect or finished but at…
… least some groundwork is done.
- Loading branch information
1 parent
b2fa02c
commit ceee0fa
Showing
5 changed files
with
304 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* COPYRIGHT: See COPYING in the top level directory | ||
* PROJECT: DataFormatter | ||
* FILE: DataFormatter/AttributeConverter.cs | ||
* PURPOSE: Helper for csv, Interface and implementation of AttributeConverter. | ||
* PROGRAMER: Peter Geinitz (Wayfarer) | ||
*/ | ||
|
||
namespace DataFormatter | ||
{ | ||
/// <summary> | ||
/// Interface for AttributeConverter Converter | ||
/// </summary> | ||
internal interface IAttributeConverter | ||
{ | ||
/// <summary> | ||
/// Converts the specified value. | ||
/// </summary> | ||
/// <param name="value">The value.</param> | ||
/// <returns>Generic return Type.</returns> | ||
object Convert(string value); | ||
} | ||
|
||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Implementation of AttributeConverter for int | ||
/// </summary> | ||
/// <seealso cref="T:DataFormatter.IAttributeConverter" /> | ||
public sealed class IntAttributeConverter : IAttributeConverter | ||
{ | ||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Converts the specified value. | ||
/// </summary> | ||
/// <param name="value">The value.</param> | ||
/// <returns>Converted to int</returns> | ||
public object Convert(string value) | ||
{ | ||
return int.Parse(value); | ||
} | ||
} | ||
|
||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Implementation of AttributeConverter for string | ||
/// </summary> | ||
/// <seealso cref="T:DataFormatter.IAttributeConverter" /> | ||
public sealed class StringAttributeConverter : IAttributeConverter | ||
{ | ||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Converts the specified value. | ||
/// </summary> | ||
/// <param name="value">The value.</param> | ||
/// <returns>Converted to string</returns> | ||
public object Convert(string value) | ||
{ | ||
return value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* COPYRIGHT: See COPYING in the top level directory | ||
* PROJECT: DataFormatter | ||
* FILE: DataFormatter/CsvColumnAttribute.cs | ||
* PURPOSE: Helper for csv, Helps converter | ||
* PROGRAMER: Peter Geinitz (Wayfarer) | ||
*/ | ||
|
||
using System; | ||
|
||
namespace DataFormatter | ||
{ | ||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Needed for our custom csv conversion | ||
/// </summary> | ||
/// <seealso cref="T:System.Attribute" /> | ||
[AttributeUsage(AttributeTargets.Property)] | ||
public sealed class CsvColumnAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Gets the index of the row. | ||
/// </summary> | ||
/// <value> | ||
/// The index. | ||
/// </value> | ||
internal int Index { get; } | ||
|
||
/// <summary> | ||
/// Gets the type of the converter. | ||
/// </summary> | ||
/// <value> | ||
/// The type of the converter. | ||
/// </value> | ||
internal Type ConverterType { get; } | ||
|
||
/// <inheritdoc /> | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="T:DataFormatter.CsvColumnAttribute" /> class. | ||
/// </summary> | ||
/// <param name="index">The index.</param> | ||
/// <param name="converterType">Type of the converter.</param> | ||
public CsvColumnAttribute(int index, Type converterType) | ||
{ | ||
Index = index; | ||
ConverterType = converterType; | ||
} | ||
} | ||
} |
Oops, something went wrong.