Exemple #1
0
        public static async Task Main(string[] args)
        {
            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
                         .Build();

            var endpoint = config["Endpoint"];
            var database = config["Database"];
            var coll     = config["Collection"];
            var authKey  = config["AuthKey"];

            context = GremlinTraversalContext.Create(endpoint, database, coll, authKey);

            await context.REPL(async queryText => {
                if (queryText == ":rebuild")
                {
                    var deserializer = new Deserializer();
                    var current      = deserializer.Deserialize <Dictionary <object, object> >(File.OpenText("venues.yaml"));
                    await WORK(current);
                    return(true);
                }
                if (queryText == ":edit")
                {
                    System.Diagnostics.Process.Start("notepad", "venues.yaml");
                    return(true);
                }
                if (queryText == ":clear")
                {
                    await context.Execute($"g.E().drop()");
                    await context.Execute($"g.V().drop()");
                    return(true);
                }
                return(false);
            });
        }
Exemple #2
0
        private static async Task WORK(Dictionary <object, object> current)
        {
            await context.Execute($"g.E().drop()");

            await context.Execute($"g.V().drop()");

            await context.Execute($"g.addV('Venues').property(\"id\", \"Venue\")");

            foreach (var xx in current)
            {
                switch (xx.Key)
                {
                case "Venues":
                    await Array("Venue", xx.Value, Venue);

                    break;

                default:
                    await Default("Venue", xx);

                    break;
                }
            }
        }