Ejemplo n.º 1
0
        public static string GetCsvNationRecordField(NationRecordFields recordField, Nation nation)
        {
            string fieldString = string.Empty;

            switch (recordField)
            {
            case NationRecordFields.Name:
                fieldString += ExtendedStringWriter.GetSafeString(nation.Name);
                break;

            case NationRecordFields.Capital:
                fieldString += ExtendedStringWriter.GetSafeString(nation.Capital);
                break;

            case NationRecordFields.Latitude:
                fieldString += nation.Longitude;
                break;

            case NationRecordFields.Longitude:
                fieldString += nation.Longitude;
                break;

            case NationRecordFields.ImageUri:
                fieldString += ExtendedStringWriter.GetSafeString(nation.ImageUri);
                break;

            case NationRecordFields.GeographyXml:
                fieldString += ExtendedStringWriter.GetSafeString(nation.GeographyXml);
                break;
            }

            return(fieldString);
        }
Ejemplo n.º 2
0
        public static string GetCsvBookRecordField(BookRecordFields recordField, Book book)
        {
            string fieldString = string.Empty;

            switch (recordField)
            {
            case BookRecordFields.DateString:
                fieldString += book.DateString;
                break;

            case BookRecordFields.Date:
                fieldString +=
                    book.Date.Day + "/" + book.Date.Month + "/" + book.Date.Year;
                break;

            case BookRecordFields.Author:
                fieldString += ExtendedStringWriter.GetSafeString(book.Author);
                break;

            case BookRecordFields.Title:
                fieldString += ExtendedStringWriter.GetSafeString(book.Title);
                break;

            case BookRecordFields.Pages:
                if (!(book.Pages == 0 && (book.Format == "Audio" || book.Format == "Comic")))
                {
                    fieldString += book.Pages;
                }
                break;

            case BookRecordFields.Note:
                fieldString += ExtendedStringWriter.GetSafeString(book.Note);
                break;

            case BookRecordFields.Nationality:
                fieldString += ExtendedStringWriter.GetSafeString(book.Nationality);
                break;

            case BookRecordFields.OriginalLanguage:
                fieldString += ExtendedStringWriter.GetSafeString(book.OriginalLanguage);
                break;

            case BookRecordFields.Book:
                if (book.Format == "Book")
                {
                    fieldString += "x";
                }
                break;

            case BookRecordFields.Comic:
                if (book.Format == "Comic")
                {
                    fieldString += "x";
                }
                break;

            case BookRecordFields.Audio:
                if (book.Format == "Audio")
                {
                    fieldString += "x";
                }
                break;

            case BookRecordFields.Image:
                fieldString += ExtendedStringWriter.GetSafeString(book.ImageUrl);
                break;

            case BookRecordFields.Tags:
            {
                string tags = string.Empty;
                for (int i = 0; i < book.Tags.Length; i++)
                {
                    if (i != 0)
                    {
                        tags += ", ";
                    }

                    tags += book.Tags[i];
                }

                fieldString += ExtendedStringWriter.GetSafeString(tags);
            }
            break;
            }

            return(fieldString);
        }