├── .gitignore ├── AutomaticUpdates ├── AutomaticUpdates.csproj ├── BugFixInfo.cs ├── FeatureInfo.cs ├── Properties │ └── AssemblyInfo.cs ├── UpdateEngine.cs └── VersionUpdateInfo.cs ├── Common ├── Common.csproj ├── LicenseDetails.cs ├── Properties │ └── AssemblyInfo.cs └── UserCancellationException.cs ├── CreateTestDatabases ├── CreateDataChecks_1.cs ├── CreateDataChecks_2.cs ├── CreateDataChecks_3.cs ├── CreateTestDatabases.csproj ├── CreateTriggerChecks_1.cs ├── IDatabasePairCreator.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── TestSchemaFiles │ └── schema_1.sql ├── Utils.cs ├── app.config └── packages.config ├── DiffControl ├── BinaryFile.cs ├── ChangeTextAction.cs ├── CharData.cs ├── DiffBar.cs ├── DiffControl.csproj ├── DiffEditBox.cs ├── DiffSnapshot.cs ├── DualDiffControl.Designer.cs ├── DualDiffControl.cs ├── DualDiffControl.resx ├── Engine.cs ├── LineRecord.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Structures.cs └── TextFile.cs ├── FastGrid ├── FastGrid.cs ├── FastGrid.csproj ├── FastGridCell.cs ├── FastGridCheckBoxCell.cs ├── FastGridColumn.cs ├── FastGridLocation.cs ├── FastGridRow.cs ├── FastGridSelection.cs ├── FastGridStyle.cs └── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── LICENSE ├── SQLiteParser ├── .gitignore ├── Properties │ └── AssemblyInfo.cs ├── RefCompare.cs ├── SQLiteBetweenExpression.cs ├── SQLiteBinaryExpression.cs ├── SQLiteCaseExpression.cs ├── SQLiteCaseItem.cs ├── SQLiteCastExpression.cs ├── SQLiteCheckColumnConstraint.cs ├── SQLiteCheckTableConstraint.cs ├── SQLiteCollateColumnConstraint.cs ├── SQLiteCollateExpression.cs ├── SQLiteColumnConstraint.cs ├── SQLiteColumnStatement.cs ├── SQLiteColumnType.cs ├── SQLiteCreateIndexStatement.cs ├── SQLiteCreateTableStatement.cs ├── SQLiteCreateTriggerStatement.cs ├── SQLiteCreateViewStatement.cs ├── SQLiteDdlMain.cs ├── SQLiteDdlStatement.cs ├── SQLiteDefaultColumnConstraint.cs ├── SQLiteDeferColumnConstraint.cs ├── SQLiteDeleteStatement.cs ├── SQLiteDistinct.cs ├── SQLiteExistsExpression.cs ├── SQLiteExpression.cs ├── SQLiteForeignKeyTableConstraint.cs ├── SQLiteFromClause.cs ├── SQLiteFromIndexed.cs ├── SQLiteFromInternalTable.cs ├── SQLiteFromTable.cs ├── SQLiteFunctionExpression.cs ├── SQLiteIdExpression.cs ├── SQLiteInExpression.cs ├── SQLiteIndexedColumn.cs ├── SQLiteInsertPrefix.cs ├── SQLiteInsertStatement.cs ├── SQLiteJoinOperator.cs ├── SQLiteLikeExpression.cs ├── SQLiteLikeOperator.cs ├── SQLiteLimitClause.cs ├── SQLiteMultiSelectStatement.cs ├── SQLiteNameExpression.cs ├── SQLiteNullColumnConstraint.cs ├── SQLiteNullExpression.cs ├── SQLiteObjectName.cs ├── SQLiteOperator.cs ├── SQLiteParser.csproj ├── SQLitePrimaryKeyColumnConstraint.cs ├── SQLitePrimaryKeyTableConstraint.cs ├── SQLiteRaiseExpression.cs ├── SQLiteReferenceHandler.cs ├── SQLiteReferencesColumnConstraint.cs ├── SQLiteResolveAction.cs ├── SQLiteSchema.cs ├── SQLiteSelectColumn.cs ├── SQLiteSelectExpression.cs ├── SQLiteSelectOperator.cs ├── SQLiteSelectStatement.cs ├── SQLiteSingleSelectStatement.cs ├── SQLiteSortItem.cs ├── SQLiteStatement.cs ├── SQLiteTableConstraint.cs ├── SQLiteTerm.cs ├── SQLiteTermExpression.cs ├── SQLiteTriggerEventClause.cs ├── SQLiteTriggerTime.cs ├── SQLiteUnaryExpression.cs ├── SQLiteUniqueColumnConstraint.cs ├── SQLiteUniqueTableConstraint.cs ├── SQLiteUpdateItem.cs ├── SQLiteUpdateStatement.cs ├── SQLiteVariableExpression.cs ├── Utils.cs ├── sqlite.lex └── sqlite.y ├── SQLiteTurbo ├── AbstractWorker.cs ├── App.config ├── BlobCompareWorker.cs ├── BlobCopier.cs ├── BlobLoader.cs ├── BlobReaderWriter.cs ├── BlobSaver.cs ├── ChangeScriptBuilder.cs ├── CompareParams.cs ├── CompareWorker.cs ├── Configuration.cs ├── DiffExporter.cs ├── EtchedLine.cs ├── Forms │ ├── AboutDialog.Designer.cs │ ├── AboutDialog.cs │ ├── AboutDialog.resx │ ├── CellValueEditorDialog.Designer.cs │ ├── CellValueEditorDialog.cs │ ├── CellValueEditorDialog.resx │ ├── ChangeScriptDialog.Designer.cs │ ├── ChangeScriptDialog.cs │ ├── ChangeScriptDialog.resx │ ├── CheckUpdatesDialog.Designer.cs │ ├── CheckUpdatesDialog.cs │ ├── CheckUpdatesDialog.resx │ ├── CompareDialog.Designer.cs │ ├── CompareDialog.cs │ ├── CompareDialog.resx │ ├── ExportChangesDialog.Designer.cs │ ├── ExportChangesDialog.cs │ ├── ExportChangesDialog.resx │ ├── FeedbackDialog.Designer.cs │ ├── FeedbackDialog.cs │ ├── FeedbackDialog.resx │ ├── FirstTimeDialog.Designer.cs │ ├── FirstTimeDialog.cs │ ├── FirstTimeDialog.resx │ ├── HttpPostSenderDialog.Designer.cs │ ├── HttpPostSenderDialog.cs │ ├── HttpPostSenderDialog.resx │ ├── IndefiniteProgressDialog.Designer.cs │ ├── IndefiniteProgressDialog.cs │ ├── IndefiniteProgressDialog.resx │ ├── LicenseRegistrationDialog.Designer.cs │ ├── LicenseRegistrationDialog.cs │ ├── LicenseRegistrationDialog.resx │ ├── MainForm.Designer.cs │ ├── MainForm.cs │ ├── MainForm.resx │ ├── ProgressDialog.Designer.cs │ ├── ProgressDialog.cs │ ├── ProgressDialog.resx │ ├── SearchDataRowsDialog.Designer.cs │ ├── SearchDataRowsDialog.cs │ ├── SearchDataRowsDialog.resx │ ├── SoftwareUpdatesDetailsDialog.Designer.cs │ ├── SoftwareUpdatesDetailsDialog.cs │ ├── SoftwareUpdatesDetailsDialog.resx │ ├── TwoWayCompareEditDialog.Designer.cs │ ├── TwoWayCompareEditDialog.cs │ ├── TwoWayCompareEditDialog.resx │ ├── UnexpectedErrorDialog.Designer.cs │ ├── UnexpectedErrorDialog.cs │ └── UnexpectedErrorDialog.resx ├── IWorker.cs ├── ItemCopier.cs ├── LicenseManager.cs ├── LocalUserFileAppender.cs ├── MailSender.cs ├── PostSubmitter.cs ├── Program.cs ├── ProgressEventArgs.cs ├── Properties │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── app.ico │ ├── appicon.ico │ ├── feedback2.png │ ├── feedback_non_selected_idea.png │ ├── feedback_non_selected_question.png │ ├── feedback_pressed.png │ ├── feedback_problem_non_selected.png │ ├── feedback_problem_selected.png │ ├── feedback_selected_idea.png │ ├── feedback_selected_question.png │ ├── normal_feedback_button.png │ └── pressed_feedback_button.png ├── RowsCopier.cs ├── RowsDeleter.cs ├── SQLiteTurbo.csproj ├── SchemaComparisonItem.cs ├── SchemaComparisonView.Designer.cs ├── SchemaComparisonView.cs ├── SchemaComparisonView.resx ├── SchemaObjectUpdater.cs ├── ScrollableDataGridView.cs ├── ScrollableTreeView.cs ├── SearchDataWorker.cs ├── SelectionBar.cs ├── SendEmailWorker.cs ├── SpinningProgress.Designer.cs ├── SpinningProgress.cs ├── SpinningProgress.resx ├── SyncWorker.cs ├── SyntaxRichTextBox.cs ├── TableChangeItem.cs ├── TableChanges.cs ├── TableCompareWorker.cs ├── TableDiffControl.Designer.cs ├── TableDiffControl.cs ├── TableDiffControl.resx ├── UserSurveyDialog.Designer.cs ├── UserSurveyDialog.cs ├── UserSurveyDialog.resx ├── Utils.cs ├── WebSiteUtils.cs ├── packages.config └── sqlite.syn ├── SQLiteTurboDiff.sln ├── SVG ├── about.svg ├── accept.svg ├── app.svg ├── appicon.svg ├── bug.svg ├── check_updates.svg ├── close_comparison.svg ├── company_tagline.svg ├── compare.svg ├── copy_from_left_db.svg ├── copy_from_right_db.svg ├── edit_selected_difference.svg ├── feather.svg ├── feedback.svg ├── feedback_frame.svg ├── feedback_non_selected_idea.svg ├── feedback_non_selected_problem.svg ├── feedback_question.svg ├── feedback_selected_problem.svg ├── feedback_selected_question.svg ├── finish_page_banner.svg ├── free.svg ├── generate_script_left_to_right.svg ├── generate_script_right_to_left.svg ├── greenpinesoftware_logo.svg ├── home_screenshot.svg ├── installer_banner.svg ├── key.svg ├── lamp.svg ├── lamp_non_selected.svg ├── lamp_selected.svg ├── lock.svg ├── main_screen.svg ├── next_diff.svg ├── prev_diff.svg ├── question.svg ├── recycle_bin.svg ├── redo.svg ├── reject.svg ├── reorder_columns.svg ├── save_schema.svg ├── search.svg ├── smallbug.svg ├── sqlite_compare_logo.svg ├── sqlite_feather.svg ├── text2451.png ├── undo.svg ├── uninstall.svg └── v_bullet.svg ├── Setup ├── Thumbs.db ├── appicon.ico ├── changes.txt ├── finish_banner.bmp ├── installer_banner.bmp ├── setup.nsi └── uninstallicon.ico ├── ShiftReduceParser.dll ├── SolutionInfo.cs ├── UndoRedo ├── ActionRecord.cs ├── Properties │ └── AssemblyInfo.cs ├── UndoManager.cs ├── UndoRedo.csproj └── UndoableAction.cs ├── eula.txt ├── gplex.exe ├── gplexx.frame ├── gppg.exe ├── license.lic └── readme.txt /AutomaticUpdates/BugFixInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AutomaticUpdates 6 | { 7 | /// 8 | /// Contains information regarding a bug that was fixed 9 | /// 10 | [Serializable] 11 | public class BugFixInfo 12 | { 13 | public BugFixInfo() 14 | { 15 | } 16 | 17 | public BugFixInfo(BugSeverity severity, string description) 18 | { 19 | _severity = severity; 20 | _description = description; 21 | } 22 | 23 | /// 24 | /// Get the severity level of the bug 25 | /// 26 | public BugSeverity Severity 27 | { 28 | get { return _severity; } 29 | set { _severity = value; } 30 | } 31 | 32 | /// 33 | /// Get the description of the bug 34 | /// 35 | public string Description 36 | { 37 | get { return _description; } 38 | set { _description = value; } 39 | } 40 | 41 | private BugSeverity _severity; 42 | private string _description; 43 | } 44 | 45 | /// 46 | /// Enumerates the possible severity levels for bugs 47 | /// 48 | public enum BugSeverity 49 | { 50 | None = 0, 51 | 52 | Minor = 1, 53 | 54 | Major = 2, 55 | 56 | Critical = 3, 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /AutomaticUpdates/FeatureInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AutomaticUpdates 6 | { 7 | /// 8 | /// Describes a feature that was added to the software 9 | /// 10 | [Serializable] 11 | public class FeatureInfo 12 | { 13 | public FeatureInfo() 14 | { 15 | } 16 | 17 | /// 18 | /// Creates a new feature info object with the specified impact and description 19 | /// 20 | /// The impact of the feature 21 | /// The description of the feature 22 | public FeatureInfo(FeatureImpact impact, string description) 23 | { 24 | _impact = impact; 25 | _description = description; 26 | } 27 | 28 | /// 29 | /// Get the impact of the feature on the system 30 | /// 31 | public FeatureImpact Impact 32 | { 33 | get { return _impact; } 34 | set { _impact = value; } 35 | } 36 | 37 | /// 38 | /// Get the description of the feature 39 | /// 40 | public string Description 41 | { 42 | get { return _description; } 43 | set { _description = value; } 44 | } 45 | 46 | private FeatureImpact _impact; 47 | private string _description; 48 | } 49 | 50 | /// 51 | /// Describes the impart of the added feature 52 | /// 53 | public enum FeatureImpact 54 | { 55 | None = 0, 56 | 57 | Minor = 1, 58 | 59 | Major = 2, 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /AutomaticUpdates/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | -------------------------------------------------------------------------------- /AutomaticUpdates/VersionUpdateInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace AutomaticUpdates 6 | { 7 | /// 8 | /// This class describes the various updates that occured from the last version to 9 | /// the current version. It also includes the version string of the current version 10 | /// and the version string of the previous version. 11 | /// 12 | [Serializable] 13 | public class VersionUpdateInfo 14 | { 15 | #region Constructors 16 | public VersionUpdateInfo() 17 | { 18 | } 19 | 20 | public VersionUpdateInfo(string version, DateTime releaseDate) 21 | { 22 | _version = version; 23 | _releaseDate = releaseDate; 24 | } 25 | #endregion 26 | 27 | #region Public Properties 28 | public string Version 29 | { 30 | get { return _version; } 31 | set { _version = value; } 32 | } 33 | 34 | public DateTime ReleaseDate 35 | { 36 | get { return _releaseDate; } 37 | set { _releaseDate = value; } 38 | } 39 | 40 | public List FixedBugs 41 | { 42 | get { return _fixedBugs; } 43 | set { _fixedBugs = value; } 44 | } 45 | 46 | public List AddedFeatures 47 | { 48 | get { return _addedFeatures; } 49 | set { _addedFeatures = value; } 50 | } 51 | #endregion 52 | 53 | #region Private Variables 54 | private string _version; 55 | private DateTime _releaseDate; 56 | private List _fixedBugs = new List(); 57 | private List _addedFeatures = new List(); 58 | #endregion 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Common/LicenseDetails.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Common 6 | { 7 | /// 8 | /// This class holds the license information 9 | /// 10 | [Serializable] 11 | public class LicenseDetails 12 | { 13 | public int DemoDays 14 | { 15 | get 16 | { 17 | return _demoDays; 18 | } 19 | set 20 | { 21 | _demoDays = value; 22 | } 23 | } 24 | 25 | public string CustomerName 26 | { 27 | get { return _customerName; } 28 | set { _customerName = value; } 29 | } 30 | 31 | public string ContactEmail 32 | { 33 | get { return _email; } 34 | set { _email = value; } 35 | } 36 | 37 | public int NumberOfSeats 38 | { 39 | get { return _numberOfSeats; } 40 | set { _numberOfSeats = value; } 41 | } 42 | 43 | public LicenseUsage Usage 44 | { 45 | get { return _usage; } 46 | set { _usage = value; } 47 | } 48 | 49 | public bool IsSiteLicense 50 | { 51 | get { return _siteLicense; } 52 | set { _siteLicense = value; } 53 | } 54 | 55 | public override string ToString() 56 | { 57 | return _demoDays+DELIM+_customerName + DELIM + _usage.ToString() + DELIM + _numberOfSeats.ToString() + DELIM + _siteLicense.ToString()+DELIM+_email; 58 | } 59 | 60 | public static LicenseDetails Parse(string str) 61 | { 62 | string[] parts = str.Split(new string[] { "!+-!" }, StringSplitOptions.None); 63 | if (parts.Length != 6) 64 | throw new ArgumentException("illegal license string"); 65 | 66 | LicenseDetails res = new LicenseDetails(); 67 | res._demoDays = int.Parse(parts[0]); 68 | res._customerName = parts[1]; 69 | res._usage = (LicenseUsage)Enum.Parse(typeof(LicenseUsage), parts[2]); 70 | res._numberOfSeats = int.Parse(parts[3]); 71 | res._siteLicense = bool.Parse(parts[4]); 72 | res._email = parts[5]; 73 | return res; 74 | } 75 | 76 | private const string DELIM = "!+-!"; 77 | 78 | private bool _siteLicense; 79 | private LicenseUsage _usage; 80 | private int _numberOfSeats; 81 | private string _customerName; 82 | private int _demoDays; 83 | private string _email; 84 | } 85 | 86 | public enum LicenseUsage 87 | { 88 | Demo = 0, 89 | 90 | Academic = 1, 91 | 92 | Personal = 2, 93 | 94 | Commercial = 3, 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Common")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Common")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c4e2c7bf-fb4e-4b18-8ca2-cfc04b4142ed")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /Common/UserCancellationException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Common 6 | { 7 | /// 8 | /// Used to indicate that the user chose to cancel the operation 9 | /// 10 | public class UserCancellationException : Exception 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /CreateTestDatabases/CreateDataChecks_1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Data.SQLite; 6 | 7 | namespace CreateTestDatabases 8 | { 9 | public class CreateDataChecks_1 : IDatabasePairCreator 10 | { 11 | 12 | #region IDatabasePairCreator Members 13 | 14 | public void CreatePair(string db1, string db2) 15 | { 16 | if (File.Exists(db1)) 17 | File.Delete(db1); 18 | if (File.Exists(db2)) 19 | File.Delete(db2); 20 | SQLiteConnection.CreateFile(db1); 21 | 22 | using (SQLiteConnection c1 = Utils.CreateConnection(db1)) 23 | { 24 | c1.Open(); 25 | 26 | Utils.RunCommand( 27 | @" CREATE TABLE test1 " + 28 | @" (" + 29 | @" tblob TINYBLOB, " + 30 | @" blob BLOB, " + 31 | @" mblob MEDIUMBLOB, " + 32 | @" ba BYTEA" + 33 | @" )", c1); 34 | 35 | byte[] f1 = new byte[] { 1 }; 36 | byte[] f2 = new byte[] { 1, 2 }; 37 | byte[] f3 = new byte[] { 1, 2, 3 }; 38 | byte[] f4 = new byte[] { 1, 2, 3, 4 }; 39 | 40 | byte[][] tarr = new byte[][] { f1, f2, f3, f4 }; 41 | 42 | SQLiteTransaction tx1 = c1.BeginTransaction(); 43 | InsertData(tarr, c1, tx1); 44 | tx1.Commit(); 45 | 46 | File.Copy(db1, db2); 47 | } // using 48 | } 49 | 50 | private void InsertData(byte[][] tarr, SQLiteConnection conn, SQLiteTransaction tx) 51 | { 52 | Random rand = new Random(); 53 | SQLiteCommand insert = new SQLiteCommand("INSERT INTO test1 (tblob,blob,mblob,ba) VALUES (@f1, @f2, @f3, @f4)", conn, tx); 54 | insert.Parameters.Add("@f1", System.Data.DbType.Binary); 55 | insert.Parameters.Add("@f2", System.Data.DbType.Binary); 56 | insert.Parameters.Add("@f3", System.Data.DbType.Binary); 57 | insert.Parameters.Add("@f4", System.Data.DbType.Binary); 58 | 59 | for (int i = 0; i < 100; i++) 60 | { 61 | for (int k = 1; k <= tarr.Length; k++) 62 | { 63 | int index = rand.Next(0, tarr.Length - 1); 64 | insert.Parameters["@f" + k].Value = tarr[index]; 65 | } 66 | insert.ExecuteNonQuery(); 67 | } // for 68 | } 69 | 70 | #endregion 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /CreateTestDatabases/CreateDataChecks_2.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Data.SQLite; 5 | using System.IO; 6 | 7 | namespace CreateTestDatabases 8 | { 9 | public class CreateDataChecks_2 : IDatabasePairCreator 10 | { 11 | #region IDatabasePairCreator Members 12 | 13 | public void CreatePair(string db1, string db2) 14 | { 15 | if (File.Exists(db1)) 16 | File.Delete(db1); 17 | if (File.Exists(db2)) 18 | File.Delete(db2); 19 | SQLiteConnection.CreateFile(db1); 20 | 21 | using (SQLiteConnection c1 = Utils.CreateConnection(db1)) 22 | { 23 | c1.Open(); 24 | 25 | Utils.RunCommand( 26 | @" CREATE TABLE test1 " + 27 | @" (" + 28 | @" ascending integer NOT NULL PRIMARY KEY," + 29 | @" t1 char," + 30 | @" t2 char(10),"+ 31 | @" t3 varchar,"+ 32 | @" t4 varchar(50),"+ 33 | @" t5 nchar,"+ 34 | @" t6 nchar(10),"+ 35 | @" t7 text,"+ 36 | @" t8 tinytext,"+ 37 | @" t9 mediumtext,"+ 38 | @" t10 longtext"+ 39 | @" )", c1); 40 | 41 | SQLiteTransaction tx1 = c1.BeginTransaction(); 42 | InsertData(c1, tx1); 43 | tx1.Commit(); 44 | 45 | File.Copy(db1, db2); 46 | } // using 47 | } 48 | 49 | #endregion 50 | 51 | private void InsertData(SQLiteConnection conn, SQLiteTransaction tx) 52 | { 53 | Random rand = new Random(); 54 | SQLiteCommand insert = new SQLiteCommand("INSERT INTO test1 " + 55 | "(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) VALUES " + 56 | "('a','b','c','d','e','f','e','g','h','i')", conn, tx); 57 | 58 | for (int i = 0; i < 100; i++) 59 | { 60 | insert.ExecuteNonQuery(); 61 | } // for 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /CreateTestDatabases/CreateDataChecks_3.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Data.SQLite; 5 | using System.IO; 6 | 7 | namespace CreateTestDatabases 8 | { 9 | public class CreateDataChecks_3 : IDatabasePairCreator 10 | { 11 | #region IDatabasePairCreator Members 12 | 13 | public void CreatePair(string db1, string db2) 14 | { 15 | if (File.Exists(db1)) 16 | File.Delete(db1); 17 | if (File.Exists(db2)) 18 | File.Delete(db2); 19 | SQLiteConnection.CreateFile(db1); 20 | 21 | using (SQLiteConnection c1 = Utils.CreateConnection(db1)) 22 | { 23 | c1.Open(); 24 | 25 | Utils.RunCommand( 26 | "CREATE TABLE log (" + 27 | " id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," + 28 | " user_id INTEGER NULL DEFAULT NULL," + 29 | " type_id INTEGER NOT NULL," + 30 | " severity_id TINYINT NOT NULL," + 31 | " message VARCHAR(255) NOT NULL," + 32 | " data LONGBLOB NULL," + 33 | " timestamp DATETIME NOT NULL," + 34 | " ip INTEGER UNSIGNED NOT NULL" + 35 | " )", c1); 36 | 37 | Utils.RunCommand( 38 | "CREATE TABLE test1 (" + 39 | " a," + 40 | " b COLLATE BINARY," + 41 | " c COLLATE RTRIM," + 42 | " d COLLATE NOCASE" + 43 | ")", c1); 44 | 45 | SQLiteTransaction tx1 = c1.BeginTransaction(); 46 | InsertData(c1, tx1); 47 | tx1.Commit(); 48 | 49 | File.Copy(db1, db2); 50 | } // using 51 | } 52 | 53 | #endregion 54 | 55 | private void InsertData(SQLiteConnection conn, SQLiteTransaction tx) 56 | { 57 | Random rand = new Random(); 58 | SQLiteCommand insert1 = new SQLiteCommand("INSERT INTO log " + 59 | "(user_id,type_id,severity_id,message,data, timestamp,ip) VALUES " + 60 | "(1,2,3,'message',X'01020304','2004-12-12',4)", conn, tx); 61 | 62 | SQLiteCommand insert2 = new SQLiteCommand("INSERT INTO test1 (a,b,c,d) VALUES " + 63 | "(1,2,'c','d')", conn, tx); 64 | 65 | for (int i = 0; i < 100; i++) 66 | { 67 | insert1.ExecuteNonQuery(); 68 | insert2.ExecuteNonQuery(); 69 | } // for 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /CreateTestDatabases/IDatabasePairCreator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CreateTestDatabases 6 | { 7 | public interface IDatabasePairCreator 8 | { 9 | void CreatePair(string db1, string db2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /CreateTestDatabases/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace CreateTestDatabases 6 | { 7 | class Program 8 | { 9 | static IDatabasePairCreator[] _checks = new IDatabasePairCreator[] 10 | { 11 | new CreateDataChecks_1(), 12 | new CreateDataChecks_2(), 13 | new CreateDataChecks_3(), 14 | new CreateTriggerChecks_1(), 15 | }; 16 | 17 | static void Main(string[] args) 18 | { 19 | for (int i = 0; i < _checks.Length; i++) 20 | { 21 | // Mickey Mouse 22 | _checks[i].CreatePair("test_left_" + i + ".db", "test_right_" + i + ".db"); 23 | } // for 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CreateTestDatabases/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CreateTestDatabases")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("CreateTestDatabases")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9b62b035-d4df-4de6-8d83-45e29678016b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /CreateTestDatabases/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Data.SQLite; 5 | 6 | namespace CreateTestDatabases 7 | { 8 | public class Utils 9 | { 10 | public static SQLiteConnection CreateConnection(string dbpath) 11 | { 12 | SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder(); 13 | builder.DataSource = dbpath; 14 | return new SQLiteConnection(builder.ConnectionString); 15 | } 16 | 17 | public static void RunCommand(string command, params SQLiteConnection[] clist) 18 | { 19 | foreach (SQLiteConnection conn in clist) 20 | { 21 | SQLiteCommand cmd = new SQLiteCommand(command, conn); 22 | cmd.ExecuteNonQuery(); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /CreateTestDatabases/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /CreateTestDatabases/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DiffControl/BinaryFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections; 4 | 5 | namespace DifferenceEngine 6 | { 7 | public class DiffList_BinaryFile : IDiffList 8 | { 9 | private byte[] _byteList; 10 | 11 | public DiffList_BinaryFile(string fileName) 12 | { 13 | FileStream fs = null; 14 | BinaryReader br = null; 15 | try 16 | { 17 | fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); 18 | int len = (int)fs.Length; 19 | br = new BinaryReader(fs); 20 | _byteList = br.ReadBytes(len); 21 | } 22 | catch (Exception ex) 23 | { 24 | throw ex; 25 | } 26 | finally 27 | { 28 | if (br != null) br.Close(); 29 | if (fs != null) fs.Close(); 30 | } 31 | 32 | } 33 | #region IDiffList Members 34 | 35 | public int Count() 36 | { 37 | return _byteList.Length; 38 | } 39 | 40 | public IComparable GetByIndex(int index) 41 | { 42 | return _byteList[index]; 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /DiffControl/ChangeTextAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using UndoRedo; 5 | 6 | namespace DiffControl 7 | { 8 | /// 9 | /// Encapsulates the case when any element of text was changed 10 | /// in one of the two diff edit boxes (dual diff control) 11 | /// 12 | public class ChangeTextAction : UndoableAction 13 | { 14 | public ChangeTextAction(DiffEditBox left, DiffEditBox right, 15 | DiffSnapshot beforeLeft, DiffSnapshot afterLeft, 16 | DiffSnapshot beforeRight, DiffSnapshot afterRight) 17 | { 18 | _left = left; 19 | _right = right; 20 | _beforeLeft = beforeLeft; 21 | _beforeRight = beforeRight; 22 | _afterLeft = afterLeft; 23 | _afterRight = afterRight; 24 | } 25 | 26 | public override string Name 27 | { 28 | get { return "Change Text"; } 29 | } 30 | 31 | public override string Description 32 | { 33 | get { return "Text was changed"; } 34 | } 35 | 36 | public override void Do(bool redo) 37 | { 38 | if (redo) 39 | { 40 | _left.SetSnapshot(_afterLeft); 41 | _right.SetSnapshot(_afterRight); 42 | } 43 | } 44 | 45 | public override void Undo() 46 | { 47 | _left.SetSnapshot(_beforeLeft); 48 | _right.SetSnapshot(_beforeRight); 49 | } 50 | 51 | private DiffEditBox _left; 52 | private DiffEditBox _right; 53 | private DiffSnapshot _beforeLeft; 54 | private DiffSnapshot _afterLeft; 55 | private DiffSnapshot _beforeRight; 56 | private DiffSnapshot _afterRight; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /DiffControl/CharData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | 4 | namespace DifferenceEngine 5 | { 6 | public class DiffList_CharData : IDiffList 7 | { 8 | private char[] _charList; 9 | 10 | public DiffList_CharData(string charData) 11 | { 12 | _charList = charData.ToCharArray(); 13 | } 14 | #region IDiffList Members 15 | 16 | public int Count() 17 | { 18 | return _charList.Length; 19 | } 20 | 21 | public IComparable GetByIndex(int index) 22 | { 23 | return _charList[index]; 24 | } 25 | 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /DiffControl/DiffSnapshot.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace DiffControl 6 | { 7 | /// 8 | /// Encapsulates the full state of the diff edit box (including lines, cursor, selection etc) 9 | /// so it can be restored later. 10 | /// 11 | public class DiffSnapshot : ICloneable 12 | { 13 | #region Constructors 14 | public DiffSnapshot(List lines, DiffEditPosition cursor, 15 | DiffEditRange selection, int lineIndex, int column, 16 | bool modified, bool synched) 17 | { 18 | if (lines == null) 19 | _lines = null; 20 | else 21 | { 22 | _lines = new List(); 23 | foreach (LineRecord lrec in lines) 24 | _lines.Add((LineRecord)lrec.Clone()); 25 | } // else 26 | _cursor = cursor; 27 | _selection = selection; 28 | _lineIndex = lineIndex; 29 | _columnIndex = column; 30 | _modified = modified; 31 | _synched = synched; 32 | } 33 | #endregion 34 | 35 | #region ICloneable Members 36 | 37 | public object Clone() 38 | { 39 | DiffSnapshot res = new DiffSnapshot(_lines, _cursor, _selection, _lineIndex, _columnIndex, _modified, _synched); 40 | return res; 41 | } 42 | 43 | #endregion 44 | 45 | #region Public Properties 46 | public List Lines 47 | { 48 | get { return _lines; } 49 | } 50 | 51 | public DiffEditPosition Cursor 52 | { 53 | get { return _cursor; } 54 | set { _cursor = value; } 55 | } 56 | 57 | public DiffEditRange Selection 58 | { 59 | get { return _selection; } 60 | set { _selection = value; } 61 | } 62 | 63 | public int LineIndex 64 | { 65 | get { return _lineIndex; } 66 | set { _lineIndex = value; } 67 | } 68 | 69 | public int ColumnIndex 70 | { 71 | get { return _columnIndex; } 72 | set { _columnIndex = value; } 73 | } 74 | 75 | public bool IsModified 76 | { 77 | get { return _modified; } 78 | set { _modified = value; } 79 | } 80 | 81 | public bool IsSynched 82 | { 83 | get { return _synched; } 84 | set { _synched = value; } 85 | } 86 | #endregion 87 | 88 | #region Private Variables 89 | private List _lines; 90 | private DiffEditPosition _cursor; 91 | private DiffEditRange _selection; 92 | private int _lineIndex; 93 | private int _columnIndex; 94 | private bool _modified; 95 | private bool _synched; 96 | #endregion 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /DiffControl/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DiffControl")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DiffControl")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2ec6aa69-1360-4db9-838d-5e188c37b274")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /DiffControl/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace DiffControl.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DiffControl.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DiffControl/TextFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections; 4 | 5 | namespace DifferenceEngine 6 | { 7 | public class TextLine : IComparable 8 | { 9 | public string Line; 10 | public int _hash; 11 | 12 | public TextLine(string str) 13 | { 14 | Line = str.Replace("\t"," "); 15 | _hash = str.GetHashCode(); 16 | } 17 | #region IComparable Members 18 | 19 | public int CompareTo(object obj) 20 | { 21 | return _hash.CompareTo(((TextLine)obj)._hash); 22 | } 23 | 24 | #endregion 25 | } 26 | 27 | 28 | public class DiffList_TextFile : IDiffList 29 | { 30 | private const int MaxLineLength = 1024; 31 | private ArrayList _lines; 32 | 33 | public DiffList_TextFile(string[] lines) 34 | { 35 | _lines = new ArrayList(); 36 | foreach (string line in lines) 37 | _lines.Add(new TextLine(line)); 38 | } 39 | 40 | public DiffList_TextFile(string fileName) 41 | { 42 | _lines = new ArrayList(); 43 | using (StreamReader sr = new StreamReader(fileName)) 44 | { 45 | String line; 46 | // Read and display lines from the file until the end of 47 | // the file is reached. 48 | while ((line = sr.ReadLine()) != null) 49 | { 50 | if (line.Length > MaxLineLength) 51 | { 52 | throw new InvalidOperationException( 53 | string.Format("File contains a line greater than {0} characters.", 54 | MaxLineLength.ToString())); 55 | } 56 | _lines.Add(new TextLine(line)); 57 | } 58 | } 59 | } 60 | #region IDiffList Members 61 | 62 | public int Count() 63 | { 64 | return _lines.Count; 65 | } 66 | 67 | public IComparable GetByIndex(int index) 68 | { 69 | return (TextLine)_lines[index]; 70 | } 71 | 72 | #endregion 73 | 74 | } 75 | } -------------------------------------------------------------------------------- /FastGrid/FastGridCell.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Drawing; 5 | using System.Windows.Forms; 6 | 7 | namespace FastGridApp 8 | { 9 | public class FastGridCell 10 | { 11 | public FastGridCell(FastGrid owner) 12 | { 13 | _owner = owner; 14 | } 15 | 16 | public object Value 17 | { 18 | get { return _value; } 19 | set { _value = value; } 20 | } 21 | 22 | public FastGridStyle Style 23 | { 24 | get { return _style; } 25 | } 26 | 27 | public virtual void OnPaint(Graphics g, Rectangle bbox, bool isRowSelected) 28 | { 29 | if (isRowSelected) 30 | { 31 | g.FillRectangle(SystemBrushes.Highlight, bbox); 32 | } 33 | else 34 | { 35 | using (SolidBrush b = new SolidBrush(GetBackColor())) 36 | g.FillRectangle(b, bbox); 37 | } 38 | 39 | if (_value != null) 40 | { 41 | Font f = GetFont(); 42 | int fh = (int)Math.Ceiling(f.GetHeight(g)); 43 | 44 | if (isRowSelected) 45 | { 46 | g.DrawString(_value.ToString(), GetFont(), SystemBrushes.HighlightText, 47 | new Rectangle(bbox.X, bbox.Y + (bbox.Height - fh) / 2, bbox.Width, fh), _fmt); 48 | } 49 | else 50 | { 51 | using (SolidBrush b = new SolidBrush(GetForeColor())) 52 | g.DrawString(_value.ToString(), GetFont(), b, 53 | new Rectangle(bbox.X, bbox.Y + (bbox.Height - fh) / 2, bbox.Width, fh), _fmt); 54 | } 55 | } 56 | } 57 | 58 | protected Color GetForeColor() 59 | { 60 | if (_style.ForeColor == Color.Empty) 61 | return _owner.ForeColor; 62 | else 63 | return _style.ForeColor; 64 | } 65 | 66 | protected Color GetBackColor() 67 | { 68 | if (_style.BackColor == Color.Empty) 69 | return _owner.BackColor; 70 | else 71 | return _style.BackColor; 72 | } 73 | 74 | protected Font GetFont() 75 | { 76 | if (_style.Font == null) 77 | return _owner.Font; 78 | else 79 | return _style.Font; 80 | } 81 | 82 | private object _value; 83 | private FastGrid _owner; 84 | private FastGridStyle _style = new FastGridStyle(); 85 | private StringFormat _fmt = new StringFormat(StringFormatFlags.NoWrap); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /FastGrid/FastGridCheckBoxCell.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Drawing; 5 | using System.Windows.Forms; 6 | 7 | 8 | namespace FastGridApp 9 | { 10 | public class FastGridCheckBoxCell : FastGridCell 11 | { 12 | public FastGridCheckBoxCell(FastGrid owner) 13 | : base(owner) 14 | { 15 | } 16 | 17 | public override void OnPaint(Graphics g, Rectangle bbox, bool isRowSelected) 18 | { 19 | if (isRowSelected) 20 | { 21 | g.FillRectangle(SystemBrushes.Highlight, bbox); 22 | } 23 | else 24 | { 25 | using (SolidBrush b = new SolidBrush(GetBackColor())) 26 | g.FillRectangle(b, bbox); 27 | } 28 | 29 | if (Value != null) 30 | { 31 | Font f = GetFont(); 32 | int fh = (int)Math.Ceiling(f.GetHeight(g)); 33 | 34 | if (Value is bool) 35 | { 36 | ControlPaint.DrawCheckBox(g, new Rectangle(bbox.X, bbox.Y + (bbox.Height - fh) / 2, bbox.Width, fh), 37 | ((bool)Value) ? ButtonState.Checked : ButtonState.Normal); 38 | } 39 | else 40 | { 41 | if (isRowSelected) 42 | { 43 | g.DrawString(Value.ToString(), GetFont(), SystemBrushes.HighlightText, 44 | new Rectangle(bbox.X, bbox.Y + (bbox.Height - fh) / 2, bbox.Width, fh), _fmt); 45 | } 46 | else 47 | { 48 | using (SolidBrush b = new SolidBrush(GetForeColor())) 49 | g.DrawString(Value.ToString(), GetFont(), b, 50 | new Rectangle(bbox.X, bbox.Y + (bbox.Height - fh) / 2, bbox.Width, fh), _fmt); 51 | } 52 | } // else 53 | } 54 | } 55 | 56 | private StringFormat _fmt = new StringFormat(StringFormatFlags.NoWrap); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /FastGrid/FastGridColumn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Drawing; 5 | 6 | namespace FastGridApp 7 | { 8 | public class FastGridColumn 9 | { 10 | public FastGridColumn(string text) 11 | { 12 | _text = text; 13 | } 14 | 15 | public FastGridColumn(Image img, string text) 16 | { 17 | _text = text; 18 | _img = img; 19 | } 20 | 21 | public FastGridColumn(string text, FastGridColumnType ctype) 22 | { 23 | _text = text; 24 | _ctype = ctype; 25 | } 26 | 27 | public FastGridColumn(Image img, string text, FastGridColumnType ctype) 28 | { 29 | _text = text; 30 | _ctype = ctype; 31 | _img = img; 32 | } 33 | 34 | public string Text 35 | { 36 | get { return _text; } 37 | set { _text = value; } 38 | } 39 | 40 | public Image Image 41 | { 42 | get { return _img; } 43 | set { _img = value; } 44 | } 45 | 46 | public FastGridColumnType ColumnType 47 | { 48 | get { return _ctype; } 49 | set { _ctype = value; } 50 | } 51 | 52 | public int Width 53 | { 54 | get { return _width; } 55 | set { _width = value; } 56 | } 57 | 58 | public object Tag 59 | { 60 | get { return _tag; } 61 | set { _tag = value; } 62 | } 63 | 64 | private object _tag; 65 | private string _text; 66 | private Image _img; 67 | private int _width = 100; 68 | private FastGridColumnType _ctype = FastGridColumnType.Text; 69 | } 70 | 71 | public enum FastGridColumnType 72 | { 73 | None = 0, 74 | 75 | Text = 1, 76 | 77 | CheckBox = 2, 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /FastGrid/FastGridLocation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastGridApp 6 | { 7 | /// 8 | /// Represents a location in the grid (Row/Column) 9 | /// 10 | public struct FastGridLocation 11 | { 12 | public static readonly FastGridLocation Empty = new FastGridLocation(long.MinValue, int.MinValue); 13 | 14 | public FastGridLocation(long row, int col) 15 | { 16 | RowIndex = row; 17 | ColumnIndex = col; 18 | } 19 | 20 | public override bool Equals(object obj) 21 | { 22 | if (obj == null) 23 | return false; 24 | 25 | if (!(obj is FastGridLocation)) 26 | return false; 27 | 28 | FastGridLocation loc = (FastGridLocation)obj; 29 | if (loc.RowIndex != RowIndex) 30 | return false; 31 | if (loc.ColumnIndex != ColumnIndex) 32 | return false; 33 | 34 | return true; 35 | } 36 | 37 | public static bool operator ==(FastGridLocation obj1, FastGridLocation obj2) 38 | { 39 | return obj1.Equals(obj2); 40 | } 41 | 42 | public static bool operator !=(FastGridLocation obj1, FastGridLocation obj2) 43 | { 44 | return !obj1.Equals(obj2); 45 | } 46 | 47 | public override int GetHashCode() 48 | { 49 | return RowIndex.GetHashCode() * ColumnIndex.GetHashCode(); 50 | } 51 | 52 | public override string ToString() 53 | { 54 | return "Row=" + RowIndex + ",Col=" + ColumnIndex; 55 | } 56 | 57 | public long RowIndex; 58 | public int ColumnIndex; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /FastGrid/FastGridRow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace FastGridApp 6 | { 7 | public class FastGridRow 8 | { 9 | public FastGridRow(FastGrid owner) 10 | { 11 | _owner = owner; 12 | } 13 | 14 | public FastGridCell[] Cells 15 | { 16 | get { return _cells; } 17 | set { _cells = value; } 18 | } 19 | 20 | public FastGridStyle Style 21 | { 22 | get { return _style; } 23 | } 24 | 25 | public object Tag 26 | { 27 | get { return _tag; } 28 | } 29 | 30 | private object _tag; 31 | private FastGrid _owner; 32 | private FastGridStyle _style = new FastGridStyle(); 33 | private FastGridCell[] _cells; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /FastGrid/FastGridStyle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Drawing; 5 | 6 | namespace FastGridApp 7 | { 8 | public class FastGridStyle 9 | { 10 | public Font Font 11 | { 12 | get { return _font; } 13 | set { _font = value; } 14 | } 15 | 16 | public Color BackColor 17 | { 18 | get { return _backColor; } 19 | set { _backColor = value; } 20 | } 21 | 22 | public Color ForeColor 23 | { 24 | get { return _foreColor; } 25 | set { _foreColor = value; } 26 | } 27 | 28 | private Font _font; 29 | private Color _backColor; 30 | private Color _foreColor; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /FastGrid/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FastGrid")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FastGrid")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5a174348-a2a6-4e4e-8227-8518eee719f1")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("1.0.0.0")] 33 | [assembly: AssemblyFileVersion("1.0.0.0")] 34 | -------------------------------------------------------------------------------- /FastGrid/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FastGridApp.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FastGridApp.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /FastGrid/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace FastGridApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /FastGrid/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SQLiteParser/.gitignore: -------------------------------------------------------------------------------- 1 | #Generated by build process. 2 | SQLiteLexer.cs 3 | SQLiteParser.cs -------------------------------------------------------------------------------- /SQLiteParser/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SQLiteParser")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SQLiteParser")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5f0f0a43-c174-4dca-9afe-31750a98e048")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /SQLiteParser/RefCompare.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class RefCompare 8 | { 9 | public static bool Compare(object t1, object t2) 10 | { 11 | if (t1 == null && t2 != null || t1 != null && t2 == null) 12 | return false; 13 | if (t1 == null && t2 == null) 14 | return true; 15 | if (!t1.Equals(t2)) 16 | return false; 17 | return true; 18 | } 19 | 20 | public static bool CompareMany(params object[] args) 21 | { 22 | if (args == null || args.Length % 2 != 0) 23 | throw new ArgumentException(); 24 | 25 | for (int i = 0; i < args.Length; ) 26 | { 27 | if (!Compare(args[i], args[i + 1])) 28 | return false; 29 | i += 2; 30 | } // for 31 | 32 | return true; 33 | } 34 | 35 | public static bool CompareList(List i1, List i2) where I : class 36 | { 37 | if (i1 == null && i2 != null || i1 != null && i2 == null) 38 | return false; 39 | if (i1 == null && i2 == null) 40 | return true; 41 | if (i1.Count != i2.Count) 42 | return false; 43 | for (int i = 0; i < i1.Count; i++) 44 | { 45 | if (i1[i] == null && i2[i] != null) 46 | return false; 47 | if (i1[i] != null && i2[i] == null) 48 | return false; 49 | if (i1[i] != null && i2[i] != null) 50 | { 51 | if (!i1[i].Equals(i2[i])) 52 | return false; 53 | } 54 | } // for 55 | 56 | return true; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteBetweenExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteBetweenExpression : SQLiteExpression 8 | { 9 | public SQLiteBetweenExpression() 10 | { 11 | } 12 | 13 | public SQLiteBetweenExpression(SQLiteExpression left, bool between, SQLiteExpression right, SQLiteExpression and) 14 | { 15 | _left = left; 16 | _between = between; 17 | _right = right; 18 | _and = and; 19 | } 20 | 21 | public SQLiteExpression LeftExpression 22 | { 23 | get { return _left; } 24 | set { _left = value; } 25 | } 26 | 27 | public bool IsBetween 28 | { 29 | get { return _between; } 30 | set { _between = value; } 31 | } 32 | 33 | public SQLiteExpression RightExpression 34 | { 35 | get { return _right; } 36 | set { _right = value; } 37 | } 38 | 39 | public SQLiteExpression AndExpression 40 | { 41 | get { return _and; } 42 | set { _and = value; } 43 | } 44 | 45 | public override bool IsConstant(bool allowNull) 46 | { 47 | return false; 48 | } 49 | 50 | public override bool Equals(object obj) 51 | { 52 | if (obj == null) 53 | return false; 54 | 55 | SQLiteBetweenExpression dst = obj as SQLiteBetweenExpression; 56 | if (dst == null) 57 | return false; 58 | 59 | if (this._between != dst._between) 60 | return false; 61 | 62 | if (!RefCompare.CompareMany(_left, dst._left, _right, dst._right, _and, dst._and)) 63 | return false; 64 | 65 | return base.Equals(obj); 66 | } 67 | 68 | public override string ToString() 69 | { 70 | string res = _left.ToString() + " BETWEEN " + _right.ToString() + " AND " + _and.ToString(); 71 | return res; 72 | } 73 | 74 | public override object Clone() 75 | { 76 | SQLiteExpression left = null; 77 | if (_left != null) 78 | left = (SQLiteExpression)_left.Clone(); 79 | SQLiteExpression right = null; 80 | if (_right != null) 81 | right = (SQLiteExpression)_right.Clone(); 82 | SQLiteExpression and = null; 83 | if (_and != null) 84 | and = (SQLiteExpression)_and.Clone(); 85 | 86 | SQLiteBetweenExpression res = new SQLiteBetweenExpression(); 87 | res._and = and; 88 | res._between = _between; 89 | res._left = left; 90 | res._right = right; 91 | return res; 92 | } 93 | 94 | private SQLiteExpression _left; 95 | private bool _between; 96 | private SQLiteExpression _right; 97 | private SQLiteExpression _and; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCaseItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCaseItem 8 | { 9 | private SQLiteCaseItem() 10 | { 11 | } 12 | 13 | public SQLiteCaseItem(SQLiteExpression whenExpr, SQLiteExpression thenExpr) 14 | { 15 | _when = whenExpr; 16 | _then = thenExpr; 17 | } 18 | 19 | public SQLiteExpression WhenExpression 20 | { 21 | get { return _when; } 22 | set { _when = value; } 23 | } 24 | 25 | public SQLiteExpression ThenExpression 26 | { 27 | get { return _then; } 28 | set { _then = value; } 29 | } 30 | 31 | public override bool Equals(object obj) 32 | { 33 | if (obj == null) 34 | return false; 35 | 36 | SQLiteCaseItem dst = obj as SQLiteCaseItem; 37 | if (dst == null) 38 | return false; 39 | 40 | if (!RefCompare.CompareMany(_when, dst._when, _then, dst._then)) 41 | return false; 42 | 43 | return base.Equals(obj); 44 | } 45 | 46 | public override string ToString() 47 | { 48 | return "WHEN " + _when.ToString() + " THEN " + _then.ToString(); 49 | } 50 | 51 | public virtual object Clone() 52 | { 53 | SQLiteExpression when = null; 54 | if (_when != null) 55 | when = (SQLiteExpression)_when.Clone(); 56 | SQLiteExpression then = null; 57 | if (_then != null) 58 | then = (SQLiteExpression)_then.Clone(); 59 | 60 | SQLiteCaseItem res = new SQLiteCaseItem(); 61 | res._when = when; 62 | res._then = then; 63 | return res; 64 | } 65 | 66 | private SQLiteExpression _when; 67 | private SQLiteExpression _then; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCastExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCastExpression : SQLiteExpression 8 | { 9 | private SQLiteCastExpression() 10 | { 11 | } 12 | 13 | public SQLiteCastExpression(SQLiteExpression expr, SQLiteColumnType type) 14 | { 15 | _expr = expr; 16 | _type = type; 17 | } 18 | 19 | public SQLiteExpression Expression 20 | { 21 | get { return _expr; } 22 | set { _expr = value; } 23 | } 24 | 25 | public SQLiteColumnType CastType 26 | { 27 | get { return _type; } 28 | set { _type = value; } 29 | } 30 | 31 | public override bool IsConstant(bool allowNull) 32 | { 33 | return _expr.IsConstant(allowNull); 34 | } 35 | 36 | public override bool Equals(object obj) 37 | { 38 | if (obj == null) 39 | return false; 40 | 41 | SQLiteCastExpression dst = obj as SQLiteCastExpression; 42 | if (dst == null) 43 | return false; 44 | 45 | if (!RefCompare.CompareMany(_expr, dst._expr, _type, dst._type)) 46 | return false; 47 | 48 | return base.Equals(obj); 49 | } 50 | 51 | public override string ToString() 52 | { 53 | string res = "CAST (" + _expr.ToString() + " AS " + _type.ToString() + ")"; 54 | return res; 55 | } 56 | 57 | public override object Clone() 58 | { 59 | SQLiteExpression expr = null; 60 | if (_expr != null) 61 | expr = (SQLiteExpression)_expr.Clone(); 62 | SQLiteColumnType type = null; 63 | if (_type != null) 64 | type = (SQLiteColumnType)_type.Clone(); 65 | 66 | SQLiteCastExpression res = new SQLiteCastExpression(); 67 | res._expr = expr; 68 | res._type = type; 69 | return res; 70 | } 71 | 72 | private SQLiteExpression _expr; 73 | private SQLiteColumnType _type; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCheckColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCheckColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLiteCheckColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteCheckColumnConstraint(string name, SQLiteExpression expr) 15 | : base(name) 16 | { 17 | _expr = expr; 18 | } 19 | 20 | public SQLiteExpression Expression 21 | { 22 | get { return _expr; } 23 | set { _expr = value; } 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | if (obj == null) 29 | return false; 30 | 31 | SQLiteCheckColumnConstraint dst = obj as SQLiteCheckColumnConstraint; 32 | if (dst == null) 33 | return false; 34 | 35 | if (!this.Expression.Equals(dst.Expression)) 36 | return false; 37 | 38 | return base.Equals(obj); 39 | } 40 | 41 | public override string ToString() 42 | { 43 | if (this.ConstraintName != null) 44 | return "CONSTRAINT " + this.ConstraintName + " CHECK (" + _expr.ToString() + ")"; 45 | else 46 | return "CHECK (" + _expr.ToString() + ")"; 47 | } 48 | 49 | public override object Clone() 50 | { 51 | SQLiteExpression expr = null; 52 | if (_expr != null) 53 | expr = (SQLiteExpression)_expr.Clone(); 54 | 55 | SQLiteCheckColumnConstraint res = new SQLiteCheckColumnConstraint(this.ConstraintName); 56 | res._expr = expr; 57 | return res; 58 | } 59 | 60 | private SQLiteExpression _expr; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCheckTableConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCheckTableConstraint : SQLiteTableConstraint 8 | { 9 | private SQLiteCheckTableConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteCheckTableConstraint(string name, SQLiteExpression expr, SQLiteResolveAction conf) 15 | : base(name) 16 | { 17 | _expr = expr; 18 | _conf = conf; 19 | } 20 | 21 | public SQLiteExpression Expression 22 | { 23 | get { return _expr; } 24 | set { _expr = value; } 25 | } 26 | 27 | public SQLiteResolveAction ResolveAction 28 | { 29 | get { return _conf; } 30 | set { _conf = value; } 31 | } 32 | 33 | public override bool Equals(object obj) 34 | { 35 | if (obj == null) 36 | return false; 37 | 38 | SQLiteCheckTableConstraint dst = obj as SQLiteCheckTableConstraint; 39 | if (dst == null) 40 | return false; 41 | 42 | if (!RefCompare.CompareMany(_expr, dst._expr, _conf, dst._conf)) 43 | return false; 44 | 45 | return base.Equals(obj); 46 | } 47 | 48 | public override string ToString() 49 | { 50 | StringBuilder sb = new StringBuilder(); 51 | if (ConstraintName != null) 52 | sb.Append("CONSTRAINT " + ConstraintName+ " "); 53 | sb.Append("CHECK (" + _expr.ToString() + ")"); 54 | if (_conf != SQLiteResolveAction.None) 55 | sb.Append(" " + Utils.GetConflictClauseString(_conf)); 56 | return sb.ToString(); 57 | } 58 | 59 | public override object Clone() 60 | { 61 | SQLiteExpression expr = null; 62 | if (_expr != null) 63 | expr = (SQLiteExpression)_expr.Clone(); 64 | 65 | SQLiteCheckTableConstraint res = new SQLiteCheckTableConstraint(this.ConstraintName); 66 | res._expr = expr; 67 | res._conf = _conf; 68 | return res; 69 | } 70 | 71 | private SQLiteExpression _expr; 72 | private SQLiteResolveAction _conf; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCollateColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCollateColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLiteCollateColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteCollateColumnConstraint(string name, string collation) 15 | : base(name) 16 | { 17 | CollationName = collation; 18 | } 19 | 20 | public string CollationName 21 | { 22 | get { return _collation; } 23 | set 24 | { 25 | _collation = Utils.QuoteIfNeeded(value); 26 | } 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteCollateColumnConstraint dst = obj as SQLiteCollateColumnConstraint; 35 | if (dst == null) 36 | return false; 37 | 38 | if (this.CollationName != dst.CollationName) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | if (ConstraintName != null) 47 | return "CONSTRAINT " + ConstraintName + " COLLATE " + _collation; 48 | else 49 | return "COLLATE " + _collation; 50 | } 51 | 52 | public override object Clone() 53 | { 54 | SQLiteCollateColumnConstraint res = new SQLiteCollateColumnConstraint(this.ConstraintName); 55 | res._collation = _collation; 56 | return res; 57 | } 58 | 59 | private string _collation; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCollateExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | class SQLiteCollateExpression : SQLiteExpression 8 | { 9 | private SQLiteCollateExpression() 10 | { 11 | } 12 | 13 | public SQLiteCollateExpression(SQLiteExpression expr, string collationName) 14 | { 15 | _expr = expr; 16 | CollationName = collationName; 17 | } 18 | 19 | public SQLiteExpression Expression 20 | { 21 | get { return _expr; } 22 | set { _expr = value; } 23 | } 24 | 25 | public string CollationName 26 | { 27 | get { return _collationName; } 28 | set 29 | { 30 | _collationName = Utils.QuoteIfNeeded(value); 31 | } 32 | } 33 | 34 | public override bool IsConstant(bool allowNull) 35 | { 36 | return false; 37 | } 38 | 39 | public override bool Equals(object obj) 40 | { 41 | if (obj == null) 42 | return false; 43 | 44 | SQLiteCollateExpression dst = obj as SQLiteCollateExpression; 45 | if (dst == null) 46 | return false; 47 | 48 | if (!RefCompare.Compare(_expr, dst._expr)) 49 | return false; 50 | 51 | if (_collationName != dst._collationName) 52 | return false; 53 | 54 | return base.Equals(obj); 55 | } 56 | 57 | public override string ToString() 58 | { 59 | string res = _expr.ToString() + " COLLATE " + _collationName; 60 | return res; 61 | } 62 | 63 | public override object Clone() 64 | { 65 | SQLiteExpression expr = null; 66 | if (_expr != null) 67 | expr = (SQLiteExpression)_expr.Clone(); 68 | 69 | SQLiteCollateExpression res = new SQLiteCollateExpression(); 70 | res._expr = expr; 71 | res._collationName = _collationName; 72 | return res; 73 | } 74 | 75 | private SQLiteExpression _expr; 76 | private string _collationName; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteColumnConstraint 8 | { 9 | public SQLiteColumnConstraint() 10 | { 11 | } 12 | 13 | public SQLiteColumnConstraint(string name) 14 | { 15 | ConstraintName = name; 16 | } 17 | 18 | public string ConstraintName 19 | { 20 | get { return _name; } 21 | set 22 | { 23 | _name = Utils.QuoteIfNeeded(value); 24 | } 25 | } 26 | 27 | public override bool Equals(object obj) 28 | { 29 | if (obj == null) 30 | return false; 31 | 32 | SQLiteColumnConstraint dst = obj as SQLiteColumnConstraint; 33 | if (dst == null) 34 | return false; 35 | 36 | return _name == dst._name; 37 | } 38 | 39 | public virtual object Clone() 40 | { 41 | SQLiteColumnConstraint res = new SQLiteColumnConstraint(); 42 | res._name = _name; 43 | return res; 44 | } 45 | 46 | private string _name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteColumnType.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteColumnType 8 | { 9 | #region Constructors 10 | public SQLiteColumnType(string name, int size, int precision) 11 | { 12 | _name = Utils.QuoteIfNeeded(name); 13 | _size = size; 14 | _precision = precision; 15 | } 16 | #endregion 17 | 18 | #region Public Properties 19 | public string TypeName 20 | { 21 | get { return _name; } 22 | set { _name = Utils.QuoteIfNeeded(value); } 23 | } 24 | 25 | public int TypeSize 26 | { 27 | get { return _size; } 28 | set { _size = value; } 29 | } 30 | 31 | public int TypePrecision 32 | { 33 | get { return _precision; } 34 | set { _precision = value; } 35 | } 36 | #endregion 37 | 38 | #region Public Overrided Methods 39 | public override bool Equals(object obj) 40 | { 41 | if (obj == null) 42 | return false; 43 | 44 | SQLiteColumnType dst = obj as SQLiteColumnType; 45 | if (dst == null) 46 | return false; 47 | 48 | if (_name != dst._name || _size != dst._size || _precision != dst._precision) 49 | return false; 50 | 51 | return true; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | StringBuilder sb = new StringBuilder(); 57 | sb.Append(_name); 58 | if (_size > 0 && _precision > 0) 59 | sb.Append(string.Format("({0},{1})", _size, _precision)); 60 | else if (_size > 0) 61 | sb.Append(string.Format("({0})", _size)); 62 | return sb.ToString(); 63 | } 64 | #endregion 65 | 66 | public virtual object Clone() 67 | { 68 | return new SQLiteColumnType(_name, _size, _precision); 69 | } 70 | 71 | #region Private Variables 72 | private string _name; 73 | private int _size; 74 | private int _precision; 75 | #endregion 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteCreateViewStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteCreateViewStatement : SQLiteDdlStatement 8 | { 9 | private SQLiteCreateViewStatement(SQLiteObjectName viewName) 10 | : base(viewName) 11 | { 12 | } 13 | 14 | public SQLiteCreateViewStatement(bool isTemp, bool ifNotExists, SQLiteObjectName viewName, SQLiteSelectStatement select) 15 | : base(viewName) 16 | { 17 | _isTemp = isTemp; 18 | _ifNotExists = ifNotExists; 19 | _select = select; 20 | } 21 | 22 | public bool IsTemp 23 | { 24 | get { return _isTemp; } 25 | set { _isTemp = value; } 26 | } 27 | 28 | public bool IfNotExists 29 | { 30 | get { return _ifNotExists; } 31 | set { _ifNotExists = value; } 32 | } 33 | 34 | public SQLiteSelectStatement SelectStatement 35 | { 36 | get { return _select; } 37 | set { _select = value; } 38 | } 39 | 40 | public override bool Equals(object obj) 41 | { 42 | if (obj == null) 43 | return false; 44 | 45 | SQLiteCreateViewStatement dst = obj as SQLiteCreateViewStatement; 46 | if (dst == null) 47 | return false; 48 | 49 | if (_isTemp != dst._isTemp || _ifNotExists != dst._ifNotExists) 50 | return false; 51 | 52 | if (!RefCompare.Compare(_select, dst._select)) 53 | return false; 54 | 55 | return base.Equals(obj); 56 | } 57 | 58 | public override string ToString() 59 | { 60 | // CREATE temp VIEW ifnotexists nm dbnm AS select 61 | 62 | StringBuilder sb = new StringBuilder(); 63 | sb.Append("CREATE"); 64 | if (_isTemp) 65 | sb.Append(" TEMP"); 66 | sb.Append(" VIEW"); 67 | if (_ifNotExists) 68 | sb.Append(" IF NOT EXISTS"); 69 | sb.Append(" " + base.ObjectName.ToString() + "\r\nAS\r\n" + _select.ToString()); 70 | 71 | return sb.ToString(); 72 | } 73 | 74 | public override object Clone() 75 | { 76 | SQLiteSelectStatement select = null; 77 | if (_select != null) 78 | select = (SQLiteSelectStatement)_select.Clone(); 79 | SQLiteObjectName viewName = null; 80 | if (this.ObjectName != null) 81 | viewName = (SQLiteObjectName)this.ObjectName.Clone(); 82 | 83 | SQLiteCreateViewStatement res = new SQLiteCreateViewStatement(viewName); 84 | res._ifNotExists = _ifNotExists; 85 | res._isTemp = _isTemp; 86 | res._select = select; 87 | return res; 88 | } 89 | 90 | private bool _isTemp; 91 | private bool _ifNotExists; 92 | private SQLiteSelectStatement _select; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteDdlMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteDdlMain 8 | { 9 | public static SQLiteDdlStatement GetStatement() 10 | { 11 | if (CreateTable != null) 12 | return _createTable; 13 | if (CreateIndex != null) 14 | return _createIndex; 15 | if (CreateView != null) 16 | return _createView; 17 | if (CreateTrigger != null) 18 | return _createTrigger; 19 | throw new ApplicationException("no sql statement was found"); 20 | } 21 | 22 | public static SQLiteCreateTableStatement CreateTable 23 | { 24 | get { return _createTable; } 25 | set 26 | { 27 | _createTable = value; 28 | _createView = null; 29 | _createTrigger = null; 30 | _createIndex = null; 31 | } 32 | } 33 | 34 | public static SQLiteCreateIndexStatement CreateIndex 35 | { 36 | get { return _createIndex; } 37 | set 38 | { 39 | _createIndex = value; 40 | _createView = null; 41 | _createTrigger = null; 42 | _createTable = null; 43 | } 44 | } 45 | 46 | public static SQLiteCreateViewStatement CreateView 47 | { 48 | get { return _createView; } 49 | set 50 | { 51 | _createView = value; 52 | _createTable = null; 53 | _createTrigger = null; 54 | _createIndex = null; 55 | } 56 | } 57 | 58 | public static SQLiteCreateTriggerStatement CreateTrigger 59 | { 60 | get { return _createTrigger; } 61 | set 62 | { 63 | _createTrigger = value; 64 | _createTable = null; 65 | _createIndex = null; 66 | _createView = null; 67 | } 68 | } 69 | 70 | private static SQLiteCreateIndexStatement _createIndex; 71 | private static SQLiteCreateTableStatement _createTable; 72 | private static SQLiteCreateTriggerStatement _createTrigger; 73 | private static SQLiteCreateViewStatement _createView; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteDdlStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | /// 8 | /// Serves as the base class for all SQL DDL statements 9 | /// 10 | public class SQLiteDdlStatement : SQLiteStatement 11 | { 12 | #region Constructors 13 | public SQLiteDdlStatement() 14 | { 15 | } 16 | 17 | public SQLiteDdlStatement(SQLiteObjectName name) 18 | { 19 | _objectName = name; 20 | } 21 | #endregion 22 | 23 | #region Public Properties 24 | /// 25 | /// Get/Set the name of the SQL object 26 | /// 27 | public SQLiteObjectName ObjectName 28 | { 29 | get { return _objectName; } 30 | set { _objectName = value; } 31 | } 32 | #endregion 33 | 34 | #region Public Overrided Methods 35 | public override bool Equals(object obj) 36 | { 37 | if (obj == null) 38 | return false; 39 | 40 | SQLiteDdlStatement dst = obj as SQLiteDdlStatement; 41 | if (dst == null) 42 | return false; 43 | 44 | return RefCompare.Compare(_objectName, dst._objectName); 45 | } 46 | 47 | public override object Clone() 48 | { 49 | SQLiteObjectName objectName = null; 50 | if (_objectName != null) 51 | objectName = (SQLiteObjectName)_objectName.Clone(); 52 | 53 | SQLiteDdlStatement res = new SQLiteDdlStatement(); 54 | res._objectName = objectName; 55 | return res; 56 | } 57 | #endregion 58 | 59 | #region Private Variables 60 | private SQLiteObjectName _objectName; 61 | #endregion 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteDeferColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteDeferColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLiteDeferColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteDeferColumnConstraint(string name, bool deferrable, SQLiteDeferType deferType) 15 | : base(name) 16 | { 17 | _deferType = deferType; 18 | _deferrable = deferrable; 19 | } 20 | 21 | public bool IsDeferrable 22 | { 23 | get { return _deferrable; } 24 | set { _deferrable = value; } 25 | } 26 | 27 | public SQLiteDeferType DeferType 28 | { 29 | get { return _deferType; } 30 | set { _deferType = value; } 31 | } 32 | 33 | public override bool Equals(object obj) 34 | { 35 | if (obj == null) 36 | return false; 37 | 38 | SQLiteDeferColumnConstraint dst = obj as SQLiteDeferColumnConstraint; 39 | if (dst == null) 40 | return false; 41 | 42 | if (this._deferrable != dst._deferrable) 43 | return false; 44 | if (this._deferType != dst._deferType) 45 | return false; 46 | 47 | return base.Equals(obj); 48 | } 49 | 50 | public override string ToString() 51 | { 52 | StringBuilder sb = new StringBuilder(); 53 | if (_deferrable) 54 | sb.Append("DEFERRABLE"); 55 | else 56 | sb.Append("NOT DEFERRABLE"); 57 | if (_deferType == SQLiteDeferType.InitiallyDeferred) 58 | sb.Append(" INITIALLY DEFERRED"); 59 | else if (_deferType == SQLiteDeferType.InitiallyImmediate) 60 | sb.Append(" INITIALLY IMMEDIATE"); 61 | return sb.ToString(); 62 | } 63 | 64 | public override object Clone() 65 | { 66 | SQLiteDeferColumnConstraint res = new SQLiteDeferColumnConstraint(this.ConstraintName); 67 | res._deferType = _deferType; 68 | res._deferrable = _deferrable; 69 | return res; 70 | } 71 | 72 | private bool _deferrable; 73 | private SQLiteDeferType _deferType; 74 | } 75 | 76 | public enum SQLiteDeferType 77 | { 78 | None = 0, 79 | 80 | InitiallyDeferred = 1, 81 | 82 | InitiallyImmediate = 2, 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteDeleteStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteDeleteStatement : SQLiteStatement 8 | { 9 | private SQLiteDeleteStatement() 10 | { 11 | } 12 | 13 | public SQLiteDeleteStatement(string table, SQLiteExpression whereExpr) 14 | { 15 | TableName = table; 16 | _whereExpr = whereExpr; 17 | } 18 | 19 | public string TableName 20 | { 21 | get { return _table; } 22 | set 23 | { 24 | _table = Utils.QuoteIfNeeded(value); 25 | } 26 | } 27 | 28 | public SQLiteExpression WhereExpression 29 | { 30 | get { return _whereExpr; } 31 | set { _whereExpr = value; } 32 | } 33 | 34 | public override bool Equals(object obj) 35 | { 36 | if (obj == null) 37 | return false; 38 | 39 | SQLiteDeleteStatement dst = obj as SQLiteDeleteStatement; 40 | if (dst == null) 41 | return false; 42 | 43 | if (_table != dst._table) 44 | return false; 45 | if (!RefCompare.Compare(_whereExpr, dst._whereExpr)) 46 | return false; 47 | 48 | return base.Equals(obj); 49 | } 50 | 51 | public override string ToString() 52 | { 53 | StringBuilder sb = new StringBuilder(); 54 | sb.Append("DELETE FROM " + _table); 55 | if (_whereExpr != null) 56 | sb.Append("\r\n WHERE " + _whereExpr.ToString()); 57 | return sb.ToString(); 58 | } 59 | 60 | public override object Clone() 61 | { 62 | SQLiteExpression whereExpr = null; 63 | if (_whereExpr != null) 64 | whereExpr = (SQLiteExpression)_whereExpr.Clone(); 65 | 66 | SQLiteDeleteStatement res = new SQLiteDeleteStatement(); 67 | res._table = _table; 68 | res._whereExpr = whereExpr; 69 | return res; 70 | } 71 | 72 | private string _table; 73 | private SQLiteExpression _whereExpr; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteDistinct.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public enum SQLiteDistinct 8 | { 9 | None = 0, 10 | 11 | Distinct = 1, 12 | 13 | All = 2, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteExistsExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteExistsExpression : SQLiteExpression 8 | { 9 | private SQLiteExistsExpression() 10 | { 11 | } 12 | 13 | public SQLiteExistsExpression(SQLiteSelectStatement select) 14 | { 15 | _select = select; 16 | } 17 | 18 | public SQLiteSelectStatement SelectStatement 19 | { 20 | get { return _select; } 21 | set { _select = value; } 22 | } 23 | 24 | public override bool IsConstant(bool allowNull) 25 | { 26 | return false; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteExistsExpression dst = obj as SQLiteExistsExpression; 35 | if (dst == null) 36 | return false; 37 | 38 | if (!RefCompare.Compare(_select, dst._select)) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | string res = "EXISTS (" + _select.ToString() + ")"; 47 | return res; 48 | } 49 | 50 | public override object Clone() 51 | { 52 | SQLiteSelectStatement select = null; 53 | if (_select != null) 54 | select = (SQLiteSelectStatement)_select.Clone(); 55 | 56 | SQLiteExistsExpression res = new SQLiteExistsExpression(); 57 | res._select = select; 58 | return res; 59 | } 60 | 61 | private SQLiteSelectStatement _select; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteExpression 8 | { 9 | public override bool Equals(object obj) 10 | { 11 | if (obj == null) 12 | return false; 13 | 14 | SQLiteExpression dst = obj as SQLiteExpression; 15 | if (dst == null) 16 | return false; 17 | return true; 18 | } 19 | 20 | public override string ToString() 21 | { 22 | throw new InvalidOperationException("SQL statement rendering has failed"); 23 | } 24 | 25 | public virtual object Clone() 26 | { 27 | throw new InvalidOperationException("SQL statement cloning has failed"); 28 | } 29 | 30 | public virtual bool IsConstant(bool allowNull) 31 | { 32 | throw new NotSupportedException("IsConstant is not supported in the base class"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteFromClause.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteFromClause 8 | { 9 | public SQLiteFromClause AddJoin(SQLiteJoinOperator join) 10 | { 11 | _tables.Add(join); 12 | return this; 13 | } 14 | 15 | public SQLiteFromClause AddTable(SQLiteObjectName tableName, string asName, 16 | SQLiteFromIndexed indexed, SQLiteExpression onExpr, List usingOpt) 17 | { 18 | _tables.Add(new SQLiteFromTable(tableName, asName, indexed, onExpr, usingOpt)); 19 | return this; 20 | } 21 | 22 | public SQLiteFromClause AddInternalTable(SQLiteFromInternalTable itable, string asName, 23 | SQLiteExpression onExpr, List usingOpt) 24 | { 25 | _tables.Add(new SQLiteFromTable(itable, asName, onExpr, usingOpt)); 26 | return this; 27 | } 28 | 29 | public List FromTables 30 | { 31 | get { return _tables; } 32 | } 33 | 34 | public override bool Equals(object obj) 35 | { 36 | if (obj == null) 37 | return false; 38 | 39 | SQLiteFromClause dst = obj as SQLiteFromClause; 40 | if (dst == null) 41 | return false; 42 | 43 | if (!RefCompare.CompareList(_tables, dst._tables)) 44 | return false; 45 | 46 | return true; 47 | } 48 | 49 | public override string ToString() 50 | { 51 | if (_tables == null || _tables.Count == 0) 52 | return string.Empty; 53 | 54 | StringBuilder sb = new StringBuilder(); 55 | for (int i = 0; i < _tables.Count; i++) 56 | { 57 | if (_tables[i] is SQLiteFromTable) 58 | sb.Append(_tables[i].ToString()); 59 | else 60 | sb.Append(Utils.GetJoinOperatorString((SQLiteJoinOperator)_tables[i])); 61 | if (i < _tables.Count - 1) 62 | sb.Append(" "); 63 | } // for 64 | return sb.ToString(); 65 | } 66 | 67 | public virtual object Clone() 68 | { 69 | List tlist = null; 70 | if (_tables != null) 71 | { 72 | tlist = new List(); 73 | foreach (object obj in _tables) 74 | { 75 | if (obj is SQLiteFromTable) 76 | { 77 | SQLiteFromTable ft = (SQLiteFromTable)obj; 78 | tlist.Add(ft.Clone()); 79 | } 80 | else if (obj is SQLiteJoinOperator) 81 | tlist.Add(obj); 82 | } // foreach 83 | } 84 | 85 | SQLiteFromClause res = new SQLiteFromClause(); 86 | res._tables = tlist; 87 | return res; 88 | } 89 | 90 | private List _tables = new List(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteFromIndexed.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteFromIndexed 8 | { 9 | public SQLiteFromIndexed() 10 | { 11 | } 12 | 13 | public SQLiteFromIndexed(string by) 14 | { 15 | IndexedBy = by; 16 | } 17 | 18 | public bool IsIndexed 19 | { 20 | get { return _by != null; } 21 | } 22 | 23 | public string IndexedBy 24 | { 25 | get { return _by; } 26 | set 27 | { 28 | _by = Utils.QuoteIfNeeded(value); 29 | } 30 | } 31 | 32 | public override bool Equals(object obj) 33 | { 34 | if (obj == null) 35 | return false; 36 | 37 | SQLiteFromIndexed dst = obj as SQLiteFromIndexed; 38 | if (dst == null) 39 | return false; 40 | 41 | return _by == dst._by; 42 | } 43 | 44 | public override string ToString() 45 | { 46 | if (IsIndexed) 47 | return "INDEXED BY " + _by; 48 | else 49 | return "NOT INDEXED"; 50 | } 51 | 52 | public virtual object Clone() 53 | { 54 | SQLiteFromIndexed res = new SQLiteFromIndexed(); 55 | res._by = _by; 56 | return res; 57 | } 58 | 59 | private string _by; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteFromInternalTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteFromInternalTable 8 | { 9 | private SQLiteFromInternalTable() 10 | { 11 | } 12 | 13 | public SQLiteFromInternalTable(SQLiteSelectStatement select) 14 | { 15 | _select = select; 16 | } 17 | 18 | public SQLiteFromInternalTable(SQLiteFromClause from) 19 | { 20 | _from = from; 21 | } 22 | 23 | public SQLiteSelectStatement SelectStatement 24 | { 25 | get { return _select; } 26 | set { _select = value; } 27 | } 28 | 29 | public SQLiteFromClause FromClause 30 | { 31 | get { return _from; } 32 | set { _from = value; } 33 | } 34 | 35 | public override bool Equals(object obj) 36 | { 37 | if (obj == null) 38 | return false; 39 | 40 | SQLiteFromInternalTable dst = obj as SQLiteFromInternalTable; 41 | if (dst == null) 42 | return false; 43 | 44 | if (!RefCompare.CompareMany(_select, dst._select, _from, dst._from)) 45 | return false; 46 | 47 | return true; 48 | } 49 | 50 | public override string ToString() 51 | { 52 | if (_select != null) 53 | return _select.ToString(); 54 | else 55 | return _from.ToString(); 56 | } 57 | 58 | public virtual object Clone() 59 | { 60 | SQLiteSelectStatement stmt = null; 61 | if (_select != null) 62 | stmt = (SQLiteSelectStatement)_select.Clone(); 63 | SQLiteFromClause f = null; 64 | if (_from != null) 65 | f = (SQLiteFromClause)_from.Clone(); 66 | SQLiteFromInternalTable res = new SQLiteFromInternalTable(); 67 | res._from = f; 68 | res._select = stmt; 69 | return res; 70 | } 71 | 72 | private SQLiteSelectStatement _select; 73 | private SQLiteFromClause _from; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteIdExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteIdExpression : SQLiteExpression 8 | { 9 | public SQLiteIdExpression(string id) 10 | { 11 | _id = id; 12 | } 13 | 14 | public string Id 15 | { 16 | get { return _id; } 17 | set { _id = value; } 18 | } 19 | 20 | public override bool IsConstant(bool allowNull) 21 | { 22 | return false; 23 | } 24 | 25 | public override bool Equals(object obj) 26 | { 27 | if (obj == null) 28 | return false; 29 | 30 | SQLiteIdExpression dst = obj as SQLiteIdExpression; 31 | if (dst == null) 32 | return false; 33 | 34 | if (_id != dst._id) 35 | return false; 36 | 37 | return base.Equals(obj); 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return _id; 43 | } 44 | 45 | public override object Clone() 46 | { 47 | SQLiteExpression res = new SQLiteIdExpression(_id); 48 | return res; 49 | } 50 | 51 | private string _id; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteIndexedColumn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteIndexedColumn 8 | { 9 | public SQLiteIndexedColumn() 10 | { 11 | } 12 | 13 | public SQLiteIndexedColumn(string name, string collation, SQLiteSortOrder order) 14 | { 15 | ColumnName = name; 16 | Collation = collation; 17 | _order = order; 18 | } 19 | 20 | public string ColumnName 21 | { 22 | get { return _name; } 23 | set 24 | { 25 | _name = Utils.QuoteIfNeeded(value); 26 | } 27 | } 28 | 29 | public string Collation 30 | { 31 | get { return _collation; } 32 | set 33 | { 34 | _collation = Utils.QuoteIfNeeded(value); 35 | } 36 | } 37 | 38 | public SQLiteSortOrder SortOrder 39 | { 40 | get { return _order; } 41 | set { _order = value; } 42 | } 43 | 44 | public override bool Equals(object obj) 45 | { 46 | if (obj == null) 47 | return false; 48 | 49 | SQLiteIndexedColumn dst = obj as SQLiteIndexedColumn; 50 | if (dst == null) 51 | return false; 52 | 53 | if (_name != dst._name || _collation != dst._collation || _order != dst._order) 54 | return false; 55 | 56 | return true; 57 | } 58 | 59 | public override string ToString() 60 | { 61 | StringBuilder sb = new StringBuilder(); 62 | sb.Append(_name); 63 | if (_collation != null) 64 | sb.Append(" COLLATE " + _collation); 65 | if (_order == SQLiteSortOrder.Ascending) 66 | sb.Append(" ASC"); 67 | else if (_order == SQLiteSortOrder.Descending) 68 | sb.Append(" DESC"); 69 | 70 | return sb.ToString(); 71 | } 72 | 73 | public virtual object Clone() 74 | { 75 | SQLiteIndexedColumn res = new SQLiteIndexedColumn(); 76 | res._name = _name; 77 | res._collation = _collation; 78 | res._order = _order; 79 | return res; 80 | } 81 | 82 | private string _name; 83 | private string _collation; 84 | private SQLiteSortOrder _order; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteInsertPrefix.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteInsertPrefix 8 | { 9 | public SQLiteInsertPrefix() 10 | { 11 | _isInsert = false; 12 | } 13 | 14 | public SQLiteInsertPrefix(SQLiteResolveAction conf) 15 | { 16 | _isInsert = true; 17 | _conf = conf; 18 | } 19 | 20 | public bool IsReplace 21 | { 22 | get { return !_isInsert; } 23 | } 24 | 25 | public bool IsInsert 26 | { 27 | get { return _isInsert; } 28 | } 29 | 30 | public SQLiteResolveAction ResolveAction 31 | { 32 | get { return _conf; } 33 | } 34 | 35 | public override bool Equals(object obj) 36 | { 37 | if (obj == null) 38 | return false; 39 | 40 | SQLiteInsertPrefix dst = obj as SQLiteInsertPrefix; 41 | if (dst == null) 42 | return false; 43 | 44 | return _conf == dst._conf; 45 | } 46 | 47 | public virtual object Clone() 48 | { 49 | SQLiteInsertPrefix res = new SQLiteInsertPrefix(_conf); 50 | res._isInsert = _isInsert; 51 | return res; 52 | } 53 | 54 | private bool _isInsert = false; 55 | private SQLiteResolveAction _conf; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteJoinOperator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | [Flags] 8 | public enum SQLiteJoinOperator 9 | { 10 | Comma = 0x01, 11 | 12 | Natural = 0x02, 13 | 14 | Left = 0x04, 15 | 16 | Inner = 0x08, 17 | 18 | Cross = 0x10, 19 | 20 | Outer = 0x20, 21 | 22 | Join = 0x40, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteLikeOperator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteLikeOperator 8 | { 9 | private SQLiteLikeOperator() 10 | { 11 | } 12 | 13 | public SQLiteLikeOperator(SQLiteLike like, bool negate) 14 | { 15 | _like = like; 16 | _negate = negate; 17 | } 18 | 19 | public SQLiteLike Like 20 | { 21 | get { return _like; } 22 | set { _like = value; } 23 | } 24 | 25 | public bool Negate 26 | { 27 | get { return _negate; } 28 | set { _negate = value; } 29 | } 30 | 31 | public override bool Equals(object obj) 32 | { 33 | if (obj == null) 34 | return false; 35 | 36 | SQLiteLikeOperator dst = obj as SQLiteLikeOperator; 37 | if (dst == null) 38 | return false; 39 | 40 | if (_like != dst._like || _negate != dst._negate) 41 | return false; 42 | 43 | return true; 44 | } 45 | 46 | public override string ToString() 47 | { 48 | StringBuilder sb = new StringBuilder(); 49 | if (_negate) 50 | sb.Append("NOT "); 51 | switch (_like) 52 | { 53 | case SQLiteLike.Like: 54 | sb.Append("LIKE"); 55 | break; 56 | case SQLiteLike.Glob: 57 | sb.Append("GLOB"); 58 | break; 59 | case SQLiteLike.Regexp: 60 | sb.Append("REGEXP"); 61 | break; 62 | case SQLiteLike.Match: 63 | sb.Append("MATCH"); 64 | break; 65 | default: 66 | throw new ArgumentException("illegal like operator [" + _like.ToString() + "]"); 67 | } // switch 68 | 69 | return sb.ToString(); 70 | } 71 | 72 | public virtual object Clone() 73 | { 74 | SQLiteLikeOperator res = new SQLiteLikeOperator(); 75 | res._like = _like; 76 | res._negate = _negate; 77 | return res; 78 | } 79 | 80 | private SQLiteLike _like; 81 | private bool _negate; 82 | } 83 | 84 | public enum SQLiteLike 85 | { 86 | None = 0, 87 | 88 | Like = 1, 89 | 90 | Glob = 2, 91 | 92 | Regexp = 3, 93 | 94 | Match = 4, 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteLimitClause.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteLimitClause 8 | { 9 | private SQLiteLimitClause() 10 | { 11 | } 12 | 13 | public SQLiteLimitClause(SQLiteExpression limit) 14 | { 15 | _limit = limit; 16 | } 17 | 18 | public SQLiteLimitClause(SQLiteExpression limit, SQLiteExpression offset) 19 | { 20 | _limit = limit; 21 | _offset = offset; 22 | } 23 | 24 | public SQLiteExpression LimitExpression 25 | { 26 | get { return _limit; } 27 | set { _limit = value; } 28 | } 29 | 30 | public SQLiteExpression OffsetExpression 31 | { 32 | get { return _offset; } 33 | set { _offset = value; } 34 | } 35 | 36 | public override bool Equals(object obj) 37 | { 38 | if (obj == null) 39 | return false; 40 | 41 | SQLiteLimitClause dst = obj as SQLiteLimitClause; 42 | if (dst == null) 43 | return false; 44 | 45 | if (!RefCompare.Compare(_limit, dst._limit)) 46 | return false; 47 | if (!RefCompare.Compare(_offset, dst._offset)) 48 | return false; 49 | 50 | return true; 51 | } 52 | 53 | public override string ToString() 54 | { 55 | if (_offset == null) 56 | return "LIMIT " + _limit.ToString(); 57 | return "LIMIT " + _limit.ToString() + " OFFSET " + _offset.ToString(); 58 | } 59 | 60 | public virtual object Clone() 61 | { 62 | SQLiteExpression limit = null; 63 | if (_limit != null) 64 | limit = (SQLiteExpression)_limit.Clone(); 65 | SQLiteExpression offset = null; 66 | if (_offset != null) 67 | offset = (SQLiteExpression)_offset.Clone(); 68 | 69 | SQLiteLimitClause res = new SQLiteLimitClause(); 70 | res._limit = limit; 71 | res._offset = offset; 72 | return res; 73 | } 74 | 75 | private SQLiteExpression _limit; 76 | private SQLiteExpression _offset; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteMultiSelectStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteMultiSelectStatement : SQLiteSelectStatement 8 | { 9 | private SQLiteMultiSelectStatement() 10 | { 11 | } 12 | 13 | public SQLiteMultiSelectStatement(SQLiteSelectStatement first, SQLiteSelectOperator op, SQLiteSelectStatement next) 14 | { 15 | _first = first; 16 | _op = op; 17 | _next = next; 18 | } 19 | 20 | public SQLiteSelectStatement First 21 | { 22 | get { return _first; } 23 | set { _first = value; } 24 | } 25 | 26 | public SQLiteSelectOperator SelectOperator 27 | { 28 | get { return _op; } 29 | set { _op = value; } 30 | } 31 | 32 | public SQLiteSelectStatement Next 33 | { 34 | get { return _next; } 35 | set { _next = value; } 36 | } 37 | 38 | public override bool Equals(object obj) 39 | { 40 | if (obj == null) 41 | return false; 42 | 43 | SQLiteMultiSelectStatement dst = obj as SQLiteMultiSelectStatement; 44 | if (dst == null) 45 | return false; 46 | 47 | if (!RefCompare.CompareMany(_first, dst._first, _next, dst._next)) 48 | return false; 49 | 50 | if (_op != dst._op) 51 | return false; 52 | 53 | return base.Equals(obj); 54 | } 55 | 56 | public override string ToString() 57 | { 58 | return _first.ToString() + "\r\n" + Utils.GetSelectOperatorString(_op) + "\r\n" + _next.ToString(); 59 | } 60 | 61 | public override object Clone() 62 | { 63 | SQLiteSelectStatement first = null; 64 | if (_first != null) 65 | first = (SQLiteSelectStatement)_first.Clone(); 66 | SQLiteSelectStatement next = null; 67 | if (_next != null) 68 | next = (SQLiteSelectStatement)_next.Clone(); 69 | 70 | SQLiteMultiSelectStatement res = new SQLiteMultiSelectStatement(); 71 | res._first = first; 72 | res._op = _op; 73 | res._next = next; 74 | return res; 75 | } 76 | 77 | private SQLiteSelectStatement _first; 78 | private SQLiteSelectOperator _op; 79 | private SQLiteSelectStatement _next; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteNameExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteNameExpression : SQLiteExpression 8 | { 9 | private SQLiteNameExpression() 10 | { 11 | } 12 | 13 | public SQLiteNameExpression(SQLiteObjectName name) 14 | { 15 | _name = name; 16 | } 17 | 18 | public SQLiteObjectName Name 19 | { 20 | get { return _name; } 21 | set { _name = value; } 22 | } 23 | 24 | public override bool IsConstant(bool allowNull) 25 | { 26 | return false; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteNameExpression dst = obj as SQLiteNameExpression; 35 | if (dst == null) 36 | return false; 37 | 38 | if (!RefCompare.Compare(_name, dst._name)) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return _name.ToString(); 47 | } 48 | 49 | public override object Clone() 50 | { 51 | SQLiteObjectName name = null; 52 | if (_name != null) 53 | name = (SQLiteObjectName)_name.Clone(); 54 | 55 | SQLiteNameExpression res = new SQLiteNameExpression(); 56 | res._name = name; 57 | return res; 58 | } 59 | 60 | private SQLiteObjectName _name; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteNullColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteNullColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLiteNullColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteNullColumnConstraint(string name, bool isnull, SQLiteResolveAction conf) 15 | : base(name) 16 | { 17 | _isnull = isnull; 18 | _conf = conf; 19 | } 20 | 21 | public bool IsNull 22 | { 23 | get { return _isnull; } 24 | set { _isnull = value; } 25 | } 26 | 27 | public SQLiteResolveAction ResolveAction 28 | { 29 | get { return _conf; } 30 | set { _conf = value; } 31 | } 32 | 33 | public override bool Equals(object obj) 34 | { 35 | if (obj == null) 36 | return false; 37 | 38 | SQLiteNullColumnConstraint dst = obj as SQLiteNullColumnConstraint; 39 | if (dst == null) 40 | return false; 41 | 42 | if (dst._isnull != this._isnull) 43 | return false; 44 | if (this._conf != dst._conf) 45 | return false; 46 | 47 | return base.Equals(obj); 48 | } 49 | 50 | public override string ToString() 51 | { 52 | StringBuilder sb = new StringBuilder(); 53 | if (ConstraintName != null) 54 | sb.Append("CONSTRAINT " + ConstraintName + " "); 55 | if (_isnull) 56 | sb.Append("NULL"); 57 | else 58 | sb.Append("NOT NULL"); 59 | if (_conf != SQLiteResolveAction.None) 60 | sb.Append(" " + Utils.GetConflictClauseString(_conf)); 61 | return sb.ToString(); 62 | } 63 | 64 | public override object Clone() 65 | { 66 | SQLiteNullColumnConstraint res = new SQLiteNullColumnConstraint(this.ConstraintName); 67 | res._isnull = _isnull; 68 | res._conf = _conf; 69 | return res; 70 | } 71 | 72 | private bool _isnull; 73 | private SQLiteResolveAction _conf; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteNullExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteNullExpression : SQLiteExpression 8 | { 9 | public override bool Equals(object obj) 10 | { 11 | if (obj == null) 12 | return false; 13 | 14 | SQLiteNullExpression dst = obj as SQLiteNullExpression; 15 | if (dst == null) 16 | return false; 17 | 18 | return true; 19 | } 20 | 21 | public override bool IsConstant(bool allowNull) 22 | { 23 | return allowNull; 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return "NULL"; 29 | } 30 | 31 | public override object Clone() 32 | { 33 | SQLiteExpression res = new SQLiteNullExpression(); 34 | return res; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteObjectName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteObjectName 8 | { 9 | public SQLiteObjectName(string first, params string[] rest) 10 | { 11 | _first = Utils.QuoteIfNeeded(first); 12 | 13 | if (rest != null) 14 | { 15 | bool found = false; 16 | foreach (string r in rest) 17 | { 18 | if (r != null) 19 | { 20 | found = true; 21 | break; 22 | } 23 | } 24 | if (found) 25 | _rest = Utils.QuoteIfNeeded(rest); 26 | } 27 | } 28 | 29 | public string FirstName 30 | { 31 | get { return _first; } 32 | } 33 | 34 | public string[] Rest 35 | { 36 | get { return _rest; } 37 | } 38 | 39 | public override string ToString() 40 | { 41 | StringBuilder sb = new StringBuilder(); 42 | sb.Append(_first); 43 | if (_rest != null) 44 | { 45 | foreach (string r in _rest) 46 | sb.Append("." + r); 47 | } 48 | return sb.ToString(); 49 | } 50 | 51 | public override bool Equals(object obj) 52 | { 53 | if (obj == null) 54 | return false; 55 | 56 | SQLiteObjectName dst = obj as SQLiteObjectName; 57 | if (dst == null) 58 | return false; 59 | 60 | return dst.ToString().ToLower().Equals(this.ToString().ToLower()); 61 | } 62 | 63 | public override int GetHashCode() 64 | { 65 | return this.ToString().GetHashCode(); 66 | } 67 | 68 | public virtual object Clone() 69 | { 70 | string[] r = null; 71 | if (_rest != null) 72 | { 73 | r = new string[_rest.Length]; 74 | for(int i=0; i<_rest.Length; i++) 75 | r[i] = _rest[i]; 76 | } 77 | SQLiteObjectName res = new SQLiteObjectName(_first, r); 78 | return res; 79 | } 80 | 81 | private string _first; 82 | private string[] _rest; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteOperator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public enum SQLiteOperator 8 | { 9 | None = 0, 10 | 11 | And = 1, 12 | 13 | Or = 2, 14 | 15 | Lt = 3, 16 | 17 | Gt = 4, 18 | 19 | Ge = 5, 20 | 21 | Le = 6, 22 | 23 | Eq = 7, 24 | 25 | Ne = 8, 26 | 27 | BitAnd = 9, 28 | 29 | BitOr = 10, 30 | 31 | Lshift = 11, 32 | 33 | Rshift = 12, 34 | 35 | Plus = 13, 36 | 37 | Minus = 14, 38 | 39 | Star = 15, 40 | 41 | Slash = 16, 42 | 43 | Rem = 17, 44 | 45 | Concat = 18, 46 | 47 | IsNull = 19, 48 | 49 | NotNull = 20, 50 | 51 | Is_Null = 21, 52 | 53 | Not_Null = 22, 54 | 55 | Is_Not_Null = 23, 56 | 57 | Not = 24, 58 | 59 | BitNot = 25, 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SQLiteParser/SQLitePrimaryKeyColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLitePrimaryKeyColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLitePrimaryKeyColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLitePrimaryKeyColumnConstraint(string name, SQLiteSortOrder order, SQLiteResolveAction conf, bool autoincrement) 15 | : base(name) 16 | { 17 | _order = order; 18 | _conf = conf; 19 | _autoincrement = autoincrement; 20 | } 21 | 22 | public bool IsAutoincrement 23 | { 24 | get { return _autoincrement; } 25 | set { _autoincrement = value; } 26 | } 27 | 28 | public SQLiteSortOrder SortOrder 29 | { 30 | get { return _order; } 31 | set { _order = value; } 32 | } 33 | 34 | public SQLiteResolveAction ResolveAction 35 | { 36 | get { return _conf; } 37 | set { _conf = value; } 38 | } 39 | 40 | public override bool Equals(object obj) 41 | { 42 | if (obj == null) 43 | return false; 44 | 45 | SQLitePrimaryKeyColumnConstraint dst = obj as SQLitePrimaryKeyColumnConstraint; 46 | if (dst == null) 47 | return false; 48 | 49 | if (_autoincrement != dst._autoincrement || _order != dst._order || _conf != dst._conf) 50 | return false; 51 | 52 | return base.Equals(obj); 53 | } 54 | 55 | public override string ToString() 56 | { 57 | StringBuilder sb = new StringBuilder(); 58 | if (ConstraintName != null) 59 | sb.Append("CONSTRAINT " + ConstraintName + " "); 60 | sb.Append("PRIMARY KEY"); 61 | if (_order == SQLiteSortOrder.Ascending) 62 | sb.Append(" ASC"); 63 | else if (_order == SQLiteSortOrder.Descending) 64 | sb.Append(" DESC"); 65 | if (_conf != SQLiteResolveAction.None) 66 | sb.Append(" " + Utils.GetConflictClauseString(_conf)); 67 | if (_autoincrement) 68 | sb.Append(" AUTOINCREMENT"); 69 | return sb.ToString(); 70 | } 71 | 72 | public override object Clone() 73 | { 74 | SQLitePrimaryKeyColumnConstraint res = new SQLitePrimaryKeyColumnConstraint(ConstraintName); 75 | res._autoincrement = _autoincrement; 76 | res._order = _order; 77 | res._conf = _conf; 78 | return res; 79 | } 80 | 81 | private bool _autoincrement; 82 | private SQLiteSortOrder _order; 83 | private SQLiteResolveAction _conf; 84 | } 85 | 86 | public enum SQLiteSortOrder 87 | { 88 | None = 0, 89 | 90 | Ascending = 1, 91 | 92 | Descending = 2, 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteRaiseExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteRaiseExpression : SQLiteExpression 8 | { 9 | public SQLiteRaiseExpression() 10 | { 11 | RaiseType = SQLiteResolveAction.Ignore; 12 | } 13 | 14 | public SQLiteRaiseExpression(SQLiteResolveAction raiseType, string errmsg) 15 | { 16 | _errmsg = errmsg; 17 | RaiseType = raiseType; 18 | } 19 | 20 | public SQLiteResolveAction RaiseType 21 | { 22 | get { return _raiseType; } 23 | set 24 | { 25 | if (value == SQLiteResolveAction.Rollback || 26 | value == SQLiteResolveAction.Abort || 27 | value == SQLiteResolveAction.Fail || 28 | value == SQLiteResolveAction.Ignore) 29 | _raiseType = value; 30 | if (value == SQLiteResolveAction.Ignore) 31 | _errmsg = null; 32 | } 33 | } 34 | 35 | public string ErrorMessage 36 | { 37 | get { return _errmsg; } 38 | set { _errmsg = value; } 39 | } 40 | 41 | public override bool IsConstant(bool allowNull) 42 | { 43 | return false; 44 | } 45 | 46 | public override bool Equals(object obj) 47 | { 48 | if (obj == null) 49 | return false; 50 | 51 | SQLiteRaiseExpression dst = obj as SQLiteRaiseExpression; 52 | if (dst == null) 53 | return false; 54 | 55 | if (_raiseType != dst._raiseType || _errmsg != dst._errmsg) 56 | return false; 57 | 58 | return base.Equals(obj); 59 | } 60 | 61 | public override string ToString() 62 | { 63 | string res; 64 | if (_raiseType == SQLiteResolveAction.Rollback || _raiseType == SQLiteResolveAction.Abort || 65 | _raiseType == SQLiteResolveAction.Fail) 66 | { 67 | // RAISE LP raisetype COMMA nm RP 68 | res = "RAISE (" + Utils.GetResolveActionString(_raiseType) + "," + _errmsg + ")"; 69 | } 70 | else if (_raiseType == SQLiteResolveAction.Ignore) 71 | { 72 | // RAISE LP IGNORE RP 73 | res = "RAISE (IGNORE)"; 74 | } 75 | else 76 | throw new ArgumentException("Illegal raise type [" + _raiseType.ToString() + "]"); 77 | 78 | return res; 79 | } 80 | 81 | public override object Clone() 82 | { 83 | SQLiteRaiseExpression res = new SQLiteRaiseExpression(); 84 | res._raiseType = _raiseType; 85 | res._errmsg = _errmsg; 86 | return res; 87 | } 88 | 89 | private SQLiteResolveAction _raiseType; 90 | private string _errmsg; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteResolveAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | /// 8 | /// Lists possible conflict resolve actions 9 | /// 10 | public enum SQLiteResolveAction 11 | { 12 | None = 0, 13 | 14 | Ignore = 1, 15 | 16 | Replace = 2, 17 | 18 | Rollback = 3, 19 | 20 | Abort = 4, 21 | 22 | Fail = 5, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSchema.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteSchema 8 | { 9 | public void AddStatement(SQLiteDdlStatement stmt) 10 | { 11 | if (stmt is SQLiteCreateTableStatement) 12 | Tables.Add(stmt.ObjectName, (SQLiteCreateTableStatement)stmt); 13 | else if (stmt is SQLiteCreateIndexStatement) 14 | Indexes.Add(stmt.ObjectName, (SQLiteCreateIndexStatement)stmt); 15 | else if (stmt is SQLiteCreateViewStatement) 16 | Views.Add(stmt.ObjectName, (SQLiteCreateViewStatement)stmt); 17 | else if (stmt is SQLiteCreateTriggerStatement) 18 | Triggers.Add(stmt.ObjectName, (SQLiteCreateTriggerStatement)stmt); 19 | else 20 | throw new ArgumentException("Illegal statement type"); 21 | } 22 | 23 | public Dictionary Tables = new Dictionary(); 24 | public Dictionary Indexes = new Dictionary(); 25 | public Dictionary Views = new Dictionary(); 26 | public Dictionary Triggers = new Dictionary(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSelectColumn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteSelectColumn 8 | { 9 | public SQLiteSelectColumn(SQLiteExpression expr, string name) 10 | { 11 | _expr = expr; 12 | AsName = name; 13 | } 14 | 15 | public SQLiteSelectColumn(SQLiteObjectName tableName) 16 | { 17 | _tableName = tableName; 18 | } 19 | 20 | public SQLiteSelectColumn() 21 | { 22 | } 23 | 24 | public SQLiteExpression Expression 25 | { 26 | get { return _expr; } 27 | set { _expr = value; } 28 | } 29 | 30 | public string AsName 31 | { 32 | get { return _asName; } 33 | set { _asName = Utils.QuoteIfNeeded(value); } 34 | } 35 | 36 | public SQLiteObjectName TableName 37 | { 38 | get { return _tableName; } 39 | set { _tableName = value; } 40 | } 41 | 42 | public bool IsSingleWildcard 43 | { 44 | get { return _expr == null && _tableName == null && _asName == null; } 45 | } 46 | 47 | public override bool Equals(object obj) 48 | { 49 | if (obj == null) 50 | return false; 51 | 52 | SQLiteSelectColumn dst = obj as SQLiteSelectColumn; 53 | if (dst == null) 54 | return false; 55 | 56 | if (!RefCompare.CompareMany(_expr, dst._expr, _tableName, dst._tableName)) 57 | return false; 58 | if (_asName != dst._asName) 59 | return false; 60 | 61 | return true; 62 | } 63 | 64 | public override string ToString() 65 | { 66 | if (_tableName != null) 67 | return _tableName.ToString() + ".*"; 68 | if (_expr != null && _asName != null) 69 | return _expr.ToString() + " AS " + _asName; 70 | else if (_expr != null) 71 | return _expr.ToString(); 72 | return "*"; 73 | } 74 | 75 | public virtual object Clone() 76 | { 77 | SQLiteExpression expr = null; 78 | if (_expr != null) 79 | expr = (SQLiteExpression)_expr.Clone(); 80 | SQLiteObjectName tableName = null; 81 | if (_tableName != null) 82 | tableName = (SQLiteObjectName)_tableName.Clone(); 83 | 84 | SQLiteSelectColumn res = new SQLiteSelectColumn(); 85 | res._expr = expr; 86 | res._asName = _asName; 87 | res._tableName = tableName; 88 | return res; 89 | } 90 | 91 | private SQLiteExpression _expr; 92 | private string _asName; 93 | private SQLiteObjectName _tableName; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSelectExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteSelectExpression : SQLiteExpression 8 | { 9 | private SQLiteSelectExpression() 10 | { 11 | } 12 | 13 | public SQLiteSelectExpression(SQLiteSelectStatement select) 14 | { 15 | _select = select; 16 | } 17 | 18 | public SQLiteSelectStatement SelectStatement 19 | { 20 | get { return _select; } 21 | set { _select = value; } 22 | } 23 | 24 | public override bool IsConstant(bool allowNull) 25 | { 26 | return false; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteSelectExpression dst = obj as SQLiteSelectExpression; 35 | if (dst == null) 36 | return false; 37 | 38 | if (!RefCompare.Compare(_select, dst._select)) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override object Clone() 45 | { 46 | SQLiteSelectStatement select = null; 47 | if (_select != null) 48 | select = (SQLiteSelectStatement)_select.Clone(); 49 | 50 | SQLiteSelectExpression res = new SQLiteSelectExpression(); 51 | res._select = select; 52 | return res; 53 | } 54 | 55 | public override string ToString() 56 | { 57 | return "("+_select.ToString()+")"; 58 | } 59 | 60 | private SQLiteSelectStatement _select; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSelectOperator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | /// 8 | /// Describes all SELECT operators 9 | /// 10 | public enum SQLiteSelectOperator 11 | { 12 | None = 0, 13 | 14 | Union = 1, 15 | 16 | UnionAll = 2, 17 | 18 | Except = 3, 19 | 20 | Intersect = 4, 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSelectStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteSelectStatement : SQLiteStatement 8 | { 9 | public override object Clone() 10 | { 11 | return new SQLiteSelectStatement(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteSortItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteSortItem 8 | { 9 | private SQLiteSortItem() 10 | { 11 | } 12 | 13 | public SQLiteSortItem(SQLiteExpression expr, SQLiteSortOrder order) 14 | { 15 | _expr = expr; 16 | _order = order; 17 | } 18 | 19 | public SQLiteExpression Expression 20 | { 21 | get { return _expr; } 22 | set { _expr = value; } 23 | } 24 | 25 | public SQLiteSortOrder SortOrder 26 | { 27 | get { return _order; } 28 | set { _order = value; } 29 | } 30 | 31 | public override bool Equals(object obj) 32 | { 33 | if (obj == null) 34 | return false; 35 | 36 | SQLiteSortItem dst = obj as SQLiteSortItem; 37 | if (dst == null) 38 | return false; 39 | 40 | if (!RefCompare.Compare(_expr, dst._expr)) 41 | return false; 42 | 43 | if (_order != dst._order) 44 | return false; 45 | 46 | return true; 47 | } 48 | 49 | public override string ToString() 50 | { 51 | StringBuilder sb = new StringBuilder(); 52 | 53 | sb.Append(_expr.ToString()); 54 | if (_order == SQLiteSortOrder.Ascending) 55 | sb.Append(" ASC"); 56 | else if (_order == SQLiteSortOrder.Descending) 57 | sb.Append(" DESC"); 58 | 59 | return sb.ToString(); 60 | } 61 | 62 | public virtual object Clone() 63 | { 64 | SQLiteExpression expr = null; 65 | if (_expr != null) 66 | expr = (SQLiteExpression)_expr.Clone(); 67 | 68 | SQLiteSortItem res = new SQLiteSortItem(); 69 | res._expr = expr; 70 | res._order = _order; 71 | return res; 72 | } 73 | 74 | private SQLiteExpression _expr; 75 | private SQLiteSortOrder _order; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteStatement 8 | { 9 | public override bool Equals(object obj) 10 | { 11 | if (obj == null) 12 | return false; 13 | 14 | SQLiteStatement dst = obj as SQLiteStatement; 15 | if (dst == null) 16 | return false; 17 | 18 | return true; 19 | } 20 | 21 | public virtual object Clone() 22 | { 23 | return new SQLiteStatement(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteTableConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteTableConstraint 8 | { 9 | private SQLiteTableConstraint() 10 | { 11 | } 12 | 13 | public SQLiteTableConstraint(string name) 14 | { 15 | ConstraintName = name; 16 | } 17 | 18 | public string ConstraintName 19 | { 20 | get { return _name; } 21 | set 22 | { 23 | _name = Utils.QuoteIfNeeded(value); 24 | } 25 | } 26 | 27 | /// 28 | /// Used to merge CONSTRAINT xxx / NEXT constraint pairs (they are actually the 29 | /// same constraint). 30 | /// 31 | /// The list to merge 32 | /// The resulting (merged) constraints list 33 | public static List Merge(List cons) 34 | { 35 | List res = new List(); 36 | for (int i = 0; i < cons.Count; i++) 37 | { 38 | SQLiteTableConstraint c = cons[i]; 39 | if (c.GetType() == typeof(SQLiteTableConstraint) && c.ConstraintName != null) 40 | { 41 | i++; 42 | if (i < cons.Count) 43 | { 44 | SQLiteTableConstraint next = cons[i]; 45 | next.ConstraintName = c.ConstraintName; 46 | res.Add(next); 47 | } 48 | } 49 | else 50 | res.Add(c); 51 | } // for 52 | 53 | return res; 54 | } 55 | 56 | public override bool Equals(object obj) 57 | { 58 | if (obj == null) 59 | return false; 60 | 61 | SQLiteTableConstraint dst = obj as SQLiteTableConstraint; 62 | if (dst == null) 63 | return false; 64 | 65 | return this.ConstraintName == dst.ConstraintName; 66 | } 67 | 68 | public override string ToString() 69 | { 70 | return ""; 71 | } 72 | 73 | public virtual object Clone() 74 | { 75 | SQLiteTableConstraint res = new SQLiteTableConstraint(); 76 | res._name = _name; 77 | return res; 78 | } 79 | 80 | private string _name; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteTermExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteTermExpression : SQLiteExpression 8 | { 9 | private SQLiteTermExpression() 10 | { 11 | } 12 | 13 | public SQLiteTermExpression(SQLiteTerm term) 14 | { 15 | _term = term; 16 | } 17 | 18 | public SQLiteTerm Term 19 | { 20 | get { return _term; } 21 | set { _term = value; } 22 | } 23 | 24 | public override bool IsConstant(bool allowNull) 25 | { 26 | return !_term.AsTimeFunction.HasValue; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteTermExpression dst = obj as SQLiteTermExpression; 35 | if (dst == null) 36 | return false; 37 | 38 | if (!RefCompare.Compare(_term, dst._term)) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return _term.ToString(); 47 | } 48 | 49 | public override object Clone() 50 | { 51 | SQLiteTerm term = null; 52 | if (_term != null) 53 | term = (SQLiteTerm)_term.Clone(); 54 | 55 | SQLiteTermExpression res = new SQLiteTermExpression(); 56 | res._term = term; 57 | return res; 58 | } 59 | 60 | private SQLiteTerm _term; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteTriggerTime.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public enum SQLiteTriggerTime 8 | { 9 | None = 0, 10 | 11 | Before = 1, 12 | 13 | After = 2, 14 | 15 | InsteadOf = 3, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteUnaryExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteUnaryExpression : SQLiteExpression 8 | { 9 | private SQLiteUnaryExpression() 10 | { 11 | } 12 | 13 | public SQLiteUnaryExpression(SQLiteOperator op, SQLiteExpression expr) 14 | { 15 | _op = op; 16 | _expr = expr; 17 | } 18 | 19 | public SQLiteOperator UnaryOperator 20 | { 21 | get { return _op; } 22 | set { _op = value; } 23 | } 24 | 25 | public SQLiteExpression Expression 26 | { 27 | get { return _expr; } 28 | set { _expr = value; } 29 | } 30 | 31 | public override bool IsConstant(bool allowNull) 32 | { 33 | return _expr.IsConstant(allowNull); 34 | } 35 | 36 | public override bool Equals(object obj) 37 | { 38 | if (obj == null) 39 | return false; 40 | 41 | SQLiteUnaryExpression dst = obj as SQLiteUnaryExpression; 42 | if (dst == null) 43 | return false; 44 | 45 | if (!RefCompare.Compare(_expr, dst._expr)) 46 | return false; 47 | if (_op != dst._op) 48 | return false; 49 | 50 | return base.Equals(obj); 51 | } 52 | 53 | public override string ToString() 54 | { 55 | string res = null; 56 | if (_op == SQLiteOperator.Is_Not_Null || _op == SQLiteOperator.Is_Null || 57 | _op == SQLiteOperator.IsNull || _op == SQLiteOperator.Not_Null || 58 | _op == SQLiteOperator.NotNull || _op == SQLiteOperator.Not) 59 | res = _expr.ToString() + " " + Utils.GetOperatorString(_op) + " "; 60 | else 61 | res = Utils.GetOperatorString(_op) + _expr.ToString(); 62 | return res; 63 | } 64 | 65 | public override object Clone() 66 | { 67 | SQLiteExpression expr = null; 68 | if (_expr != null) 69 | expr = (SQLiteExpression)_expr.Clone(); 70 | 71 | SQLiteUnaryExpression res = new SQLiteUnaryExpression(); 72 | res._expr = expr; 73 | res._op = _op; 74 | return res; 75 | } 76 | 77 | private SQLiteOperator _op; 78 | private SQLiteExpression _expr; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteUniqueColumnConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteUniqueColumnConstraint : SQLiteColumnConstraint 8 | { 9 | private SQLiteUniqueColumnConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteUniqueColumnConstraint(string name, SQLiteResolveAction conf) 15 | : base(name) 16 | { 17 | _conf = conf; 18 | } 19 | 20 | public SQLiteResolveAction ResolveAction 21 | { 22 | get { return _conf; } 23 | set { _conf = value; } 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | if (obj == null) 29 | return false; 30 | 31 | SQLiteUniqueColumnConstraint dst = obj as SQLiteUniqueColumnConstraint; 32 | if (dst == null) 33 | return false; 34 | 35 | if (_conf != dst._conf) 36 | return false; 37 | 38 | return base.Equals(obj); 39 | } 40 | 41 | public override string ToString() 42 | { 43 | StringBuilder sb = new StringBuilder(); 44 | if (this.ConstraintName != null) 45 | sb.Append("CONSTRAINT " + this.ConstraintName + " "); 46 | sb.Append("UNIQUE"); 47 | if (_conf != SQLiteResolveAction.None) 48 | sb.Append(" " + Utils.GetConflictClauseString(_conf)); 49 | return sb.ToString(); 50 | } 51 | 52 | public override object Clone() 53 | { 54 | SQLiteUniqueColumnConstraint res = new SQLiteUniqueColumnConstraint(this.ConstraintName); 55 | res._conf = _conf; 56 | return res; 57 | } 58 | 59 | private SQLiteResolveAction _conf; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteUniqueTableConstraint.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteUniqueTableConstraint : SQLiteTableConstraint 8 | { 9 | private SQLiteUniqueTableConstraint(string name) 10 | : base(name) 11 | { 12 | } 13 | 14 | public SQLiteUniqueTableConstraint(string name, List columns, SQLiteResolveAction conf) 15 | : base(name) 16 | { 17 | _columns = columns; 18 | _conf = conf; 19 | } 20 | 21 | public SQLiteResolveAction ResolveAction 22 | { 23 | get { return _conf; } 24 | set { _conf = value; } 25 | } 26 | 27 | public List UniqueColumns 28 | { 29 | get { return _columns; } 30 | set { _columns = value; } 31 | } 32 | 33 | public override bool Equals(object obj) 34 | { 35 | if (obj == null) 36 | return false; 37 | 38 | SQLiteUniqueTableConstraint dst = obj as SQLiteUniqueTableConstraint; 39 | if (dst == null) 40 | return false; 41 | 42 | if (this._conf != dst._conf) 43 | return false; 44 | if (!RefCompare.CompareList(_columns, dst._columns)) 45 | return false; 46 | 47 | return base.Equals(obj); 48 | } 49 | 50 | public override string ToString() 51 | { 52 | StringBuilder sb = new StringBuilder(); 53 | if (ConstraintName != null) 54 | sb.Append("CONSTRAINT " + ConstraintName+" "); 55 | sb.Append("UNIQUE ("); 56 | for (int i = 0; i < _columns.Count; i++) 57 | { 58 | sb.Append(_columns[i].ToString()); 59 | if (i < _columns.Count - 1) 60 | sb.Append(","); 61 | } // for 62 | sb.Append(")"); 63 | if (_conf != SQLiteResolveAction.None) 64 | sb.Append(" " + Utils.GetConflictClauseString(_conf)); 65 | 66 | return sb.ToString(); 67 | } 68 | 69 | public override object Clone() 70 | { 71 | List columns = null; 72 | if (_columns != null) 73 | { 74 | columns = new List(); 75 | foreach (SQLiteIndexedColumn c in _columns) 76 | columns.Add((SQLiteIndexedColumn)c.Clone()); 77 | } 78 | 79 | SQLiteUniqueTableConstraint res = new SQLiteUniqueTableConstraint(this.ConstraintName); 80 | res._conf = _conf; 81 | res._columns = columns; 82 | return res; 83 | } 84 | 85 | private SQLiteResolveAction _conf; 86 | private List _columns; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteUpdateItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteUpdateItem 8 | { 9 | private SQLiteUpdateItem() 10 | { 11 | } 12 | 13 | public SQLiteUpdateItem(string colname, SQLiteExpression expr) 14 | { 15 | ColumnName = colname; 16 | _expr = expr; 17 | } 18 | 19 | public SQLiteExpression Expression 20 | { 21 | get { return _expr; } 22 | set { _expr = value; } 23 | } 24 | 25 | public string ColumnName 26 | { 27 | get { return _colname; } 28 | set 29 | { 30 | _colname = Utils.QuoteIfNeeded(value); 31 | } 32 | } 33 | 34 | public override bool Equals(object obj) 35 | { 36 | if (obj == null) 37 | return false; 38 | 39 | SQLiteUpdateItem dst = obj as SQLiteUpdateItem; 40 | if (dst == null) 41 | return false; 42 | 43 | if (_colname != dst._colname) 44 | return false; 45 | if (!RefCompare.Compare(_expr, dst._expr)) 46 | return false; 47 | 48 | return true; 49 | } 50 | 51 | public override string ToString() 52 | { 53 | return _colname + " = " + _expr.ToString(); 54 | } 55 | 56 | public virtual object Clone() 57 | { 58 | SQLiteExpression expr = null; 59 | if (_expr != null) 60 | expr = (SQLiteExpression)_expr.Clone(); 61 | 62 | SQLiteUpdateItem res = new SQLiteUpdateItem(); 63 | res._colname = _colname; 64 | res._expr = expr; 65 | return res; 66 | } 67 | 68 | private string _colname; 69 | private SQLiteExpression _expr; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /SQLiteParser/SQLiteVariableExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteParser 6 | { 7 | public class SQLiteVariableExpression : SQLiteExpression 8 | { 9 | private SQLiteVariableExpression() 10 | { 11 | } 12 | 13 | public SQLiteVariableExpression(string variable) 14 | { 15 | _variable = variable; 16 | } 17 | 18 | public string Variable 19 | { 20 | get { return _variable; } 21 | set { _variable = value; } 22 | } 23 | 24 | public override bool IsConstant(bool allowNull) 25 | { 26 | return false; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (obj == null) 32 | return false; 33 | 34 | SQLiteVariableExpression dst = obj as SQLiteVariableExpression; 35 | if (dst == null) 36 | return false; 37 | 38 | if (_variable != dst._variable) 39 | return false; 40 | 41 | return base.Equals(obj); 42 | } 43 | 44 | public override string ToString() 45 | { 46 | return _variable; 47 | } 48 | 49 | public override object Clone() 50 | { 51 | SQLiteVariableExpression res = new SQLiteVariableExpression(); 52 | res._variable = _variable; 53 | return res; 54 | } 55 | 56 | private string _variable; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /SQLiteTurbo/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 |
5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /SQLiteTurbo/CompareParams.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// Encapsulates all the necessary comparison parameters. 9 | /// 10 | public class CompareParams 11 | { 12 | #region Constructors 13 | /// 14 | /// Constructs comparison parameters object 15 | /// 16 | /// The path to the left DB file 17 | /// The path to the right DB file 18 | /// Associated comparison type 19 | public CompareParams(string left, string right, ComparisonType ctype, bool compareBlobFields) 20 | { 21 | _left = left; 22 | _right = right; 23 | _ctype = ctype; 24 | _compareBlobFields = compareBlobFields; 25 | } 26 | #endregion 27 | 28 | #region Public Properties 29 | /// 30 | /// Path to the left DB file to compare 31 | /// 32 | public string LeftDbPath 33 | { 34 | get { return _left; } 35 | } 36 | 37 | /// 38 | /// Path to right DB file to compare 39 | /// 40 | public string RightDbPath 41 | { 42 | get { return _right; } 43 | } 44 | 45 | /// 46 | /// The comparision type to use 47 | /// 48 | public ComparisonType ComparisonType 49 | { 50 | get { return _ctype; } 51 | set { _ctype = value; } 52 | } 53 | 54 | /// 55 | /// TRUE means that the compare worker will also compare BLOB field values 56 | /// 57 | public bool IsCompareBlobFields 58 | { 59 | get { return _compareBlobFields; } 60 | set { _compareBlobFields = value; } 61 | } 62 | #endregion 63 | 64 | #region Private Variables 65 | private string _left; 66 | private string _right; 67 | private ComparisonType _ctype = ComparisonType.None; 68 | private bool _compareBlobFields; 69 | #endregion 70 | } 71 | 72 | /// 73 | /// Provides various options to the comparison process. 74 | /// 75 | public enum ComparisonType 76 | { 77 | /// 78 | /// Illegal value 79 | /// 80 | None = 0, 81 | 82 | /// 83 | /// Compare the schema only 84 | /// 85 | CompareSchemaOnly = 1, 86 | 87 | /// 88 | /// Compare both schema and data stored in DB tables. 89 | /// 90 | CompareSchemaAndData = 2, 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /SQLiteTurbo/DiffExporter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// This class is responsible for exporting found changes to a CSV file 9 | /// 10 | public class DiffExporter : AbstractWorker 11 | { 12 | #region CONSTRUCTORS 13 | public DiffExporter(TableChanges changes, string fpath, bool exportUpdates, bool exportAdded, bool exportDeleted) 14 | : base("Diff Exporter") 15 | { 16 | _changes = changes; 17 | _fpath = fpath; 18 | _exportAdded = exportAdded; 19 | _exportDeleted = exportDeleted; 20 | _exportUpdates = exportUpdates; 21 | } 22 | 23 | public DiffExporter(List multiChanges, string fpath, bool exportUpdates, bool exportAdded, bool exportDeleted) 24 | : base("DiffExporter") 25 | { 26 | _multiChanges = multiChanges; 27 | _fpath = fpath; 28 | _exportAdded = exportAdded; 29 | _exportDeleted = exportDeleted; 30 | _exportUpdates = exportUpdates; 31 | } 32 | #endregion 33 | 34 | #region Protected Methods 35 | protected override void DoWork() 36 | { 37 | if (_changes != null) 38 | _changes.ExportToCSV(_fpath, _exportUpdates, _exportAdded, _exportDeleted, ExportHandler); 39 | else 40 | { 41 | // Check how many tables have changes in them 42 | List list = new List(); 43 | foreach (SchemaComparisonItem item in _multiChanges) 44 | { 45 | if (item.TableChanges != null && !item.TableChanges.SameTables) 46 | list.Add(item.TableChanges); 47 | } // foreach 48 | TableChanges.ExportMultipleToCSV(_fpath, list, _exportUpdates, _exportAdded, _exportDeleted, ExportHandler); 49 | } // else 50 | } 51 | 52 | protected override bool IsDualProgress 53 | { 54 | get { return false; } 55 | } 56 | #endregion 57 | 58 | #region Private Methods 59 | private void ExportHandler(long rowsExported, long total, ref bool cancel) 60 | { 61 | cancel = WasCancelled; 62 | if (total == 0) 63 | return; 64 | int next = (int)(100.0 * rowsExported / total); 65 | if (next > _progress) 66 | { 67 | _progress = next; 68 | NotifyPrimaryProgress(false, _progress, rowsExported.ToString() + "/" + total.ToString() + " rows exported", null); 69 | } 70 | } 71 | #endregion 72 | 73 | 74 | #region FIELDS 75 | private int _progress = 0; 76 | private TableChanges _changes; 77 | private List _multiChanges; 78 | private bool _exportUpdates; 79 | private bool _exportAdded; 80 | private bool _exportDeleted; 81 | private string _fpath; 82 | #endregion 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /SQLiteTurbo/EtchedLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows.Forms; 5 | using System.Drawing; 6 | using System.ComponentModel; 7 | 8 | namespace SQLiteTurbo 9 | { 10 | public class EtchedLine : Control 11 | { 12 | #region Constructors 13 | public EtchedLine() 14 | { 15 | // Avoid receiving the focus. 16 | SetStyle(ControlStyles.Selectable, false); 17 | } 18 | #endregion 19 | 20 | #region Public Properties 21 | [Category("Appearance")] 22 | Color DarkColor 23 | { 24 | 25 | get { return _darkColor; } 26 | 27 | set 28 | { 29 | _darkColor = value; 30 | Refresh(); 31 | } 32 | } 33 | 34 | [Category("Appearance")] 35 | Color LightColor 36 | { 37 | get { return _lightColor; } 38 | 39 | set 40 | { 41 | _lightColor = value; 42 | Refresh(); 43 | } 44 | } 45 | #endregion 46 | 47 | #region Overriden Methods 48 | protected override void OnPaint(PaintEventArgs e) 49 | { 50 | base.OnPaint(e); 51 | 52 | Brush lightBrush = new SolidBrush(_lightColor); 53 | Brush darkBrush = new SolidBrush(_darkColor); 54 | Pen lightPen = new Pen(lightBrush, 1); 55 | Pen darkPen = new Pen(darkBrush, 1); 56 | 57 | e.Graphics.DrawLine(darkPen, 0, 0, this.Width, 0); 58 | e.Graphics.DrawLine(lightPen, 0, 1, this.Width, 1); 59 | } 60 | 61 | protected override void OnResize(EventArgs e) 62 | { 63 | base.OnResize(e); 64 | 65 | Refresh(); 66 | } 67 | #endregion 68 | 69 | #region Private Variables 70 | private Color _darkColor = SystemColors.ControlDark; 71 | private Color _lightColor = SystemColors.ControlLightLight; 72 | #endregion 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/AboutDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using Common; 9 | 10 | namespace SQLiteTurbo 11 | { 12 | public partial class AboutDialog : Form 13 | { 14 | public AboutDialog() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | private void btnClose_Click(object sender, EventArgs e) 20 | { 21 | this.Close(); 22 | } 23 | 24 | private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) 25 | { 26 | WebSiteUtils.OpenPage(e.LinkText); 27 | } 28 | 29 | private void pictureBox1_MouseClick(object sender, MouseEventArgs e) 30 | { 31 | WebSiteUtils.OpenProductPage(); 32 | } 33 | 34 | private void AboutDialog_Load(object sender, EventArgs e) 35 | { 36 | lblVersion.Text = Utils.GetSoftwareVersion(); 37 | lblBuild.Text = Utils.GetSoftwareBuild(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/ChangeScriptDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Diagnostics; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | using System.Reflection; 11 | using SQLiteParser; 12 | 13 | namespace SQLiteTurbo 14 | { 15 | public partial class ChangeScriptDialog : Form 16 | { 17 | public ChangeScriptDialog() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | public void Prepare(string sql) 23 | { 24 | txtSQL.Document.Text = sql; 25 | txtSQL.Document.ParseAll(); 26 | } 27 | 28 | private void ChangeScriptDialog_Load(object sender, EventArgs e) 29 | { 30 | txtSQL.Document.SetSyntaxFromEmbeddedResource(Assembly.GetExecutingAssembly(), "SQLiteTurbo.sqlite.syn"); 31 | } 32 | 33 | private void btnClose_Click(object sender, EventArgs e) 34 | { 35 | this.Close(); 36 | } 37 | 38 | private void btnSaveAs_Click(object sender, EventArgs e) 39 | { 40 | SaveFileDialog dlg = new SaveFileDialog(); 41 | dlg.AddExtension = true; 42 | dlg.DefaultExt = "sql"; 43 | dlg.Filter = "SQL files (*.sql)|*.sql|All files|*.*"; 44 | DialogResult res = dlg.ShowDialog(this); 45 | if (res == DialogResult.Cancel) 46 | return; 47 | 48 | string fpath = dlg.FileName; 49 | if (File.Exists(fpath)) 50 | File.Delete(fpath); 51 | File.WriteAllText(fpath, txtSQL.Document.Text); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/FirstTimeDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace SQLiteTurbo 10 | { 11 | public partial class FirstTimeDialog : Form 12 | { 13 | public FirstTimeDialog() 14 | { 15 | InitializeComponent(); 16 | } 17 | 18 | #region Public Properties 19 | public bool IsAutomaticUpdates 20 | { 21 | get { return _automaticUpdates; } 22 | } 23 | #endregion 24 | 25 | #region Event Handlers 26 | private void cbxAutomaticUpdates_CheckedChanged(object sender, EventArgs e) 27 | { 28 | _automaticUpdates = cbxAutomaticUpdates.Checked; 29 | } 30 | 31 | private void btnCheckNow_Click(object sender, EventArgs e) 32 | { 33 | _automaticUpdates = cbxAutomaticUpdates.Checked; 34 | this.DialogResult = DialogResult.OK; 35 | } 36 | 37 | private void btnClose_Click(object sender, EventArgs e) 38 | { 39 | _automaticUpdates = cbxAutomaticUpdates.Checked; 40 | this.DialogResult = DialogResult.Cancel; 41 | } 42 | #endregion 43 | 44 | #region Private Variables 45 | private bool _automaticUpdates = false; 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/HttpPostSenderDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using Common; 10 | 11 | namespace SQLiteTurbo 12 | { 13 | public partial class HttpPostSenderDialog : Form 14 | { 15 | public HttpPostSenderDialog() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public void Prepare(PostSubmitter ps) 21 | { 22 | _postSubmitter = ps; 23 | } 24 | 25 | public Exception Error 26 | { 27 | get { return _error; } 28 | } 29 | 30 | private void btnCancel_Click(object sender, EventArgs e) 31 | { 32 | _postSubmitter.CancelPost(); 33 | } 34 | 35 | private void HttpPostSenderDialog_FormClosing(object sender, FormClosingEventArgs e) 36 | { 37 | if (!_exit) 38 | { 39 | _postSubmitter.CancelPost(); 40 | e.Cancel = true; 41 | } 42 | } 43 | 44 | private void HttpPostSenderDialog_Shown(object sender, EventArgs e) 45 | { 46 | WaitCallback wc = delegate 47 | { 48 | bool cancelled = false; 49 | _error = null; 50 | try 51 | { 52 | _postSubmitter.Post(); 53 | } 54 | catch (UserCancellationException uce) 55 | { 56 | cancelled = true; 57 | } 58 | catch (Exception ex) 59 | { 60 | _error = ex; 61 | } // catch 62 | 63 | try 64 | { 65 | _exit = true; 66 | if (cancelled) 67 | Invoke(new MethodInvoker(delegate { this.DialogResult = DialogResult.Cancel; })); 68 | else 69 | Invoke(new MethodInvoker(delegate { this.DialogResult = DialogResult.OK; })); 70 | } 71 | catch (ObjectDisposedException ode) 72 | { 73 | // Ignore 74 | } // catch 75 | }; 76 | ThreadPool.QueueUserWorkItem(wc); 77 | } 78 | 79 | private PostSubmitter _postSubmitter; 80 | private Exception _error; 81 | private bool _exit; 82 | } 83 | } -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/IndefiniteProgressDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Data; 6 | using System.Drawing; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace SQLiteTurbo 11 | { 12 | public partial class IndefiniteProgressDialog : Form 13 | { 14 | public IndefiniteProgressDialog() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public void Start(IWin32Window parent, string message, WaitCallback handler, MethodInvoker cancelHandler) 20 | { 21 | btnCancel.Enabled = cancelHandler != null; 22 | _handler = handler; 23 | _cancelHandler = cancelHandler; 24 | lblMessage.Text = message; 25 | ShowDialog(parent); 26 | } 27 | 28 | private void IndefiniteProgressDialog_Shown(object sender, EventArgs e) 29 | { 30 | WaitCallback wc = delegate 31 | { 32 | try 33 | { 34 | _handler(null); 35 | Invoke(new MethodInvoker(delegate { this.Close(); })); 36 | } 37 | catch (Exception ex) 38 | { 39 | _error = ex; 40 | Invoke(new MethodInvoker(delegate 41 | { 42 | this.Close(); 43 | System.Windows.Forms.Timer tm = new System.Windows.Forms.Timer(); 44 | tm.Interval = 500; 45 | tm.Tick += new EventHandler(tm_Tick); 46 | tm.Start(); 47 | })); 48 | } // catch 49 | }; 50 | ThreadPool.QueueUserWorkItem(wc); 51 | } 52 | 53 | void tm_Tick(object sender, EventArgs e) 54 | { 55 | System.Windows.Forms.Timer tm = (System.Windows.Forms.Timer)sender; 56 | tm.Stop(); 57 | tm.Dispose(); 58 | MessageBox.Show(_error.Message, "Operation Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); 59 | } 60 | 61 | private void btnCancel_Click(object sender, EventArgs e) 62 | { 63 | if (_cancelHandler != null) 64 | _cancelHandler(); 65 | this.DialogResult = DialogResult.Cancel; 66 | } 67 | 68 | private WaitCallback _handler; 69 | private MethodInvoker _cancelHandler; 70 | private Exception _error; 71 | } 72 | } -------------------------------------------------------------------------------- /SQLiteTurbo/Forms/SoftwareUpdatesDetailsDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | using AutomaticUpdates; 9 | 10 | namespace SQLiteTurbo 11 | { 12 | public partial class SoftwareUpdatesDetailsDialog : Form 13 | { 14 | public SoftwareUpdatesDetailsDialog() 15 | { 16 | InitializeComponent(); 17 | } 18 | 19 | public void Prepare(List vlist) 20 | { 21 | StringBuilder sb = new StringBuilder(); 22 | foreach (VersionUpdateInfo v in vlist) 23 | { 24 | sb.Append("\r\n\r\n[" + v.Version + "] release date: "+v.ReleaseDate.ToLongDateString()); 25 | if (v.FixedBugs.Count > 0) 26 | { 27 | sb.Append("\r\n\r\nThe following bugs were fixed:"); 28 | foreach (BugFixInfo bug in v.FixedBugs) 29 | { 30 | sb.Append("\r\n(" + bug.Severity.ToString() + " bug) -> " + bug.Description); 31 | } // foreach 32 | } 33 | if (v.AddedFeatures.Count > 0) 34 | { 35 | sb.Append("\r\n\r\nThe following features were added:"); 36 | foreach (FeatureInfo feature in v.AddedFeatures) 37 | { 38 | sb.Append("\r\n(" + feature.Impact.ToString() + " impact) -> " + feature.Description); 39 | } // foreach 40 | } 41 | } // foreach 42 | txtUpdates.Text = sb.ToString(); 43 | txtUpdates.SelectionStart = 0; 44 | txtUpdates.SelectionLength = 0; 45 | } 46 | 47 | private void btnClose_Click(object sender, EventArgs e) 48 | { 49 | this.DialogResult = DialogResult.Cancel; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /SQLiteTurbo/IWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// Used to provide unified interface for invoking long running processes. 9 | /// 10 | public interface IWorker 11 | { 12 | /// 13 | /// Fired whenever the operation has progressed 14 | /// 15 | event EventHandler ProgressChanged; 16 | 17 | /// 18 | /// Begin the operation 19 | /// 20 | void BeginWork(); 21 | 22 | /// 23 | /// Cancel the operation 24 | /// 25 | void Cancel(); 26 | 27 | /// 28 | /// Get the operation's result (valid only after the work has finished successfully). 29 | /// 30 | object Result 31 | { 32 | get; 33 | } 34 | 35 | /// 36 | /// In case the worker supports dual progress notifications (primary/secondary) 37 | /// this property will return TRUE. 38 | /// 39 | bool SupportsDualProgress 40 | { 41 | get; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SQLiteTurbo/LocalUserFileAppender.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using System.Windows.Forms; 6 | using log4net; 7 | using log4net.Appender; 8 | using log4net.Core; 9 | using log4net.Layout; 10 | 11 | namespace SQLiteTurbo 12 | { 13 | public class LocalUserFileAppender : AppenderSkeleton 14 | { 15 | public LocalUserFileAppender() 16 | { 17 | // Compute the path to the local application data folder where the sqlite log file will be 18 | // placed. 19 | _logpath = Configuration.LogFilePath; 20 | if (File.Exists(_logpath)) 21 | File.Delete(_logpath); 22 | _logwriter = new StreamWriter(File.Open(_logpath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)); 23 | } 24 | 25 | [System.Obsolete("Instead use the default constructor and set the Layout property")] 26 | public LocalUserFileAppender(ILayout layout) 27 | : this() 28 | { 29 | Layout = layout; 30 | } 31 | 32 | protected override void Append(log4net.Core.LoggingEvent loggingEvent) 33 | { 34 | if (_logwriter.BaseStream.Length > 500 * 1024) 35 | { 36 | _logwriter.Close(); 37 | File.Delete(_logpath); 38 | _logwriter = new StreamWriter(File.Open(_logpath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)); 39 | } 40 | 41 | _logwriter.WriteLine("{0}|{1}|{2}|{3}|{4}", 42 | loggingEvent.Level.DisplayName, 43 | loggingEvent.ThreadName, 44 | loggingEvent.TimeStamp.ToShortDateString() + " " + loggingEvent.TimeStamp.ToShortTimeString() + "," + loggingEvent.TimeStamp.Millisecond, 45 | loggingEvent.LocationInformation.ClassName + "." + loggingEvent.LocationInformation.MethodName + "(" + loggingEvent.LocationInformation.LineNumber + ")", 46 | (loggingEvent.ExceptionObject != null ? (loggingEvent.ExceptionObject.Message + "\r\n" + loggingEvent.ExceptionObject.StackTrace) : 47 | (loggingEvent.MessageObject != null ? loggingEvent.MessageObject.ToString() : "null"))); 48 | _logwriter.Flush(); 49 | } 50 | 51 | protected override void OnClose() 52 | { 53 | base.OnClose(); 54 | _logwriter.Flush(); 55 | _logwriter.Close(); 56 | } 57 | 58 | protected override bool RequiresLayout 59 | { 60 | get { return false; } 61 | } 62 | 63 | private string _logpath; 64 | private StreamWriter _logwriter; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /SQLiteTurbo/ProgressEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// Conveys progress informatio 9 | /// 10 | public class ProgressEventArgs : EventArgs 11 | { 12 | #region Constructors 13 | public ProgressEventArgs(bool done, int progress, string msg, Exception error) 14 | { 15 | _done = done; 16 | _progress = progress; 17 | _msg = msg; 18 | _error = error; 19 | } 20 | #endregion 21 | 22 | #region Public Properties 23 | public bool IsDone 24 | { 25 | get { return _done; } 26 | set { _done = value; } 27 | } 28 | 29 | public int Progress 30 | { 31 | get { return _progress; } 32 | set { _progress = value; } 33 | } 34 | 35 | public string Message 36 | { 37 | get { return _msg; } 38 | set { _msg = value; } 39 | } 40 | 41 | public Exception Error 42 | { 43 | get { return _error; } 44 | set { _error = value; } 45 | } 46 | 47 | public ProgressEventArgs NestedProgress 48 | { 49 | get { return _nested; } 50 | set { _nested = value; } 51 | } 52 | #endregion 53 | 54 | #region Private Variables 55 | private bool _done; 56 | private int _progress; 57 | private string _msg; 58 | private Exception _error; 59 | private ProgressEventArgs _nested; 60 | #endregion 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /SQLiteTurbo/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SQLiteTurbo.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SQLiteTurbo/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/app.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/app.ico -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/appicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/appicon.ico -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback2.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_non_selected_idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_non_selected_idea.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_non_selected_question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_non_selected_question.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_pressed.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_problem_non_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_problem_non_selected.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_problem_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_problem_selected.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_selected_idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_selected_idea.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/feedback_selected_question.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/feedback_selected_question.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/normal_feedback_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/normal_feedback_button.png -------------------------------------------------------------------------------- /SQLiteTurbo/Resources/pressed_feedback_button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SQLiteTurbo/Resources/pressed_feedback_button.png -------------------------------------------------------------------------------- /SQLiteTurbo/RowsCopier.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// This class is responsible to copy rows from one table to another 9 | /// 10 | public class RowsCopier : AbstractWorker 11 | { 12 | #region Constructor 13 | public RowsCopier(TableChanges tchanges, string diff, List rows, bool leftToRight) 14 | : base("RowsCopier") 15 | { 16 | _diff = diff; 17 | _changes = tchanges; 18 | _rows = rows; 19 | _leftToRight = leftToRight; 20 | } 21 | #endregion 22 | 23 | #region Protected Overrided Methods 24 | protected override void DoWork() 25 | { 26 | // Ask the table changes object to do the copy 27 | _changes.CopyRows(_diff, _rows, _leftToRight, RowsCopyingHandler); 28 | } 29 | 30 | protected override bool IsDualProgress 31 | { 32 | get 33 | { 34 | return true; 35 | } 36 | } 37 | #endregion 38 | 39 | #region Private Methods 40 | private void RowsCopyingHandler(int rowsCopied, int totalRows, string blobName, int blobBytesCopied, int totalBlobBytes, ref bool cancel) 41 | { 42 | cancel = WasCancelled; 43 | 44 | if (blobName == null) 45 | { 46 | if (totalRows > 0) 47 | { 48 | int progress = (int)(100.0 * rowsCopied / totalRows); 49 | if (progress > _progress) 50 | { 51 | NotifyPrimaryProgress(false, progress, rowsCopied.ToString() + "/" + totalRows.ToString() + " copied", null); 52 | _progress = progress; 53 | } 54 | } 55 | } 56 | else 57 | { 58 | if (totalBlobBytes > 0) 59 | { 60 | int progress = (int)(100.0 * blobBytesCopied / totalBlobBytes); 61 | bool done = blobBytesCopied == totalBlobBytes; 62 | NotifySecondaryProgress(done, progress, Utils.FormatMemSize(blobBytesCopied, MemFormat.KB) + "/" + 63 | Utils.FormatMemSize(totalBlobBytes, MemFormat.KB) + " (" + blobName + ")", null); 64 | } 65 | } // else 66 | } 67 | #endregion 68 | 69 | #region Private Variables 70 | private string _diff; 71 | private int _progress; 72 | private TableChanges _changes; 73 | private List _rows; 74 | private bool _leftToRight; 75 | #endregion 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SQLiteTurbo/RowsDeleter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// This class is responsible to delete rows from the specified table 9 | /// 10 | public class RowsDeleter : AbstractWorker 11 | { 12 | #region Constructor 13 | public RowsDeleter(TableChanges tchanges, string diff, List rows, bool left) 14 | : base("RowsDeleter") 15 | { 16 | _diff = diff; 17 | _changes = tchanges; 18 | _rows = rows; 19 | _left = left; 20 | } 21 | #endregion 22 | 23 | #region Protected Overrided Methods 24 | protected override void DoWork() 25 | { 26 | // Ask the table changes object to do the deletion 27 | _changes.DeleteRows(_diff, _rows, _left, RowsDeletionHandler); 28 | } 29 | 30 | protected override bool IsDualProgress 31 | { 32 | get 33 | { 34 | return false; 35 | } 36 | } 37 | #endregion 38 | 39 | #region Private Methods 40 | private void RowsDeletionHandler(int rowsDeleted, int totalRows, ref bool cancel) 41 | { 42 | cancel = WasCancelled; 43 | if (totalRows > 0) 44 | { 45 | int progress = (int)(100.0 * rowsDeleted / totalRows); 46 | if (progress > _progress) 47 | { 48 | NotifyPrimaryProgress(false, progress, rowsDeleted.ToString() + "/" + totalRows.ToString() + " deleted", null); 49 | _progress = progress; 50 | } 51 | } 52 | } 53 | #endregion 54 | 55 | #region Private Variables 56 | private string _diff; 57 | private int _progress; 58 | private TableChanges _changes; 59 | private List _rows; 60 | private bool _left; 61 | #endregion 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SQLiteTurbo/ScrollableDataGridView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Windows.Forms; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace SQLiteTurbo 8 | { 9 | /// 10 | /// Provides the ability to synchronize the location of the horizontal scrollbar 11 | /// between two data grids. 12 | /// 13 | public class ScrollableDataGridView : DataGridView 14 | { 15 | #region Public Methods 16 | 17 | /// 18 | /// Returns the maximum horizontal scroll position 19 | /// 20 | /// 21 | public int GetMaxScrollPosition() 22 | { 23 | HScrollBar sbr = GetHScrollBar(); 24 | return sbr.Maximum; 25 | } 26 | 27 | /// 28 | /// Set the position of the horizontal scrollbar 29 | /// 30 | /// The position to set 31 | public void SetScrollPosition(int pos) 32 | { 33 | HScrollBar sbr = (HScrollBar)HorizontalScrollBar; 34 | if (pos > sbr.Maximum) 35 | pos = sbr.Maximum; 36 | sbr.Value = pos; 37 | SendMessage(this.Handle, 276, (IntPtr)(4 + 0x10000 * pos), sbr.Handle); 38 | } 39 | 40 | /// 41 | /// Get the position of the horizontal scrollbar 42 | /// 43 | /// 44 | public int GetScrollPosition() 45 | { 46 | HScrollBar sb = GetHScrollBar(); 47 | return sb.Value; 48 | } 49 | #endregion 50 | 51 | #region Private Methods 52 | [DllImport("user32.dll")] 53 | static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); 54 | 55 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] 56 | static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam); 57 | 58 | private HScrollBar GetHScrollBar() 59 | { 60 | if (_hscrollbar != null) 61 | return _hscrollbar; 62 | foreach (Control ctrl in this.Controls) 63 | { 64 | if (ctrl is HScrollBar) 65 | { 66 | _hscrollbar = ctrl as HScrollBar; 67 | return _hscrollbar; 68 | } 69 | } // foreach 70 | 71 | return null; 72 | } 73 | #endregion 74 | 75 | private HScrollBar _hscrollbar; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /SQLiteTurbo/ScrollableTreeView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Forms; 4 | using System.Runtime.InteropServices; 5 | using System.Text; 6 | 7 | namespace SQLiteTurbo 8 | { 9 | public class ScrollableTreeView : TreeView 10 | { 11 | #region Events 12 | public event EventHandler GotMessage; 13 | #endregion 14 | 15 | #region Public Methods 16 | public void SetScrollPosition(int pos) 17 | { 18 | if (!this.IsHandleCreated) 19 | this.CreateControl(); 20 | 21 | Message m = new Message(); 22 | m.HWnd = this.Handle; 23 | m.LParam = IntPtr.Zero; 24 | m.Msg = 277; 25 | m.WParam = new IntPtr(0x00000005 | (pos << 16)); 26 | 27 | base.WndProc(ref m); 28 | } 29 | 30 | public int GetScrollPosition() 31 | { 32 | return GetScrollPos(this.Handle.ToInt32(), SB_VERT); 33 | } 34 | #endregion 35 | 36 | #region Protected Methods 37 | protected override void WndProc(ref Message m) 38 | { 39 | base.WndProc(ref m); 40 | 41 | if (m.Msg == 277 || m.Msg == 0x100 || m.Msg == WM_MOUSEWHEEL) 42 | { 43 | if (GotMessage != null) 44 | GotMessage(this, EventArgs.Empty); 45 | } 46 | } 47 | #endregion 48 | 49 | #region Private Constants 50 | private const int SB_HORZ = 0x0; 51 | private const int SB_VERT = 0x1; 52 | private const int WM_MOUSEWHEEL = 0x020A; 53 | #endregion 54 | 55 | #region Private Methods 56 | [DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)] 57 | public static extern int GetScrollPos(int hWnd, int nBar); 58 | 59 | [DllImport("user32.dll")] 60 | static extern int SetScrollPos(IntPtr hWnd, int nBar, int nPos, bool bRedraw); 61 | #endregion 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /SQLiteTurbo/SearchDataWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SQLiteTurbo 6 | { 7 | /// 8 | /// This class is responsible to search for a data row starting from the specified 9 | /// row index that matches the specified criteria 10 | /// 11 | public class SearchDataWorker : AbstractWorker 12 | { 13 | #region Constructors 14 | public SearchDataWorker(bool isLeft, string diff, TableChanges tchanges, long rowIndex, long maxRowIndex, string sql) 15 | : base("SearchDataWorker") 16 | { 17 | _maxRowIndex = maxRowIndex; 18 | _isLeft = isLeft; 19 | _changes = tchanges; 20 | _rowIndex = rowIndex; 21 | _sql = sql; 22 | _diff = diff; 23 | } 24 | #endregion 25 | 26 | #region Public Properties 27 | #endregion 28 | 29 | #region Protected Methods 30 | protected override void DoWork() 31 | { 32 | if (_sql != null) 33 | WorkResult = _changes.SearchRowsBySQL(_isLeft, _diff, _rowIndex, _maxRowIndex, _sql, SearchHandler); 34 | } 35 | 36 | protected override bool IsDualProgress 37 | { 38 | get { return false; } 39 | } 40 | #endregion 41 | 42 | #region Private Methods 43 | private void SearchHandler(long searchedRows, long total, ref bool cancel) 44 | { 45 | cancel = WasCancelled; 46 | if (total == 0) 47 | return; 48 | int next = (int)(100.0 * searchedRows / total); 49 | if (next > _progress) 50 | { 51 | _progress = next; 52 | NotifyPrimaryProgress(false, _progress, searchedRows.ToString() + "/" + total.ToString() + " rows searched", null); 53 | } 54 | } 55 | #endregion 56 | 57 | #region Private Variables 58 | private bool _isLeft; 59 | private string _diff; 60 | private TableChanges _changes; 61 | private long _rowIndex; 62 | private long _maxRowIndex = -1; 63 | private string _sql; 64 | private int _progress; 65 | #endregion 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /SQLiteTurbo/SendEmailWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace SQLiteTurbo 7 | { 8 | public class SendEmailWorker : AbstractWorker 9 | { 10 | public SendEmailWorker(bool isBug, string subject, string body, List attachments, string retEmail, bool useDefaultEmailClient) 11 | : base("SendEmailWorker") 12 | { 13 | _isbug = isBug; 14 | _subject = subject; 15 | _body = body; 16 | _attachments = attachments; 17 | _retemail = retEmail; 18 | _timeout = MailSender.ComputeTimeout(attachments); 19 | _useDefaultEmailClient = useDefaultEmailClient; 20 | } 21 | 22 | 23 | #region Protected Overrided Methods 24 | protected override void DoWork() 25 | { 26 | System.Timers.Timer tm = new System.Timers.Timer(1000); 27 | tm.Elapsed += new System.Timers.ElapsedEventHandler(tm_Elapsed); 28 | tm.AutoReset = true; 29 | tm.Start(); 30 | 31 | try 32 | { 33 | if (_useDefaultEmailClient) 34 | MailSender.SendMail(_isbug, _subject, _body, _attachments, _retemail); 35 | else 36 | MailSender.SendMailViaGmail(_isbug, _subject, _body, _attachments, _retemail, _timeout * 1000); 37 | } 38 | catch (Exception ex) 39 | { 40 | // General error 41 | throw; 42 | } 43 | finally 44 | { 45 | tm.Stop(); 46 | tm.Dispose(); 47 | } 48 | } 49 | 50 | 51 | 52 | private void tm_Elapsed(object sender, System.Timers.ElapsedEventArgs e) 53 | { 54 | // Cause the internal thread to exit if possible 55 | if (WasCancelled && _first) 56 | { 57 | _first = false; 58 | MailSender.CancelSendingViaGmail(); 59 | return; 60 | } 61 | 62 | _elapsed++; 63 | int progress = 0; 64 | if (_timeout > 0) 65 | progress = (int)(100.0*_elapsed / _timeout); 66 | if (progress > 100) 67 | return; 68 | NotifyPrimaryProgress(false, progress, 69 | string.Format("Sending email to server (estimated {0} seconds left)", _timeout-_elapsed), null); 70 | } 71 | 72 | protected override bool IsDualProgress 73 | { 74 | get 75 | { 76 | return false; 77 | } 78 | } 79 | #endregion 80 | 81 | #region Private Variables 82 | private bool _isbug; 83 | private string _subject; 84 | private string _body; 85 | private List _attachments; 86 | private string _retemail; 87 | private int _timeout; 88 | private int _elapsed = 0; 89 | private bool _first = true; 90 | private bool _useDefaultEmailClient; 91 | #endregion 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /SQLiteTurbo/SpinningProgress.Designer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Diagnostics; 7 | using System.Windows.Forms; 8 | namespace CircularProgress.SpinningProgress 9 | { 10 | // TRANSMISSINGCOMMENT: Class SpinningProgress 11 | partial class SpinningProgress : System.Windows.Forms.UserControl 12 | { 13 | 14 | // UserControl1 overrides dispose to clean up the component list. 15 | [ System.Diagnostics.DebuggerNonUserCode() ] 16 | protected override void Dispose( bool disposing ) 17 | { 18 | if ( disposing && components != null ) 19 | { 20 | components.Dispose(); 21 | } 22 | base.Dispose( disposing ); 23 | } 24 | 25 | 26 | // Required by the Windows Form Designer 27 | private System.ComponentModel.IContainer components; 28 | 29 | // NOTE: The following procedure is required by the Windows Form Designer 30 | // It can be modified using the Windows Form Designer. 31 | // Do not modify it using the code editor. 32 | [ System.Diagnostics.DebuggerStepThrough() ] 33 | private void InitializeComponent() 34 | { 35 | this.SuspendLayout(); 36 | // 37 | // SpinningProgress 38 | // 39 | this.AutoScaleDimensions = new System.Drawing.SizeF( 6.0F, 13.0F ); 40 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 41 | this.Name = "SpinningProgress"; 42 | this.Size = new System.Drawing.Size( 30, 30 ); 43 | this.ResumeLayout( false ); 44 | 45 | } 46 | 47 | 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /SQLiteTurbo/SyncWorker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace SQLiteTurbo 7 | { 8 | /// 9 | /// The purpose of this class is to take an asynchronous worker object and 10 | /// turn it into a synchronouns one. This is useful in contexts where the 11 | /// worker is integrated into a larger operation. 12 | /// 13 | public class SyncWorker : IWorker 14 | { 15 | #region Constructors 16 | public SyncWorker(IWorker worker) 17 | { 18 | _worker = worker; 19 | _worker.ProgressChanged += new EventHandler(_worker_ProgressChanged); 20 | } 21 | #endregion 22 | 23 | #region IWorker Members 24 | 25 | public event EventHandler ProgressChanged; 26 | 27 | public void BeginWork() 28 | { 29 | _worker.BeginWork(); 30 | _event.WaitOne(); 31 | _event.Close(); 32 | if (_error != null) 33 | throw _error; 34 | } 35 | 36 | public void Cancel() 37 | { 38 | _worker.Cancel(); 39 | } 40 | 41 | public object Result 42 | { 43 | get { return _worker.Result; } 44 | } 45 | 46 | public bool SupportsDualProgress 47 | { 48 | get { return _worker.SupportsDualProgress; } 49 | } 50 | 51 | #endregion 52 | 53 | #region Event Handlers 54 | private void _worker_ProgressChanged(object sender, ProgressEventArgs e) 55 | { 56 | // Delegate to my listeners 57 | if (this.ProgressChanged != null) 58 | this.ProgressChanged(this, e); 59 | 60 | if (e.IsDone || e.Error != null) 61 | { 62 | if (e.Error != null) 63 | _error = e.Error; 64 | _worker.ProgressChanged -= new EventHandler(_worker_ProgressChanged); 65 | _event.Set(); 66 | } 67 | } 68 | #endregion 69 | 70 | #region Private Variables 71 | private IWorker _worker; 72 | private Exception _error; 73 | private AutoResetEvent _event = new AutoResetEvent(false); 74 | #endregion 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /SQLiteTurbo/UserSurveyDialog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Text; 7 | using System.Windows.Forms; 8 | 9 | namespace SQLiteTurbo 10 | { 11 | public partial class UserSurveyDialog : Form 12 | { 13 | #region Constructors 14 | public UserSurveyDialog() 15 | { 16 | InitializeComponent(); 17 | } 18 | #endregion 19 | 20 | #region Event Handlers 21 | private void btnSend_Click(object sender, EventArgs e) 22 | { 23 | string description = "Problems:\r\n" + txtProblems.Text + 24 | "\r\n\r\nMissing Features:\r\n" + txtMissingFeatures.Text + 25 | "\r\n\r\nImprovements:\r\n\r\n" + txtImprovements.Text; 26 | 27 | PostSubmitter ps = new PostSubmitter(); 28 | ps.Url = "http://www.sqlitecompare.com/support_submit.php"; 29 | ps.PostItems.Add("subject", "Survey Results"); 30 | ps.PostItems.Add("description", description); 31 | ps.PostItems.Add("email", txtEmail.Text.Trim()); 32 | ps.PostItems.Add("os_version", Environment.OSVersion.ToString()); 33 | ps.PostItems.Add("sw_version", Utils.GetSoftwareVersion() + " build " + Utils.GetSoftwareBuild()); 34 | ps.PostItems.Add("name", txtName.Text.Trim()); 35 | ps.Type = PostSubmitter.PostTypeEnum.Post; 36 | 37 | HttpPostSenderDialog dlg = new HttpPostSenderDialog(); 38 | dlg.Prepare(ps); 39 | DialogResult rs = dlg.ShowDialog(this); 40 | if (rs == DialogResult.Cancel) 41 | return; 42 | 43 | if (dlg.Error != null) 44 | { 45 | // Some kind of transmission error has occured - notify the user 46 | DialogResult res = MessageBox.Show(this, 47 | "Failed to transfer the data to our servers. Do you want to navigate to our web support page?", 48 | "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); 49 | if (res == DialogResult.Yes) 50 | WebSiteUtils.OpenBugFeaturePage(); 51 | } 52 | else 53 | { 54 | MessageBox.Show(this, 55 | "Your survey was queued for review. Thanks!", 56 | "Information", 57 | MessageBoxButtons.OK, MessageBoxIcon.Information); 58 | this.Close(); 59 | } // else 60 | } 61 | 62 | private void btnClose_Click(object sender, EventArgs e) 63 | { 64 | this.Close(); 65 | } 66 | #endregion 67 | } 68 | } -------------------------------------------------------------------------------- /SQLiteTurbo/WebSiteUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Diagnostics; 5 | 6 | namespace SQLiteTurbo 7 | { 8 | public class WebSiteUtils 9 | { 10 | public static void OpenBuyPage() 11 | { 12 | OpenPage("http://sqlitecompare.com/Buy.html"); 13 | } 14 | 15 | public static void OpenBugFeaturePage() 16 | { 17 | OpenPage("https://github.com/shuebener/SQLiteCompare/issues"); 18 | } 19 | 20 | public static void OpenUserGuidePage() 21 | { 22 | OpenPage("http://sqlitecompare.com/GettingStarted.html"); 23 | } 24 | 25 | public static void OpenProductPage() 26 | { 27 | OpenPage("http://sqlitecompare.com"); 28 | } 29 | 30 | public static void OpenPage(string url) 31 | { 32 | Process p = new Process(); 33 | ProcessStartInfo psi = new ProcessStartInfo(url); 34 | p.StartInfo = psi; 35 | psi.UseShellExecute = true; 36 | p.Start(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SQLiteTurbo/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /SVG/text2451.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/SVG/text2451.png -------------------------------------------------------------------------------- /Setup/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/Setup/Thumbs.db -------------------------------------------------------------------------------- /Setup/appicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/Setup/appicon.ico -------------------------------------------------------------------------------- /Setup/finish_banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/Setup/finish_banner.bmp -------------------------------------------------------------------------------- /Setup/installer_banner.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/Setup/installer_banner.bmp -------------------------------------------------------------------------------- /Setup/uninstallicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/Setup/uninstallicon.ico -------------------------------------------------------------------------------- /ShiftReduceParser.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/ShiftReduceParser.dll -------------------------------------------------------------------------------- /SolutionInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyProduct("SQLite Compare")] 9 | [assembly: AssemblyTitle("SQLite Compare")] 10 | [assembly: AssemblyDescription("Utility for comparing two SQLite database files for both structure and data.")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("SCHMID Group | Gebr. SCHMID GmbH")] 13 | [assembly: AssemblyCopyright("Copyright © 2016 - SCHMID Group | Gebr. SCHMID GmbH")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("BD655607-78A1-471B-A296-BB55E33D878C")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | [assembly: AssemblyVersion("3.0.0.0")] 33 | [assembly: AssemblyFileVersion("3.0.0.0")] 34 | -------------------------------------------------------------------------------- /UndoRedo/ActionRecord.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.Xml.Serialization; 5 | 6 | namespace UndoRedo 7 | { 8 | /// 9 | /// Encapsulates the details a single action that was performed by the user. 10 | /// 11 | [Serializable] 12 | public class ActionRecord 13 | { 14 | #region Constructors 15 | public ActionRecord() 16 | { 17 | } 18 | 19 | public ActionRecord(DateTime time, string name, string description, ActionType type) 20 | { 21 | _actionTime = time; 22 | _actionName = name; 23 | _actionDescription = description; 24 | _actionType = type; 25 | } 26 | #endregion 27 | 28 | #region Public Properties 29 | public DateTime ActionTime 30 | { 31 | get { return _actionTime; } 32 | } 33 | 34 | public string ActionName 35 | { 36 | get { return _actionName; } 37 | } 38 | 39 | public string ActionDescription 40 | { 41 | get { return _actionDescription; } 42 | } 43 | 44 | public ActionType ActionType 45 | { 46 | get { return _actionType; } 47 | } 48 | #endregion 49 | 50 | #region Private Variables 51 | private DateTime _actionTime; 52 | private string _actionName; 53 | private string _actionDescription; 54 | private ActionType _actionType = ActionType.None; 55 | #endregion 56 | } 57 | 58 | /// 59 | /// The type of the action that was performed by the user 60 | /// 61 | public enum ActionType 62 | { 63 | /// 64 | /// Illegal value 65 | /// 66 | None = 0, 67 | 68 | /// 69 | /// Normal action 70 | /// 71 | Do = 1, 72 | 73 | /// 74 | /// Undo action 75 | /// 76 | Undo = 2, 77 | 78 | /// 79 | /// Redo action 80 | /// 81 | Redo = 3, 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /UndoRedo/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("UndoRedo")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("UndoRedo")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1ab0dbfc-3e6a-494e-91ea-ae56cd604e31")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Revision and Build Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /UndoRedo/UndoableAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace UndoRedo 6 | { 7 | /// 8 | /// This class serves as the basis for all undoable actions in the software. 9 | /// 10 | public abstract class UndoableAction 11 | { 12 | /// 13 | /// Get the name of the action 14 | /// 15 | public abstract string Name 16 | { 17 | get; 18 | } 19 | 20 | /// 21 | /// Get the description of the undoable action 22 | /// 23 | public abstract string Description 24 | { 25 | get; 26 | } 27 | 28 | /// 29 | /// Performs the action 30 | /// 31 | /// TRUE indicates that the action is redone 32 | public abstract void Do(bool redo); 33 | 34 | /// 35 | /// Undo the action 36 | /// 37 | public abstract void Undo(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /gplex.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/gplex.exe -------------------------------------------------------------------------------- /gppg.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shuebener/SQLiteCompare/456afb7b789fe7e6554c30966407abc91c9fda0f/gppg.exe -------------------------------------------------------------------------------- /license.lic: -------------------------------------------------------------------------------- 1 | OFDS1lyVrJJOdGlXpcDUrAZXMA4lCgiLaeY0HrfZCFv8rMaofHjqJmyGaTe4kEoZz1k4BHEUVhG7BMB2wBVLkj1uS8heE6cNEMl1Rw0GKrUlVB5XvWtEgtqk7KSK0Z50tcU3zSW05IveQsv7QZoW/iUvcWgpncB3+Hy0ki8+/LAzez4L0O4cnYaRC+xQvgjhAHMsNQZ5UlZHOU5/Igxo1yAUHJ6SG5mXY44/IV2wkLlJy+V3ml5/a4WHWdIXEKXebozsYozBS0MrUaUD23wG9nhCCNQukTraPzIqkVPYAYYu9tetsFRco+d7/YkCOJ1eSoLPtXTWmR/ctI5SxwBz1w==D+E@+L#+I$+M%62eB65q7ANhlw4cZ9Q8ibQfzsJK410Jh9fwRMKynwomEzNNpI+0/XU5ZiecVtylLn0Cjm4NPYJdxHFzbk9bKVJxn1OvXu1jYLcOHGZ8PYW1J8w== -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | SQLite Compare is a database comparison and merge utility for Windows 7/8/10 2 | 3 | 4 | SQLite Compare V3.0 5 | --------------------- 6 | 7 | - Fork of SQLite-Compare-Utility (http://www.codeproject.com/Articles/220018/SQLite-Compare-Utility). 8 | - Using .NET 4.6. 9 | - Using NuGet library packages. 10 | 11 | 12 | 13 | 14 | SQLite Compare V2.5 15 | --------------------- 16 | 17 | Features: 18 | 19 | - Blazing fast in-memory schema comparisons. 20 | 21 | - Optimized data comparison engine capable of 22 | comparing even huge tables with millions of rows. 23 | 24 | - WinMerge-like schema difference view and operations. 25 | 26 | - SQL change script generation - useful for supporting 27 | database upgrades in existing installations (available 28 | only with a commercial license). 29 | 30 | - Intuitive data difference view for comparing individual field values. 31 | 32 | - Open Source and Free !! 33 | 34 | 35 | Known limitations: 36 | 37 | 1. SQLite Compare supports only the newer SQLite 3 file format. SQLite version 2 files are incompatible with the newer file format and are therefore not supported. If you really want to compare older SQLite file then you can convert them to the newer file format by following method outlined in http://www.sqlite.org/formatchng.html 38 | 39 | 2. Currently it is not impossible to rename a column in the schema diff view. This is a limitation caused by the inability to determine if a new column was added or an existing column was renamed. The workaround is to do such renames in another SQL management tool and than run the comparison if necessary. 40 | 41 | 3. BLOB field comparisons tend to take more time to execute, especially when 42 | big BLOBs are involved. When BLOB fields are not part of a table primary key - 43 | they are compared using a fast algorithm that does not load the entire BLOB into memory before doing the comparison. However - when BLOB fields are part of a table primary key (should be rare but possible), there is no way to avoid loading them into main memory before doing comparisons (SQLite limitation). 44 | 45 | 4. Currently it is not possible to compare tables that have mismatching primary keys. For example - it is not possible to compare two tables where table A has a primary key composed from two integers while table B has a primary key composed of a single integer. 46 | 47 | 48 | Enjoy :-) 49 | Liron Levi 50 | --------------------------------------------------------------------------------