<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestClient.IO;
using TestClient.IO.TestData;

namespace TestClient
{
    /// <summary>
    /// Simple code example to demonstrate how to use embark
    /// </summary>
    class Demo
    {
        public static void Main()
        {
            //var defaultDir = Directory.GetCurrentDirectory() + "\\Collections\\";
            //var defaultDir = @"C:\MyTemp\Embark\Local\Collections\";
            var defaultDir = @"C:\AnimalsDB\Collections\";

            if (Directory.Exists(defaultDir))
                Directory.Delete(defaultDir, recursive: true);

            SimpleTDemo();

            //SimpleDemo();
        }

        static void SimpleDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network (via REST API)
            //var db = Embark.Client.GetNetworkDB("127.0.0.1", 8080);// Not implemented, yet..

            // collections created on-the-fly if needed
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Select<Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);
        }

        static void SimpleTDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\");

            // or over a network via REST API to WCF server *see usage section below*
            //var db = Embark.Client.GetNetworkDB("192.168.1.24", 8080);

            // collections created on-the-fly if needed
            var io = db.GetCollection<Sheep>("sheep");

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Select(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            // non-type specific collection if you want to save Apples & Oranges in the same fruit collection
            //var io = db["fruit"];
        }

        static void SearchDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(/* Client() defaults to: C:\MyTemp\Embark\Local\ */);

            // or over a network
            // var io = Embark.Client.GetNetworkDB("127.0.0.1", 8765);// Not implemented, yet..

            // reference collections when used a lot so you don't have to keep typing them out
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Select<Sheep>(id);<commit_msg>Mixed type collection Demo<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TestClient.IO;
using TestClient.IO.TestData;

namespace TestClient
{
    /// <summary>
    /// Simple code example to demonstrate how to use embark
    /// </summary>
    class Demo
    {
        public static void Main()
        {
            //var defaultDir = Directory.GetCurrentDirectory() + "\\Collections\\";
            //var defaultDir = @"C:\MyTemp\Embark\Local\Collections\";
            var defaultDir = @"C:\AnimalsDB\Collections\";

            if (Directory.Exists(defaultDir))
                Directory.Delete(defaultDir, recursive: true);

            SimpleTDemo();

            MixedTypeDemo();
        }

        static void SimpleTDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\");

            // or over a network via REST API to WCF server *see usage section below*
            //var db = Embark.Client.GetNetworkDB("192.168.1.24", 8080);

            // collections created on-the-fly if needed
            var io = db.GetCollection<Sheep>("sheep");

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Select(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            // non-type specific collection if you want to save Apples & Oranges in the same fruit collection
            //var io = db["fruit"];
        }

        static void MixedTypeDemo()
        {
            // arrange some guinea pigs
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };
            var mittens = new Cat { Name = "Mittens", FurDensity = 0.1 };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network (via REST API)
            //var db = Embark.Client.GetNetworkDB("127.0.0.1", 8080);// Not implemented, yet..

            // collections created on-the-fly if needed
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);
            long d2 = io.Insert((object)500);
            long d3 = io.Insert("a string!");
            long d4 = io.Insert<Cat>(mittens);

            // get
            Sheep fluffy = io.Select<Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);
        }

        static void SearchDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(/* Client() defaults to: C:\MyTemp\Embark\Local\ */);

            // or over a network
            // var io = Embark.Client.GetNetworkDB("127.0.0.1", 8765);// Not implemented, yet..

            // reference collections when used a lot so you don't have to keep typing them out
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Select<Sheep>(id);
{'fraction_non_alphanumeric': 0.11428571428571428, 'fraction_numerical': 0.010313588850174216, 'mean_word_length': 1.6636971046770601, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3781237', 'n_tokens_mistral': 2111, 'n_tokens_neox': 1949, 'n_words': 548}