static void Main(string[] args) {
     var d1 = new DirTree(@"C:\",
         new DirTree(@"C:\Dir1",
             new DirTree(@"C:\Dir1\Dir2"),
             new DirTree(@"C:\Dir1\Dir3")
             ),
             new DirTree(@"C:\Dir4",
             new DirTree(@"C:\Dir4\Dir5"),
             new DirTree(@"C:\Dir4\Dir6")
             ));
     var path = @"D:\Dirs.dir";
     // write the directory tree to a file
     var file = new FileStream(path, FileMode.CreateNew | FileMode.Truncate);
     var w = new BinaryWriter(file);
     d1.WriteTo(w);
     w.Close();
     file.Close();
     // read it from the file
     var file2 = new FileStream(path, FileMode.Open);
     var rdr = new BinaryReader(file2);
     var d2 = new DirTree(rdr);
     // now inspect d2 in debugger to see that it was read back into memory
     // find files bigger than (roughly) 1GB
     var BigFiles = from f in f_results.FromFile(@"C:\SomeFile.dat")
                    where f.size > 1e9
                    select f;
 }
Пример #2
0
        public void AppHostShowsErrorWhenGivenSubcommandWasNotFoundInProjectJson(string flavor, string os, string architecture)
        {
            var runtimeHomeDir   = _fixture.GetRuntimeHomeDir(flavor, os, architecture);
            var projectStructure = @"{
  ""project.json"": ""{ }""
}";

            using (var projectPath = new DisposableDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", @"
{
    ""frameworks"": {
        ""dnx451"": { },
        ""dnxcore50"": { }
    }
}").WriteTo(projectPath);

                string stdOut, stdErr;
                var    exitCode = TestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: "invalid",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                },
                    workingDir: projectPath);

                Assert.Equal(1, exitCode);
                Assert.Contains("Unable to load application or execute command 'invalid'.", stdErr);
            }
        }
Пример #3
0
        public void AppHostShowsErrorWhenGivenSubcommandWasNotFoundInProjectJson(string flavor, string os, string architecture)
        {
            var runtimeHomeDir   = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);
            var projectStructure = @"{
  'project.json': '{ }'
}";

            using (runtimeHomeDir)
                using (var projectPath = TestUtils.CreateTempDir())
                {
                    DirTree.CreateFromJson(projectStructure).WriteTo(projectPath);

                    string stdOut, stdErr;
                    var    exitCode = BootstrapperTestUtils.ExecBootstrapper(
                        runtimeHomeDir,
                        arguments: $"{projectPath} invalid",
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.AppBase, projectPath }
                    });

                    Assert.NotEqual(0, exitCode);
                    Assert.Contains("Unable to load application or execute command 'invalid'.", stdErr);
                }
        }
Пример #4
0
        public void KCommandShowsErrorWhenGivenSubcommandWasNotFoundInProjectJson(DisposableDir runtimeHomeDir)
        {
            var projectStructure = @"{
  'project.json': '{ }'
}";

            using (runtimeHomeDir)
                using (var projectPath = TestUtils.CreateTempDir())
                {
                    DirTree.CreateFromJson(projectStructure).WriteTo(projectPath);

                    string stdOut, stdErr;
                    var    exitCode = KCommandTestUtils.ExecKCommand(
                        runtimeHomeDir,
                        subcommand: "invalid",
                        arguments: string.Empty,
                        stdOut: out stdOut,
                        stdErr: out stdErr,
                        environment: new Dictionary <string, string> {
                        { EnvironmentNames.AppBase, projectPath }
                    });

                    Assert.NotEqual(0, exitCode);
                    Assert.Contains("Unable to load application or execute command 'invalid'.", stdErr);
                }
        }
Пример #5
0
        private void objFile_FileOk(object sender, CancelEventArgs e)
        {
            int selectedResource = GetSelectedTreeResource();

            if (selectedResource <= 0)
            {
                MessageBox.Show("请选择一个目录", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                OpenFileDialog objFileDialog = (OpenFileDialog)sender;
                for (int i = 0; i < objFileDialog.Files.Count; i++)
                {
                    String filePath;
                    HttpPostedFileHandle hfh = (HttpPostedFileHandle)objFileDialog.Files[i];;
                    _currentUser.CreateFile(selectedResource, hfh.PostedFileName, out filePath);
                    hfh.SaveAs(filePath);

                    DirTree selTree = GetActiveTree();
                    selTree.ReloadFileList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建文件失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #6
0
        public frmMain()
        {
            InitializeComponent();
            Text = $@"RomVaultX {Application.StartupPath}";

            string driveLetter = AppSettings.ReadSetting("vDriveLetter");

            if (driveLetter == null)
            {
                AppSettings.AddUpdateAppSettings("vDriveLetter", "V");

                driveLetter = AppSettings.ReadSetting("vDriveLetter");
            }
            vDriveLetter = driveLetter.ToCharArray()[0];

            addGameGrid();
            string res = Program.db.ConnectToDB();

            if (!string.IsNullOrEmpty(res))
            {
                MessageBox.Show("res", "DB Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }

            DatUpdate.UpdateGotTotal();
            DirTree.Setup(RvTreeRow.ReadTreeFromDB());
        }
Пример #7
0
        private void CreateFolder_Closed(object sender, EventArgs e)
        {
            NameForm nameForm = (NameForm)sender;

            if (nameForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                int selectedResource = GetSelectedTreeResource();
                if (selectedResource <= 0)
                {
                    MessageBox.Show("选择的父目录不存在", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                _currentUser.CreateFolder(selectedResource, nameForm.NewName);
                DirTree selTree = GetActiveTree();
                selTree.ReloadTreeNode(selTree.MainTreeView.SelectedNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建目录失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        private void DeleteFileHandler(object sender, EventArgs e)
        {
            if (((Form)sender).DialogResult != DialogResult.Yes)
            {
                return;
            }

            FileList currentList = GetActiveFileList();

            if (currentList == null)
            {
                MessageBox.Show("请选择文件", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                foreach (ListViewItem item in currentList.FileListView.Items)
                {
                    if (item.Checked)
                    {
                        CResourceEntity res      = new CResourceEntity(MidLayerSettings.ConnectionString).Load((int)item.Tag);
                        String          filePath = res.MakeFullPath();
                        _currentUser.DeleteResource((int)item.Tag);
                        System.IO.File.Delete(filePath);
                    }
                }
                DirTree selTree = GetActiveTree();
                selTree.ReloadFileList();
            }
            catch (Exception ex)
            {
                MessageBox.Show("系统错误: " + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
 public frmMain()
 {
     InitializeComponent();
     addGameGrid();
     DataAccessLayer.UpdateGotTotal();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
 }
Пример #10
0
        private void DeleteFolder_Closed(object sender, EventArgs e)
        {
            if (((Form)sender).DialogResult != DialogResult.Yes)
            {
                return;
            }

            try
            {
                TreeNode node = GetSelectedTreeNode();
                if (node == null || (int)node.Tag <= 0)
                {
                    MessageBox.Show("选择的目录不存在", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CResourceEntity res = new CResourceEntity(MidLayerSettings.ConnectionString).Load((int)node.Tag);

                String dirPath = res.MakeFullPath();
                _currentUser.DeleteResource((int)node.Tag);
                System.IO.Directory.Delete(dirPath, true);

                node = node.Parent;
                if (node != null)
                {
                    DirTree selTree = GetActiveTree();
                    selTree.ReloadTreeNode(node);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除目录失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #11
0
        public void ProjectResolverChecksProjectFileForDisambiguation()
        {
            const string projectName       = "ProjectA";
            var          solutionStructure = @"{
  'global.json': '',
  'src1': {
    'ProjectA': {
      'project.json': '{}'
    }
  },
  'src2': {
    'ProjectA': {
      'file.txt': 'Not a project.json'
    }
  }
}";

            using (var solutionPath = new DisposableDir())
            {
                DirTree.CreateFromJson(solutionStructure)
                .WithFileContents("global.json", @"{
  ""projects"": [""src1"", ""src2""]
}")
                .WriteTo(solutionPath);

                var projectPath = Path.Combine(solutionPath, "src1", projectName);

                Runtime.Project project;
                Assert.True(new ProjectResolver(projectPath).TryResolveProject(projectName, out project));
                Assert.NotNull(project);
            }
        }
Пример #12
0
        private void menuShareFolder_Click(object sender, EventArgs e)
        {
            try
            {
                DirTree activeTree = GetActiveTree();
                if (activeTree == myDirTree || (activeTree == archiveDirTree && _currentUser.Usr_Type == (int)USERTYPE.ORGANIZEADMIN))
                {
                    int res = GetSelectedTreeResource();
                    if (res <= 0)
                    {
                        MessageBox.Show("无法共享选择的资源!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    ShareForm shareForm = new ShareForm();
                    shareForm.CurrentUser = _currentUser;
                    shareForm.ResourceId  = res;
                    shareForm.Closed     += new EventHandler(shareForm_Closed);
                    shareForm.ShowDialog();
                }
                else
                {
                    MessageBox.Show("只能共享个人目录!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("无法共享: " + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #13
0
        public void CanSpecifyProjectDirectoryInGlobalJson()
        {
            var solutionStructure = @"{
  'global.json': '',
  'src': {
    'ProjectA': {
      'project.json': '{}'
    }
  },
  'ProjectB': {
    'project.json': '{}'
  }
}";

            using (var solutionPath = new DisposableDir())
            {
                DirTree.CreateFromJson(solutionStructure)
                .WithFileContents("global.json", @"{
  ""projects"": [""src"", ""ProjectB""]
}")
                .WriteTo(solutionPath);

                var resolutionRoot = Path.Combine(solutionPath, "src", "ProjectA");

                Runtime.Project project;
                Assert.True(new ProjectResolver(resolutionRoot).TryResolveProject("ProjectB", out project));
                Assert.NotNull(project);
            }
        }
Пример #14
0
        public void ProjectResolverDoesNotThrowWhenThereAreDuplicatedEntriesInGlobalJson()
        {
            const string unambiguousName   = "ProjectA";
            var          solutionStructure = @"{
  'global.json': '',
  'src': {
    'ProjectA': {
      'project.json': '{}'
    }
  }
}";

            using (var solutionPath = new DisposableDir())
            {
                DirTree.CreateFromJson(solutionStructure)
                .WithFileContents("global.json", @"{
  ""projects"": [""src"", ""src/../src"", ""somedir\\somesubdir\\..\\..\\src""]
}")
                .WriteTo(solutionPath);

                var unambiguousProjectPath = Path.Combine(solutionPath, "src", unambiguousName);

                Runtime.Project project;
                Assert.True(new ProjectResolver(unambiguousProjectPath).TryResolveProject(unambiguousName, out project));
                Assert.NotNull(project);
            }
        }
Пример #15
0
        public void ProjectResolverWorksWithMultipleNonProjectFoldersThatHaveSameName()
        {
            const string projectName       = "ProjectA";
            var          solutionStructure = @"{
  'global.json': '',
  'src1': {
    'ProjectA': {
      'file.txt': 'Not a project.json'
    }
  },
  'src2': {
    'ProjectA': {
      'file.txt': 'Not a project.json'
    }
  }
}";

            using (var solutionPath = new DisposableDir())
            {
                DirTree.CreateFromJson(solutionStructure)
                .WithFileContents("global.json", @"{
  ""projects"": [""src1"", ""src2""]
}")
                .WriteTo(solutionPath);

                var projectPath = Path.Combine(solutionPath, "src1", projectName);

                Runtime.Project project;
                Assert.False(new ProjectResolver(projectPath).TryResolveProject(projectName, out project));
                Assert.Null(project);
            }
        }
Пример #16
0
        public void DnuRestore_UsesProjectAndCommandLineProvidedRuntimes(string flavor, string os, string architecture)
        {
            var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);

            LockFile lockFile;

            using (var testDir = new DisposableDir())
            {
                var misc = TestUtils.GetMiscProjectsFolder();
                DirTree.CreateFromDirectory(Path.Combine(misc, "RuntimeRestore", "TestProject"))
                .WriteTo(testDir);

                // Clean up the lock file if it ended up there during the copy
                var lockFilePath = Path.Combine(testDir, "project.lock.json");
                if (File.Exists(lockFilePath))
                {
                    File.Delete(lockFilePath);
                }

                // Modify the project
                AddRuntimeToProject(testDir, "win10-x86");

                // Restore the project!
                var source = Path.Combine(misc, "RuntimeRestore", "RuntimeRestoreTestPackage", "feed");
                DnuTestUtils.ExecDnu(runtimeHomeDir, "restore", $"--source {source} --runtime ubuntu.14.04-x64 --runtime osx.10.10-x64", workingDir: testDir);

                // Check the lock file
                lockFile = (new LockFileFormat()).Read(Path.Combine(testDir, "project.lock.json"));
            }

            AssertLockFileTarget(lockFile, "win10-x86", "win8-x86");
            AssertLockFileTarget(lockFile, "osx.10.10-x64", "osx.10.10-x64");
            AssertLockFileTarget(lockFile, "ubuntu.14.04-x64", "ubuntu.14.04-x64");
        }
Пример #17
0
        void update()
        {
            files.Search(new SearchSpec(FileSearch.Text));
            if (ShowRightOnly.IsChecked == true)
            {
                files.SearchRightPresent();
            }
            DirTree.Data.ClearAll();
            DirTree.Data.AddRootItem(files);
            if (IsVisible)
            {
                if (lastSelectedFile != null && lastSelectedFile.Parent != null &&
                    !lastSelectedFile.LeftPresent && !lastSelectedFile.RightPresent)
                {
                    // File has been deleted or renamed.  Check for renaming
                    UInt32 instance = NameRegistry.Files.toHash(lastSelectedFile.BaseName);
                    UInt32 group    = NameRegistry.Groups.toHash(lastSelectedFile.Parent.Path);
                    UInt32 ext      = NameRegistry.Types.toHash(lastSelectedFile.FileType);
                    string newpath  = NameRegistry.Groups.toName(group) + "\\" + NameRegistry.Files.toName(instance) + "." + NameRegistry.Types.toName(ext);
                    lastSelectedFile = files.getFile(newpath, false);
                }
                DirTree.SelectedItem = lastSelectedFile;
                if (DirTree.SelectedItem != null)
                {
                    DirTree.ScrollIntoView(DirTree.SelectedItem);
                }

                /*if (editing != null && DirTree.SelectedItem != null &&
                 *  editing == RightPath + "\\" + (DirTree.SelectedItem as DirectoryTree).Path)
                 * {
                 *  if (System.IO.File.GetLastWriteTimeUtc(editing) >
                 * }*/
                updateEditorSearch();
            }
        }
Пример #18
0
        public void BootstrapperLaunches46ClrIfDnx46IsHighestVersionInProject(string flavor, string os, string architecture)
        {
            const string projectStructure = @"{
    ""project.json"": {},
    ""project.lock.json"": {},
    ""Program.cs"": {}
}";

            const string projectJson = @"{
    ""dependencies"": {
    },
    ""frameworks"": {
        ""dnx46"": {
        },
        ""dnx451"": {
        }
    }
}";
            const string lockFile    = @"{
  ""locked"": false,
  ""version"": 2,
  ""targets"": {
    ""DNX,Version=v4.6"": {},
    ""DNX,Version=v4.5.1"": {}
  },
  ""libraries"": {},
  ""projectFileDependencyGroups"": {
    """": [],
    ""DNX,Version=v4.6"": [],
    ""DNX,Version=v4.5.1"": []
  }
}";

            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempDir = new DisposableDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJson)
                .WithFileContents("project.lock.json", lockFile)
                .WithFileContents("Program.cs", ClrVersionTestProgram)
                .WriteTo(tempDir);

                string stdOut;
                string stdErr;
                var    exitCode = TestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: "-p . run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                },
                    workingDir: tempDir);

                Assert.Equal(0, exitCode);
                Assert.Contains("40600", stdOut.Trim());
            }
        }
Пример #19
0
        public void BootstrapperLaunchesRequestedFramworkVersionIfOptionProvided(string flavor, string os, string architecture, string requestedFramework, string expectedOutput)
        {
            const string projectStructure = @"{
    ""project.json"": {},
    ""project.lock.json"": {},
    ""Program.cs"": {}
}";

            const string projectJson = @"{
    ""dependencies"": {
    },
    ""frameworks"": {
        ""dnx46"": {},
        ""dnx452"": {},
        ""dnx451"": {}
    }
}";
            const string lockFile    = @"{
  ""locked"": false,
  ""version"": 1,
  ""targets"": {
    ""DNX,Version=v4.5.1"": {}
    ""DNX,Version=v4.5.2"": {}
    ""DNX,Version=v4.6"": {}
  },
  ""libraries"": {},
  ""projectFileDependencyGroups"": {
    """": [],
    ""DNX,Version=v4.5.1"": []
    ""DNX,Version=v4.5.2"": []
    ""DNX,Version=v4.6"": []
  }
}";

            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempDir = TestUtils.CreateTempDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJson)
                .WithFileContents("project.lock.json", lockFile)
                .WithFileContents("Program.cs", ClrVersionTestProgram)
                .WriteTo(tempDir);

                string stdOut;
                string stdErr;
                var    exitCode = TestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: $"--framework {requestedFramework} run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                },
                    workingDir: tempDir);
                Assert.Equal(0, exitCode);
                Assert.Equal(expectedOutput, stdOut.Trim());
            }
        }
Пример #20
0
 private void deepReScanToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning RomRoot Files", romRootScanner.ScanFilesDeep);
     progress.ShowDialog(this);
     progress.Dispose();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
     DatSetSelected(DirTree.Selected);
 }
Пример #21
0
 private void btnUpdateDats_Click(object sender, EventArgs e)
 {
     FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning Dats", DatUpdate.UpdateDat);
     progress.ShowDialog(this);
     progress.Dispose();
     DirTree.Setup(RvTreeRow.ReadTreeFromDB());
     DatSetSelected(DirTree.Selected);
 }
Пример #22
0
        private void GameGridMouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (_updatingGameGrid)
            {
                return;
            }

            if (GameGrid.SelectedRows.Count != 1)
            {
                return;
            }

            RvFile tGame = gameGrid[GameGrid.SelectedRows[0].Index];

            if (tGame.Game == null)
            {
                UpdateGameGrid(tGame);
                DirTree.SetSelected(tGame);
            }
            else
            {
                string path = tGame.Parent.DatTreeFullName;
                if (Settings.rvSettings?.EInfo == null)
                {
                    return;
                }

                foreach (EmulatorInfo ei in Settings.rvSettings.EInfo)
                {
                    if (!string.Equals(path, ei.TreeDir, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }

                    if (string.IsNullOrWhiteSpace(ei.CommandLine))
                    {
                        continue;
                    }

                    string commandLineOptions = ei.CommandLine;
                    string dirname            = tGame.Parent.FullName;
                    commandLineOptions = commandLineOptions.Replace("{gamename}", Path.GetFileNameWithoutExtension(tGame.Name));
                    commandLineOptions = commandLineOptions.Replace("{gamefilename}", tGame.Name);
                    commandLineOptions = commandLineOptions.Replace("{gamedirectory}", dirname);
                    using (Process exeProcess = new Process())
                    {
                        exeProcess.StartInfo.WorkingDirectory = ei.WorkingDirectory;
                        exeProcess.StartInfo.FileName         = ei.ExeName;
                        exeProcess.StartInfo.Arguments        = commandLineOptions;
                        exeProcess.StartInfo.UseShellExecute  = false;
                        exeProcess.StartInfo.CreateNoWindow   = true;
                        exeProcess.Start();
                    }

                    return;
                }
            }
        }
Пример #23
0
        private void DoScan()
        {
            FrmProgressWindow progress = new FrmProgressWindow(this, "Scanning Files", RomScanner.ScanFiles);

            progress.ShowDialog(this);
            progress.Dispose();
            DirTree.Setup(RvTreeRow.ReadTreeFromDB());
            DatSetSelected(DirTree.Selected);
        }
Пример #24
0
        private TreeNode GetSelectedTreeNode()
        {
            DirTree selectedTree = GetActiveTree();

            if (selectedTree == null)
            {
                return(null);
            }
            return(selectedTree.MainTreeView.SelectedNode);
        }
Пример #25
0
        private void DatSetSelected(RvTreeRow cf)
        {
            DirTree.Refresh();
            GameGrid.Rows.Clear();
            RomGrid.Rows.Clear();

            if (cf == null)
                return;

            UpdateGameGrid(cf.DatId);
        }
Пример #26
0
        public void DnuRestore_GeneratesDefaultRuntimeTargets(string flavor, string os, string architecture)
        {
            // TODO(anurse): Maybe this could be a condition? This is the only place we need it right now so it
            // didn't seem worth the refactor.
            if (RuntimeEnvironmentHelper.RuntimeEnvironment.OperatingSystem.Equals("Darwin"))
            {
                var ver = Version.Parse(RuntimeEnvironmentHelper.RuntimeEnvironment.OperatingSystemVersion);
                if (ver < new Version(10, 10))
                {
                    // Not supported on this!
                    return;
                }
            }

            var runtimeHomeDir = TestUtils.GetRuntimeHomeDir(flavor, os, architecture);

            LockFile lockFile;

            using (var testDir = new DisposableDir())
            {
                var misc = TestUtils.GetMiscProjectsFolder();
                DirTree.CreateFromDirectory(Path.Combine(misc, "RuntimeRestore", "TestProject"))
                .WriteTo(testDir);

                // Clean up the lock file if it ended up there during the copy
                var lockFilePath = Path.Combine(testDir, "project.lock.json");
                if (File.Exists(lockFilePath))
                {
                    File.Delete(lockFilePath);
                }

                // Restore the project!
                var source = Path.Combine(misc, "RuntimeRestore", "RuntimeRestoreTestPackage", "feed");
                DnuTestUtils.ExecDnu(runtimeHomeDir, "restore", $"--source {source}", workingDir: testDir);

                // Check the lock file
                lockFile = (new LockFileFormat()).Read(Path.Combine(testDir, "project.lock.json"));
            }

            // We can use the runtime environment to determine the expected RIDs because by default it only uses the current OSes RIDs
            if (RuntimeEnvironmentHelper.IsWindows)
            {
                AssertLockFileTarget(lockFile, "win7-x86", "win7-x86");
                AssertLockFileTarget(lockFile, "win7-x64", "win7-x64");
            }
            else
            {
                var osName = RuntimeEnvironmentHelper.RuntimeEnvironment.GetDefaultRestoreRuntimes().First();
                osName = osName.Substring(0, osName.Length - 4);                    // Remove the -x86 suffix
                AssertLockFileTarget(lockFile, osName + "-x86", assemblyRid: null); // There is no ubuntu/osx-x86 in the test package
                AssertLockFileTarget(lockFile, osName + "-x64", osName + "-x64");
            }
        }
Пример #27
0
        private void BuildTreeRecursively(TreeNodeCollection nodes, DirTree dirTree)
        {
            foreach (MyFileInfo file in dirTree.Files)
            {
                AddFileTreeNode(nodes, file);
            }

            foreach (DirTree dir in dirTree.Dirs)
            {
                TreeNode tn = AddDirTreeNode(nodes, dir.Info);
                BuildTreeRecursively(tn.Nodes, dir);
            }
        }
        private void AddCompartmentNode(Compartment compartment, TreeNode parentNode)
        {
            if (compartment.LifecycleState != "ACTIVE")
            {
                return;
            }
            var node = parentNode.Nodes.Add(compartment.Name);

            node.Name = compartment.Name;
            node.Tag  = "Compartment," + compartment.Id;

            DirTree.Refresh();
        }
Пример #29
0
        /// <summary>
        /// build base treenodes in treeView
        /// </summary>
        /// <param name="dirTree"></param>
        private void BuildTreeBase(DirTree dirTree)
        {
            foreach (DirTree dir in dirTree.Dirs)
            {
                dir.Info.DirTreeViewNode = new SyncDirTreeViewNode(dir.Info);
                treeView1.Nodes.Add(dir.Info.DirTreeViewNode);
            }

            foreach (MyFileInfo file in dirTree.Files)
            {
                file.FileTreeViewNode = new SyncFileTreeViewNode(file);
                treeView1.Nodes.Add(file.FileTreeViewNode);
            }
        }
Пример #30
0
        public void BootstrapperConfiguresAppConfigFile(string flavor, string os, string architecture)
        {
            const string projectStructure = @"{
    ""project.json"": {},
    ""project.lock.json"": {},
    ""app.config"": {},
    ""Program.cs"": {}
}";

            const string projectJson = @" {
    ""frameworks"": {
        ""dnx451"": {
            ""frameworkAssemblies"": {
                ""System.Configuration"": """"
            }
        }
    }
}";
            const string appConfig   = @"<configuration>
  <appSettings>
    <add key=""TheSetting"" value=""TheValue"" />
  </appSettings>
</configuration>";

            var runtimeHomeDir = _fixture.GetRuntimeHomeDir(flavor, os, architecture);

            using (var tempDir = TestUtils.CreateTempDir())
            {
                DirTree.CreateFromJson(projectStructure)
                .WithFileContents("project.json", projectJson)
                .WithFileContents("app.config", appConfig)
                .WithFileContents("Program.cs", AppSettingTestProgram)
                .WriteTo(tempDir);

                string stdOut;
                string stdErr;
                var    exitCode = TestUtils.ExecBootstrapper(
                    runtimeHomeDir,
                    arguments: $"run",
                    stdOut: out stdOut,
                    stdErr: out stdErr,
                    environment: new Dictionary <string, string> {
                    { EnvironmentNames.Trace, null }
                },
                    workingDir: tempDir);
                Assert.Equal(0, exitCode);
                Assert.Equal("TheSetting=TheValue", stdOut.Trim());
            }
        }