예제 #1
0
        public void Setup()
        {
            LookupItem = new TableItem
            {
                DisplayName  = "Name",
                DatabasePath = "Database1"
            };

            LookupItemParent = new IndexFolderItem
            {
                DisplayName  = "Name",
                DatabasePath = "Database1",
                Items        = new ObservableCollection <TreeItem> {
                    LookupItem
                }
            };

            LookupItemDatabase = new DatabaseItem
            {
                DisplayName  = "Name",
                DatabasePath = "Database1",
                Items        = new ObservableCollection <TreeItem> {
                    LookupItemParent
                }
            };

            ComparisonItem = new TableItem
            {
                DisplayName  = "Name",
                DatabasePath = "Database2"
            };

            ComparisonItemParent = new IndexFolderItem
            {
                DisplayName  = "Name",
                DatabasePath = "Database2",
                Items        = new ObservableCollection <TreeItem> {
                    ComparisonItem
                }
            };

            treeSaveHelperMock = new Mock <ITreeSaveHelper>();

            viewModel = new MainWindowViewModel(treeSaveHelperMock.Object)
            {
                TreeViewItems = new ObservableCollection <TreeItem>
                {
                    LookupItemDatabase,
                    new DatabaseItem
                    {
                        DisplayName  = "Name",
                        DatabasePath = "Database2",
                        Items        = new ObservableCollection <TreeItem>
                        {
                            ComparisonItemParent
                        }
                    }
                }
            };
        }
예제 #2
0
        /// <summary>
        /// Maps the provided database to a hierarchical ViewModel structure with a DatabaseItem as its root.
        /// </summary>
        /// <param name="databasePath">The database path.</param>
        /// <returns></returns>
        public DatabaseItem MapSchemaToViewModel(string databasePath)
        {
            logger.Info("Trying to load database file at " + databasePath);
            this.databasePath = databasePath;
            dbHandler         = new DatabaseHandler(databasePath);

            TableFolderItem   tableFolder   = MapTables();
            ViewFolderItem    viewFolder    = MapViews();
            IndexFolderItem   indexFolder   = MapIndexes();
            TriggerFolderItem triggerFolder = MapTriggers();

            var databaseItem = new DatabaseItem()
            {
                DisplayName  = Path.GetFileNameWithoutExtension(databasePath),
                DatabasePath = databasePath
            };

            databaseItem.Items.Add(tableFolder);
            databaseItem.Items.Add(viewFolder);
            databaseItem.Items.Add(indexFolder);
            databaseItem.Items.Add(triggerFolder);

            logger.Info("Loaded database " + databaseItem.DisplayName + ".");
            return(databaseItem);
        }
예제 #3
0
        private IndexFolderItem MapIndexes()
        {
            var indexes     = dbHandler.GetIndexes();
            var indexFolder = new IndexFolderItem {
                DisplayName = LocalisationHelper.GetString("TreeItem_Indexes")
            };

            foreach (var index in indexes)
            {
                indexFolder.Items.Add(new IndexItem
                {
                    DisplayName  = index.Name,
                    DatabasePath = databasePath
                });
            }
            indexFolder.Items = new ObservableCollection <TreeItem>(indexFolder.Items.OrderBy(x => x.DisplayName));

            return(indexFolder);
        }