コード例 #1
0
        public static void Main(string[] args)
        {
            try
              {
            // create session
            Session session = new Session("localhost", 1984, "admin", "admin");

            // define InputStream
            MemoryStream ms = new MemoryStream(
              System.Text.Encoding.UTF8.GetBytes("<xml>Hello World!</xml>"));

            // create database
            session.Create("database", ms);
            Console.WriteLine(session.Info);

            // run query on database
            Console.WriteLine(session.Execute("xquery /"));

            // drop database
            session.Execute("drop db database");

            // close session
            session.Close();
              }
              catch (IOException e)
              {
            // print exception
            Console.WriteLine(e.Message);
              }
        }
コード例 #2
0
ファイル: Example.cs プロジェクト: rosishadura/basex-api
        public static void Main(string[] args)
        {
            try
              {
            // initialize timer
            Stopwatch watch = new Stopwatch();
            watch.Start();

            // create session
            Session session = new Session("localhost", 1984, "admin", "admin");

            // version 1: perform command and print returned string
            Console.WriteLine(session.Execute("info"));

            // version 2 (faster): perform command and pass on result to output stream
            Stream stream = Console.OpenStandardOutput();
            session.Execute("xquery 1 to 10", stream);

            // close session
            session.Close();

            // print time needed
            Console.WriteLine("\n" + watch.ElapsedMilliseconds + " ms.");
              }
              catch (IOException e)
              {
            // print exception
            Console.WriteLine(e.Message);
              }
        }
コード例 #3
0
ファイル: EventExample.cs プロジェクト: bhuesemann/basex-api
        public static void Main(string[] args)
        {
            try
              {
            // create session
            Session session1 = new Session("localhost", 1984, "admin", "admin");
            Session session2 = new Session("localhost", 1984, "admin", "admin");

            session1.Execute("create event messenger");
            session2.Watch("messenger", new Notification());
            session2.Query("for $i in 1 to 1000000 where $i = 0 return $i").Execute();
            session1.Query("db:event('messenger', 'Hello World!')").Execute();
            session2.Unwatch("messenger");
            session1.Execute("drop event messenger");

            // close session
            session1.Close();
            session2.Close();
              }
              catch (IOException e)
              {
            // print exception
            Console.WriteLine(e.Message);
              }
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            try
              {
            // create session
            Session session = new Session("localhost", 1984, "admin", "admin");

            try
            {
              // create query instance
              string input = "declare variable $name external;" +
              	"for $i in 1 to 10 return element { $name } { $i }";

              Query query = session.Query(input);

              // bind variable
              query.Bind("$name", "number");

              // initialize query
              Console.WriteLine(query.Init());

              // loop through all results
              while (query.More())
              {
            Console.WriteLine(query.Next());
              }

              // close query
              Console.WriteLine(query.Close());
            }
            catch (IOException e)
            {
              // print exception
              Console.WriteLine(e.Message);
            }

            // close session
            session.Close();
              }
              catch (IOException e)
              {
            // print exception
            Console.WriteLine(e.Message);
              }
        }
コード例 #5
0
        public static void Main(string[] args)
        {
            try
              {
            // create session
            Session session = new Session("localhost", 1984, "admin", "admin");

            try
            {
              // create query instance
              string input = "for $i in 1 to 10 return <xml>Text { $i }</xml>";
              Query query = session.Query(input);

              // initialize query
              Console.WriteLine(query.Init());

              // loop through all results
              while (query.More())
              {
            Console.WriteLine(query.Next());
              }

              // close query
              Console.WriteLine(query.Close());
            }
            catch (IOException e)
            {
              // print exception
              Console.WriteLine(e.Message);
            }

            // close session
            session.Close();
              }
              catch (IOException e)
              {
            // print exception
            Console.WriteLine(e.Message);
              }
        }
コード例 #6
0
ファイル: BaseXClient.cs プロジェクト: ferrarimartin/basex
 public Query(Session s, string query)
 {
     session = s;
       id = Exec(0, query);
 }