コード例 #1
0
ファイル: config.cs プロジェクト: midgardproject/midgard-mono
        public static void Main(string[] args)
        {
            // Initialize midgard
            Midgard.Lib.Init ();

            // Create midgard config connection
            Midgard.Config cfg = new Midgard.Config ();
            cfg.DatabaseType = "SQLite";
            cfg.DatabaseName = "midgard";
            cfg.SaveFile ("monotest", true);

            // Show config properties
            Console.WriteLine ("Creating Midgard config...");
            Console.WriteLine ("> DatabaseType={0}", cfg.DatabaseType);
            Console.WriteLine ("> DatabaseName={0}", cfg.DatabaseName);
            Console.WriteLine ("");

            // Read config file to check values
            Midgard.Config chkcfg = new Midgard.Config ();
            chkcfg.ReadFile ("monotest", true);

            // Show loaded values
            Console.WriteLine ("Checking config...");
            Console.WriteLine ("> DatabaseType={0}", chkcfg.DatabaseType);
            Console.WriteLine ("> DatabaseName={0}", chkcfg.DatabaseName);
            Console.WriteLine ("");

            // Try to connect
            Connection conn = new Midgard.Connection ();
            if (!conn.OpenConfig (chkcfg))
                Console.WriteLine ("Connection failed!");
            else
                Console.WriteLine ("Connection established!");
        }
コード例 #2
0
ファイル: schema.cs プロジェクト: midgardproject/midgard-mono
        public static void Main(string[] args)
        {
            // Initialize midgard
            Midgard.Lib.Init ();

            // Create midgard config connection
            Midgard.Config cfg = new Midgard.Config ();
            cfg.DatabaseType = "SQLite";
            cfg.DatabaseName = "midgard";

            // Try to connect
            Connection conn = new Midgard.Connection ();
            if (!conn.OpenConfig (cfg)) {
                Console.WriteLine ("Connection failed");
                return;
            }
            Console.WriteLine ("Connection established");

            // Create midgard tables
            /*if (!cfg.CreateMidgardTables (conn)) {
                Console.WriteLine ("Tables initialization failed");
                return;
            }
            Console.WriteLine ("Tables sucefully created");

            Midgard.Object person = new Midgard.Object (conn, "person", new GLib.Value (1));
            Console.WriteLine (">> {0}", person);*/
        }