Beispiel #1
0
    public static void ReadingAndWritingCsv()
    {
        // Initialize data (see code-example above):
        Contact[] contactArr = ContactExample.InitializeContacts();

        const string fileName = "FamilyDoe.csv";

        // Save the Contacts:
        contactArr.SaveCsv(fileName, CsvCompatibility.Thunderbird);

        // Display the content of the CSV file:
        Console.WriteLine("Saved CSV:");
        Console.WriteLine();
        Console.WriteLine(File.ReadAllText(fileName));

        // Reload the CSV file:
        List <Contact> contactList = ContactPersistence.LoadCsv(fileName, CsvCompatibility.Thunderbird);

        // Display the content of the reloaded Contact objects:
        Console.WriteLine();
        Console.WriteLine("Reloaded Contact objects:");

        for (int i = 0; i < contactList.Count; i++)
        {
            Console.WriteLine();
            Console.WriteLine($"Contact {i + 1}:");
            Console.WriteLine(contactArr[i]);
            Console.WriteLine();
        }
    }
Beispiel #2
0
    public static void ReadingAndWritingVCard()
    {
        // Initialize data (see code-example above):
        Contact[] contactArr = ContactExample.InitializeContacts();

        const string fileName = "FamilyDoe.vcf";

        // Save all contacts to a common VCF file:
        contactArr.SaveVcf(fileName);

        // Display the content of the VCF file:
        Console.WriteLine("Saved VCF:");
        Console.WriteLine();
        Console.WriteLine(File.ReadAllText(fileName));

        // Reload the VCF file:
        List <Contact> contactList = ContactPersistence.LoadVcf(fileName);

        // Display the content of the reloaded Contact objects:
        Console.WriteLine();
        Console.WriteLine("Reloaded Contact objects:");

        for (int i = 0; i < contactList.Count; i++)
        {
            Console.WriteLine();
            Console.WriteLine($"Contact {i + 1}:");
            Console.WriteLine(contactArr[i]);
            Console.WriteLine();
        }
    }
Beispiel #3
0
        private static void Main()
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            // CsvExample.ReadingAndWritingCsv();
            // VCardExample.ReadingAndWritingVCard();

            _ = ContactExample.InitializeContacts();

            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            var ct = new Contact();

            ct.Clean();
        }