//private static Runner _Compiler; #endregion //#region (static) StartMonoCSharpREPLShell(Args) ///// <summary> ///// The Mono C# REPL Shell ///// </summary> //public static void StartMonoCSharpREPLShell(params String[] Args) //{ // #region Feel free to step through... // _Compiler = new Runner(); // var a = _Compiler.Execute("Math.Abs(-42);"); // var b = _Compiler.Execute("Math.Sin(Math.PI / 6);"); // var c = _Compiler.Execute("class Fact { public int Run(int n) { return n <= 0 ? 1 : n*Run(n-1); } }"); // var d = _Compiler.Execute("new Fact().Run(5);"); // var e = _Compiler.Execute("\"abcdefgh\".Substring(1, 2);"); // var f = _Compiler.Execute("class Echo { public Object Print(Object o) { return o; } }"); // var g = _Compiler.Execute("var test = 123;"); // var h = _Compiler.Execute("new Echo().Print(test);"); // #endregion // #region Start the interactive (read-eval-print loop) shell... // var _Report = new Report(new ConsoleReportPrinter()); // var _CLP = new CommandLineParser(_Report); // _CLP.UnknownOptionHandler += Mono.Driver.HandleExtraArguments; // var _Settings = _CLP.ParseArguments(Args); // if (_Settings == null || _Report.Errors > 0) // Environment.Exit(1); // var _Evaluator = new Evaluator(_Settings, _Report) // { // InteractiveBaseClass = typeof(InteractiveBaseShell), // DescribeTypeExpressions = true // }; // //// Adding a assembly twice will lead to delayed errors... // //_Evaluator.ReferenceAssembly(typeof(YourAssembly).Assembly); // _Evaluator.ReferenceAssembly(typeof(Bragi).Assembly); // _Evaluator.ReferenceAssembly(typeof(IPropertyGraph).Assembly); // _Evaluator.ReferenceAssembly(typeof(GraphFactory).Assembly); // var u1 = _Compiler.Execute("using de.ahzf.Bragi;"); // var u2 = _Compiler.Execute("using de.ahzf.Blueprints;"); // var u3 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs;"); // var u4 = _Compiler.Execute("using de.ahzf.Balder.PropertyGraphs.InMemory"); // var _CSharpShell = new CSharpShell(_Evaluator, "BragiShell").Run(); // #endregion //} //#endregion /// <summary> /// Main... /// </summary> /// <param name="Args">Arguments...</param> public static void Main(String[] Args) { var _graph = DemoGraphFactory.CreateSimpleGraph(); var Alice = _graph.VertexById("Alice").AsMutable(); var _Pipe1 = new OutEdgesPipe <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe2 = new InVertexPipe <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>(); var _Pipe3 = new PathPipe <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object> >(); var _Pipeline = new Pipeline <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object>, IEnumerable <Object> >(_Pipe1, _Pipe2, _Pipe3); _Pipeline.SetSource(new SingleEnumerator <IReadOnlyGenericPropertyVertex <String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object, String, Int64, String, String, Object> >(Alice)); var x1 = _Pipeline.Select(path => path.Select(q => ((IIdentifier <String>)q).Id).Aggregate((a, b) => a + "|" + b)); var x2 = Alice.OutE().InV().Paths().ToArray(); foreach (var _Path in x1) { //var a0 = _Path.ElementAt(0); //var b0 = _Path.ElementAt(1) is IReadOnlyGenericPropertyEdge <String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; //var c0 = _Path.ElementAt(2) is IReadOnlyGenericPropertyVertex<String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object, // String, Int64, String, String, Object>; } Sigma_js.Start(); //Transactions.Start(); //NotificationsDemo.Start(); //Vanaheimr.Start(); //MulticastDemo.Start(); //PartitionGraphs.Start(); //TraversalGraphs.Start(); //NetworkingDemo.Start(); //TagExample.Start(); //PolyfileReader.Start(); //StartMonoCSharpREPLShell(); // Try to type: // "using de.ahzf.Bragi;" // // and then one of the following... // // "TagExample.Start();" // "ConcurrencyDemo.Start();" // "NetworkingDemo.Start();" // "SmallBenchmark.Start();" }
/// <summary> /// Run the tutorial. /// </summary> public void Run() { var g1 = DemoGraphFactory.Create(); var g2 = g1.AsReadOnly(); using (var GraphServer = new BifrostHTTPServer(new IPPort(8080), (id, descr, init) => GraphFactory.CreateGenericPropertyGraph_WithStringIds(id, descr, () => new VetoVote(), init)) { ServerName = "Vanaheimr Bifrost HTTP Server v0.1" } as IBifrostHTTPServer) { GraphServer.CreateNewGraph("123", "The first graph"); var graph = GraphServer.CreateNewGraph("512", "demo graph", g => g.SetProperty(GraphDBOntology.Description.Suffix, "the second graph").SetProperty("hello", "world!").SetProperty("graphs", "are cool!")); var a1 = graph.ContainsKey("hello"); var a2 = graph.ContainsKey("world!"); var a3 = graph.ContainsKey("graphs"); var a4 = graph.ContainsKey("are cool!"); var a5 = graph.ContainsKey(GraphDBOntology.Description.Suffix); var c1 = graph.ContainsValue(123UL); var t = false; graph.UseProperty("Id", success => t = true); var ii = "i = " + t; var b1 = graph.Contains("Id", 123UL); var b2 = graph is IProperties <String, Object>; var aa = graph.GetProperties(null); var deleted3 = graph.Remove().ToList(); var deleted1 = graph.Remove("hello"); // --------------------------------------------------------------- var v1 = graph.AddVertex(v => v.SetProperty("Name", "Vertex1")); var v2 = graph.AddVertex(v => v.SetProperty("Name", "Vertex2")); var e1 = graph.AddEdge(v1, v2, "knows", e => e.SetProperty("Name", "Edge1")); var allV = graph.Vertices().ToList(); var allE = graph.Edges().ToList(); // --------------------------------------------------------------- //var HTTPClient1 = new HTTPClient(IPv4Address.Parse("127.0.0.1"), new IPPort(8080)); //var _request1 = HTTPClient1.GET("/").//AccountId/RepositoryId/TransactionId/GraphId/VerticesById?Id=2&Id=3"). // SetProtocolVersion(HTTPVersion.HTTP_1_1). // SetUserAgent("Hermod HTTP Client v0.1"). // SetConnection("keep-alive"). // AddAccept(HTTPContentType.JSON_UTF8, 1); //HTTPClient1.Execute(_request1, response => Console.WriteLine(response.Content.ToUTF8String())); //// --------------------------------------------------------------- //var HTTPClient2 = new HTTPClient(IPv4Address.Parse("127.0.0.1"), new IPPort(8080)); //var _request2 = HTTPClient2.GET("/123/description").//AccountId/RepositoryId/TransactionId/GraphId/VerticesById?Id=2&Id=3"). // SetProtocolVersion(HTTPVersion.HTTP_1_1). // SetUserAgent("Hermod HTTP Client v0.1"). // SetConnection("keep-alive"). // AddAccept(HTTPContentType.JSON_UTF8, 1); //HTTPClient2.Execute(_request2, response => Console.WriteLine(response.Content.ToUTF8String())); // --------------------------------------------------------------- //#if !__MonoCS__ // var JavaScriptEngine = new Jurassic.ScriptEngine(); // //Console.WriteLine(engine.Evaluate("5 * 10 + 2")); // //engine.SetGlobalValue("interop", 15); // //engine.ExecuteFile(@"c:\test.js"); // //engine.Evaluate("interop = interop + 5"); // //Console.WriteLine(engine.GetGlobalValue<int>("interop")); // JavaScriptEngine.Evaluate("function VertexFilter(vertex) { return vertex.Name == 'Vertex1' }"); // foreach (var Vertex in graph.Vertices()) // { // //engine.SetGlobalValue("vertex", new JSPropertyVertex(_vv, engine)); // //engine.SetGlobalFunction("test", new Func<int, int, int>((a, b) => a + b)); // //Console.WriteLine(engine.Evaluate<int>("test(5, 6)")); // //engine.Evaluate("var yesorno = vertex.Id > 1"); // //var Id = engine.GetGlobalValue ("vertex.Id"); // //var yesorno = engine.GetGlobalValue<Boolean>("yesorno"); // if (JavaScriptEngine.CallGlobalFunction<Boolean>("VertexFilter", new JSPropertyVertex(Vertex, JavaScriptEngine))) // Console.WriteLine(Vertex.Id); // } // var aaa = from V2 // in graph.Vertices() // where JavaScriptEngine.CallGlobalFunction<Boolean>("VertexFilter", new JSPropertyVertex(V2, JavaScriptEngine)) // select V2; // var aaaa = aaa.ToList(); // var GraphClient = new RemotePropertyGraph(IPv4Address.Parse("127.0.0.1"), new IPPort(8080)) { Id = 512 }; // Console.WriteLine(GraphClient.Description); // //foreach (var V3 in GraphClient.Vertices()) // // Console.WriteLine(V3.Id); //#endif while (true) { Thread.Sleep(100); } } }