예제 #1
0
        public static GremlinTraversalContext Create(string endpoint, string database, string coll, string authKey)
        {
            var context = new GremlinTraversalContext();

            context.client = new GraphClient(endpoint, database, coll, authKey);

            return(context);
        }
예제 #2
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);
            });
        }