Author: antonello
Date: 2007-04-02 17:29:39 -0400 (Mon, 02 Apr 2007)
New Revision: 75314

Added:
   trunk/olive/tools/sqlmetal/
   trunk/olive/tools/sqlmetal/Assembly/
   trunk/olive/tools/sqlmetal/Assembly/AssemblyInfo.cs
   trunk/olive/tools/sqlmetal/ChangeLog
   trunk/olive/tools/sqlmetal/Makefile
   trunk/olive/tools/sqlmetal/System.Data.Linq/
   trunk/olive/tools/sqlmetal/System.Data.Linq/ConnectionStringFormatter.cs
   trunk/olive/tools/sqlmetal/System.Data.Linq/LinqMapper.cs
   trunk/olive/tools/sqlmetal/System.Data.Linq/ProgramOptions.cs
   trunk/olive/tools/sqlmetal/sqlmetal.exe.sources
Log:
SQLMetal initial commit.

Copied: trunk/olive/tools/sqlmetal (from rev 75308, 
trunk/olive/tools/linqmapper)


Property changes on: trunk/olive/tools/sqlmetal
___________________________________________________________________
Name: svn:ignore
   + LinqMapper.sln
LinqMapper.suo
bin
obj
Properties
LinqMapper.csproj


Added: trunk/olive/tools/sqlmetal/Assembly/AssemblyInfo.cs
===================================================================
--- trunk/olive/tools/linqmapper/Assembly/AssemblyInfo.cs       2007-04-02 
21:03:05 UTC (rev 75308)
+++ trunk/olive/tools/sqlmetal/Assembly/AssemblyInfo.cs 2007-04-02 21:29:39 UTC 
(rev 75314)
@@ -0,0 +1,21 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("LinqMapper")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Deveel")]
+[assembly: AssemblyProduct("LinqMapper")]
+[assembly: AssemblyCopyright("Copyright © Deveel 2007")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("f5df7199-2853-43f9-ba66-a11e94f05d7a")]
+
+[assembly: AssemblyVersion("2.0.0.0")]
+[assembly: AssemblyFileVersion("2.0.0.0")]
+
+[assembly: Mono.UsageComplement("")]

Added: trunk/olive/tools/sqlmetal/ChangeLog
===================================================================

Added: trunk/olive/tools/sqlmetal/Makefile
===================================================================
--- trunk/olive/tools/linqmapper/Makefile       2007-04-02 21:03:05 UTC (rev 
75308)
+++ trunk/olive/tools/sqlmetal/Makefile 2007-04-02 21:29:39 UTC (rev 75314)
@@ -0,0 +1,14 @@
+thisdir = tools/linqmapper
+SUBDIRS = 
+include ../../build/rules.make
+
+LOCAL_MCS_FLAGS = \
+                  /r:System.dll
+                  /r:System.Xml.dll
+                  /r:System.Data.Linq.dll
+                  /r:System.Data.Linq.Design.dll
+                  /r:Mono.GetOptions.dll
+
+PROGRAM = linqmapper.exe
+
+include ../../build/executable.make
\ No newline at end of file

Added: trunk/olive/tools/sqlmetal/System.Data.Linq/ConnectionStringFormatter.cs
===================================================================
--- trunk/olive/tools/linqmapper/System.Data.Linq/ConnectionStringFormatter.cs  
2007-04-02 21:03:05 UTC (rev 75308)
+++ trunk/olive/tools/sqlmetal/System.Data.Linq/ConnectionStringFormatter.cs    
2007-04-02 21:29:39 UTC (rev 75314)
@@ -0,0 +1,82 @@
+using System.Collections.Generic;
+
+namespace System.Data.Linq
+{
+    public abstract class ConnectionStringFormatter
+    {
+        #region .ctor
+        static ConnectionStringFormatter()
+        {
+            formatterTypes = new Dictionary<string, 
Type>(StringComparer.OrdinalIgnoreCase);
+            formatterTypes.Add("mysql", 
typeof(MySqlConnectionStringFormatter));
+            formatterTypes.Add("sql", typeof(SqlConnectionStringFormatter));
+        }
+        #endregion
+
+        #region Fields
+
+        private static readonly Dictionary<String, Type> formatterTypes;
+        private static Dictionary<String, ConnectionStringFormatter> 
formatters;
+
+        #endregion
+
+        #region Public Methods
+
+        public abstract string FormatString(string server, string database, 
string user, string password);
+
+        #endregion
+
+        #region Public Static Methods
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="connectionType"></param>
+        /// <returns></returns>
+        /// <exception cref="ArgumentException">
+        /// If the given <paramref name="connectionType"/> is not supported.
+        /// </exception>
+        public static ConnectionStringFormatter GetFormatter(string 
connectionType)
+        {
+            ConnectionStringFormatter formatter = null;
+            if (formatters != null)
+                formatter = formatters[connectionType];
+
+            if (formatter == null)
+            {
+                Type formatterType = formatterTypes[connectionType];
+                if (formatterType == null)
+                    throw new ArgumentException();
+
+                formatter = 
(ConnectionStringFormatter)Activator.CreateInstance(formatterType);
+
+                if (formatters == null)
+                    formatters = new Dictionary<string, 
ConnectionStringFormatter>(StringComparer.OrdinalIgnoreCase);
+
+                formatters.Add(connectionType, formatter);
+            }
+
+            return formatter;
+        }
+        #endregion
+
+        #region MySqlConnectionStringFormatter
+        class MySqlConnectionStringFormatter : ConnectionStringFormatter
+        {
+            public override string FormatString(string server, string 
database, string user, string password)
+            {
+                throw new Exception("The method or operation is not 
implemented.");
+            }
+        }
+        #endregion
+
+        #region SqlConnectionStringFormatter
+        class SqlConnectionStringFormatter : ConnectionStringFormatter
+        {
+            public override string FormatString(string server, string 
database, string user, string password)
+            {
+                throw new Exception("The method or operation is not 
implemented.");
+            }
+        }
+        #endregion
+    }
+}
\ No newline at end of file

Added: trunk/olive/tools/sqlmetal/System.Data.Linq/LinqMapper.cs
===================================================================
--- trunk/olive/tools/linqmapper/System.Data.Linq/LinqMapper.cs 2007-04-02 
21:03:05 UTC (rev 75308)
+++ trunk/olive/tools/sqlmetal/System.Data.Linq/LinqMapper.cs   2007-04-02 
21:29:39 UTC (rev 75314)
@@ -0,0 +1,42 @@
+using System.Data.Linq.Design;
+
+using Mono.GetOptions;
+
+namespace System.Data.Linq
+{
+    class LinqMapper
+    {
+        static int Main(string[] args)
+        {
+            ProgramOptions opts = new ProgramOptions();
+            opts.ProcessArgs(args);
+
+            if (opts.IsSqlInput)
+            {
+                if (opts.DbType == null)
+                    opts.DbType = "mysql";
+
+                ConnectionStringFormatter stringFormatter = null;
+                try
+                {
+                    stringFormatter = 
ConnectionStringFormatter.GetFormatter(opts.DbType);
+                }
+                catch (ArgumentException)
+                {
+                    Console.Out.WriteLine("Invalid connection type.");
+                    return 1;
+                }
+            }
+            else if (opts.IsXmlInput)
+            {
+                //TODO:
+            }
+            else
+            {
+                return 1;
+            }
+
+            return 0;
+        }
+    }
+}

Added: trunk/olive/tools/sqlmetal/System.Data.Linq/ProgramOptions.cs
===================================================================
--- trunk/olive/tools/linqmapper/System.Data.Linq/ProgramOptions.cs     
2007-04-02 21:03:05 UTC (rev 75308)
+++ trunk/olive/tools/sqlmetal/System.Data.Linq/ProgramOptions.cs       
2007-04-02 21:29:39 UTC (rev 75314)
@@ -0,0 +1,158 @@
+using Mono.GetOptions;
+
+namespace System.Data.Linq
+{
+    public sealed class ProgramOptions : Options
+    {
+        private string inputType;
+        private string outputType;
+        private string inputFile;
+        private string outputFile;
+        private string nspace;
+        private string mapOutputFile;
+        private string language;
+
+        private string dbName;
+        private string server;
+        private string userId;
+        private string password;
+        private string dbType;
+
+        [Option("The ID used for connecting to the database.", "user")]
+        public string UserId
+        {
+            get { return userId; }
+            set { userId = value; }
+        }
+
+        [Option("The password used to connect to the database.", "pass", 
AlternateForm="password")]
+        public string Password
+        {
+            get { return password; }
+            set { password = value; }
+        }
+
+        [Option("The type of source database (eg. MySQL, SQL, Oracle, etc.).", 
"type")]
+        public string DbType
+        {
+            get { return dbType; }
+            set { dbType = value; }
+        }
+
+        public string DbName
+        {
+            get { return dbName; }
+            set { dbName = value; }
+        }
+
+        [Option("The source server of the mapping.", "server")]
+        public string Server
+        {
+            get { return server; }
+            set { 
+                server = value;
+                inputType = "sql";
+            }
+        }
+
+        [Option("The type of input for the mapping (either XML or SQL).", 
"inputType")]
+        public string InputType
+        {
+            get { return inputType; }
+            set { inputType = value; }
+        }
+
+        [Option("Sets the XML output file for the mapping.", "xml")]
+        public string XmlOutput
+        {
+            get { return inputFile; }
+            set
+            {
+                outputType = "xml";
+                outputFile = value;
+            }
+        }
+
+        [Option("Sets the output code file for the mapping", "code")]
+        public string CodeOutput
+        {
+            get { return outputFile; }
+            set
+            {
+                outputType = "code";
+                outputFile = value;
+            }
+        }
+
+        [Option("The language used to export the mapping.", "language")]
+        public string Language
+        {
+            get { return language; }
+            set {
+                switch (value.ToLower())
+                {
+                    case "c#":
+                    case "csharp":
+                    case "vcs":
+                        language = "csharp";
+                        break;
+                    case "visualbasic":
+                    case "vb":
+                    case "vbasic":
+                        language = "vbasic";
+                        break;
+                    default:
+                        throw new ArgumentException("Language '" + value + "' 
not supported.");
+                }
+
+                outputType = "code";
+            }
+        }
+
+        public bool IsXmlInput
+        {
+            get { return String.Compare(inputType, "xml", 
StringComparison.OrdinalIgnoreCase) == 0; }
+        }
+
+        public bool IsSqlInput
+        {
+            get { return String.Compare(inputType, "sql", 
StringComparison.OrdinalIgnoreCase) == 0; }
+        }
+
+        public string OutputType
+        {
+            get { return outputType; }
+            set { outputType = value; }
+        }
+
+        public string InputFile
+        {
+            get { return inputFile; }
+            set { inputFile = value; }
+        }
+
+        public string OutputFile
+        {
+            get { return outputFile; }
+            set { outputFile = value; }
+        }
+
+        public string Namespace
+        {
+            get { return nspace; }
+            set { nspace = value; }
+        }
+
+        public string MapOutputFile
+        {
+            get { return mapOutputFile; }
+            set { mapOutputFile = value; }
+        }
+
+        [KillOption]
+        public override WhatToDoNext DoHelp2()
+        {
+            return base.DoHelp2();
+        }
+    }
+}
\ No newline at end of file

Added: trunk/olive/tools/sqlmetal/sqlmetal.exe.sources
===================================================================
--- trunk/olive/tools/linqmapper/sqlmetal.exe.sources   2007-04-02 21:03:05 UTC 
(rev 75308)
+++ trunk/olive/tools/sqlmetal/sqlmetal.exe.sources     2007-04-02 21:29:39 UTC 
(rev 75314)
@@ -0,0 +1,4 @@
+Assembly/AssemblyInfo.cs
+System.Data.Linq/ConnectionStringFormatter.cs
+System.Data.Linq/LinqMapper.cs
+System.Data.Linq/ProgramOptions.cs
\ No newline at end of file

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to