Update RecordController.cs
This commit is contained in:
@@ -9,17 +9,25 @@ namespace BoerseDataConvert
|
|||||||
{
|
{
|
||||||
public class RecordController
|
public class RecordController
|
||||||
{
|
{
|
||||||
private static int count = 1;
|
private int count;
|
||||||
|
private string fileName;
|
||||||
|
|
||||||
|
public RecordController(string fileName)
|
||||||
|
{
|
||||||
|
this.count = 1;
|
||||||
|
this.fileName = fileName;
|
||||||
|
}
|
||||||
|
|
||||||
public string ConvertToXml(Record record)
|
public string ConvertToXml(Record record)
|
||||||
{
|
{
|
||||||
StringBuilder xlmRecord = new StringBuilder();
|
StringBuilder xmlRecord = new StringBuilder();
|
||||||
xlmRecord.Append($"<record id=”{count}”>\n");
|
xmlRecord.Append($"<record id=”{count}”>\n");
|
||||||
foreach (var tagValue in record.TagsValues)
|
foreach (var tagValue in record.TagsValues)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string tag =CheckTagValue(tagValue.Key, tagValue.Value);
|
string tag =CheckTagValue(tagValue.Key, tagValue.Value);
|
||||||
xlmRecord.Append($"<{tag}>{tagValue.Value}</{tag}>\n");
|
xmlRecord.Append($"<{tag}>{tagValue.Value}</{tag}>\n");
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (ArgumentException e)
|
||||||
{
|
{
|
||||||
@@ -27,9 +35,9 @@ namespace BoerseDataConvert
|
|||||||
throw new ArgumentException(e.Message);
|
throw new ArgumentException(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xlmRecord.Append($"</record>");
|
xmlRecord.Append($"</record>");
|
||||||
count++;
|
count++;
|
||||||
return xlmRecord.ToString();
|
return xmlRecord.ToString();
|
||||||
}
|
}
|
||||||
private string CheckTagValue(string tag, string value)
|
private string CheckTagValue(string tag, string value)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user