System.IO.Path.Combine(string, string, string, string)

Here are the examples of the csharp api System.IO.Path.Combine(string, string, string, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

821 Examples 7

19 Source : FileSystemUserData.cs
with MIT License
from 0x0ade

public string GetUserFilePath(string uid, string name)
            // Misnomer: "data" in this case should be "raw". Can't change without breaking compat tho.
            => Path.Combine(UserRoot, uid, "data", name);

19 Source : ImageSaver.cs
with MIT License
from Abdulrhman5

public async Task<CommandResult<SavedImageViewModel>> SaveImage(IFormFile image)
        {
            if (image is null)
            {
                return new CommandResult<SavedImageViewModel>(
                    new ErrorMessage
                    {
                        ErrorCode = "IMAGE.NULL",
                        Message = "Please send a valid data",
                        StatusCode = System.Net.HttpStatusCode.BadRequest
                    });
            }

            if (!ImageMimeType.Any(m => m.EqualsIC(image.ContentType))
                || !ImageExtension.Any(e => e.EqualsIC(Path.GetExtension(image.FileName))))
            {
                return new CommandResult<SavedImageViewModel>(new ErrorMessage
                {
                    ErrorCode = "IMAGE.NOT.IMAGE",
                    Message = "Please send image",
                    StatusCode = System.Net.HttpStatusCode.BadRequest
                });
            }


            if (image.Length == 0)
            {
                return new CommandResult<SavedImageViewModel>(
                    new ErrorMessage
                    {
                        ErrorCode = "IMAGE.TOO.SMALL",
                        Message = "Please send a valid image",
                        StatusCode = System.Net.HttpStatusCode.BadRequest
                    });
            }


            if (image.Length > 4 * 1024 * 1024)
            {
                return new CommandResult<SavedImageViewModel>(
                    new ErrorMessage
                    {
                        ErrorCode = "IMAGE.TOO.LARGE",
                        Message = "Please send a smaller image",
                        StatusCode = System.Net.HttpStatusCode.BadRequest
                    });
            }

            var name = Guid.NewGuid();
            var withExtension = name + Path.GetExtension(image.FileName);
            var path = Path.Combine(contentRoot, "replacedets", "Images", "Profile");
            Directory.CreateDirectory(path);
            var full = Path.Combine(path, withExtension);

            try
            {
                using (Stream s = new FileStream(full, FileMode.OpenOrCreate))
                {
                    await image.CopyToAsync(s);
                }
                
                return new CommandResult<SavedImageViewModel>(new SavedImageViewModel
                {
                    Name = name,
                    Path = full,                     
                });
            }
            catch (Exception e)
            {
                _logger.LogError(e, "An error occurred while trying to save an image to the desk");
                return new CommandResult<SavedImageViewModel>(new ErrorMessage
                {
                    ErrorCode = "IMAGE.ERROR",
                    Message = "An error occurred while trying to save the image",
                    StatusCode = System.Net.HttpStatusCode.InternalServerError
                });
            }
        }

19 Source : OutputManagerL0.cs
with MIT License
from actions

[Fact]
        [Trait("Level", "L0")]
        [Trait("Category", "Worker")]
        public async void MatcherFile()
        {
            Environment.SetEnvironmentVariable("RUNNER_TEST_GET_REPOSITORY_PATH_FAILSAFE", "2");
            var matchers = new IssueMatchersConfig
            {
                Matchers =
                {
                    new IssueMatcherConfig
                    {
                        Owner = "my-matcher-1",
                        Patterns = new[]
                        {
                            new IssuePatternConfig
                            {
                                Pattern = @"(.+): (.+)",
                                File = 1,
                                Message = 2,
                            },
                        },
                    },
                },
            };
            using (var hostContext = Setup(matchers: matchers))
            using (_outputManager)
            {
                // Setup github.workspace, github.repository
                var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
                ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
                Directory.CreateDirectory(workDirectory);
                var workspaceDirectory = Path.Combine(workDirectory, "workspace");
                Directory.CreateDirectory(workspaceDirectory);
                _executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
                _executionContext.Setup(x => x.GetGitHubContext("repository")).Returns("my-org/workflow-repo");

                // Setup some git repositories
                // <WORKSPACE>/workflow-repo
                // <WORKSPACE>/workflow-repo/nested-other-repo
                // <WORKSPACE>/other-repo
                // <WORKSPACE>/other-repo/nested-workflow-repo
                // <WORKSPACE>/workflow-repo-using-ssh
                var workflowRepository = Path.Combine(workspaceDirectory, "workflow-repo");
                var nestedOtherRepository = Path.Combine(workspaceDirectory, "workflow-repo", "nested-other-repo");
                var otherRepository = Path.Combine(workspaceDirectory, workflowRepository, "nested-other-repo");
                var nestedWorkflowRepository = Path.Combine(workspaceDirectory, "other-repo", "nested-workflow-repo");
                var workflowRepositoryUsingSsh = Path.Combine(workspaceDirectory, "workflow-repo-using-ssh");
                await CreateRepository(hostContext, workflowRepository, "https://github.com/my-org/workflow-repo");
                await CreateRepository(hostContext, nestedOtherRepository, "https://github.com/my-org/other-repo");
                await CreateRepository(hostContext, otherRepository, "https://github.com/my-org/other-repo");
                await CreateRepository(hostContext, nestedWorkflowRepository, "https://github.com/my-org/workflow-repo");
                await CreateRepository(hostContext, workflowRepositoryUsingSsh, "[email protected]:my-org/workflow-repo.git");

                // Create test files
                var file_noRepository = Path.Combine(workspaceDirectory, "no-repo.txt");
                var file_workflowRepository = Path.Combine(workflowRepository, "workflow-repo.txt");
                var file_workflowRepository_nestedDirectory = Path.Combine(workflowRepository, "subdir", "subdir2", "workflow-repo-nested-dir.txt");
                var file_workflowRepository_failsafe = Path.Combine(workflowRepository, "failsafe-subdir", "failsafe-subdir2", "failsafe-subdir3", "workflow-repo-failsafe.txt");
                var file_nestedOtherRepository = Path.Combine(nestedOtherRepository, "nested-other-repo");
                var file_otherRepository = Path.Combine(otherRepository, "other-repo.txt");
                var file_nestedWorkflowRepository = Path.Combine(nestedWorkflowRepository, "nested-workflow-repo.txt");
                var file_workflowRepositoryUsingSsh = Path.Combine(workflowRepositoryUsingSsh, "workflow-repo-using-ssh.txt");
                foreach (var file in new[] { file_noRepository, file_workflowRepository, file_workflowRepository_nestedDirectory, file_workflowRepository_failsafe, file_nestedOtherRepository, file_otherRepository, file_nestedWorkflowRepository, file_workflowRepositoryUsingSsh })
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(file));
                    File.WriteAllText(file, "");
                }

                // Process
                Process($"{file_noRepository}: some error 1");
                Process($"{file_workflowRepository}: some error 2");
                Process($"{file_workflowRepository.Substring(workspaceDirectory.Length + 1)}: some error 3"); // Relative path from workspace dir
                Process($"{file_workflowRepository_nestedDirectory}: some error 4");
                Process($"{file_workflowRepository_failsafe}: some error 5");
                Process($"{file_nestedOtherRepository}: some error 6");
                Process($"{file_otherRepository}: some error 7");
                Process($"{file_nestedWorkflowRepository}: some error 8");
                Process($"{file_workflowRepositoryUsingSsh}: some error 9");

                replacedert.Equal(9, _issues.Count);

                replacedert.Equal("some error 1", _issues[0].Item1.Message);
                replacedert.False(_issues[0].Item1.Data.ContainsKey("file"));

                replacedert.Equal("some error 2", _issues[1].Item1.Message);
                replacedert.Equal(file_workflowRepository.Substring(workflowRepository.Length + 1).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), _issues[1].Item1.Data["file"]);

                replacedert.Equal("some error 3", _issues[2].Item1.Message);
                replacedert.Equal(file_workflowRepository.Substring(workflowRepository.Length + 1).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), _issues[2].Item1.Data["file"]);

                replacedert.Equal("some error 4", _issues[3].Item1.Message);
                replacedert.Equal(file_workflowRepository_nestedDirectory.Substring(workflowRepository.Length + 1).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), _issues[3].Item1.Data["file"]);

                replacedert.Equal("some error 5", _issues[4].Item1.Message);
                replacedert.False(_issues[4].Item1.Data.ContainsKey("file"));

                replacedert.Equal("some error 6", _issues[5].Item1.Message);
                replacedert.False(_issues[5].Item1.Data.ContainsKey("file"));

                replacedert.Equal("some error 7", _issues[6].Item1.Message);
                replacedert.False(_issues[6].Item1.Data.ContainsKey("file"));

                replacedert.Equal("some error 8", _issues[7].Item1.Message);
                replacedert.Equal(file_nestedWorkflowRepository.Substring(nestedWorkflowRepository.Length + 1).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), _issues[7].Item1.Data["file"]);

                replacedert.Equal("some error 9", _issues[8].Item1.Message);
                replacedert.Equal(file_workflowRepositoryUsingSsh.Substring(workflowRepositoryUsingSsh.Length + 1).Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), _issues[8].Item1.Data["file"]);
            }

            Environment.SetEnvironmentVariable("RUNNER_TEST_GET_REPOSITORY_PATH_FAILSAFE", "");
        }

19 Source : OutputManagerL0.cs
with MIT License
from actions

[Fact]
        [Trait("Level", "L0")]
        [Trait("Category", "Worker")]
        public async void MatcherFromPath()
        {
            var matchers = new IssueMatchersConfig
            {
                Matchers =
                {
                    new IssueMatcherConfig
                    {
                        Owner = "my-matcher-1",
                        Patterns = new[]
                        {
                            new IssuePatternConfig
                            {
                                Pattern = @"(.+): (.+) \[(.+)\]",
                                File = 1,
                                Message = 2,
                                FromPath = 3,
                            },
                        },
                    },
                },
            };
            using (var hostContext = Setup(matchers: matchers))
            using (_outputManager)
            {
                // Setup github.workspace, github.repository
                var workDirectory = hostContext.GetDirectory(WellKnownDirectory.Work);
                ArgUtil.NotNullOrEmpty(workDirectory, nameof(workDirectory));
                Directory.CreateDirectory(workDirectory);
                var workspaceDirectory = Path.Combine(workDirectory, "workspace");
                Directory.CreateDirectory(workspaceDirectory);
                _executionContext.Setup(x => x.GetGitHubContext("workspace")).Returns(workspaceDirectory);
                _executionContext.Setup(x => x.GetGitHubContext("repository")).Returns("my-org/workflow-repo");

                // Setup a git repository
                var repositoryPath = Path.Combine(workspaceDirectory, "workflow-repo");
                await CreateRepository(hostContext, repositoryPath, "https://github.com/my-org/workflow-repo");

                // Create a test file
                var filePath = Path.Combine(repositoryPath, "some-project", "some-directory", "some-file.txt");
                Directory.CreateDirectory(Path.GetDirectoryName(filePath));
                File.WriteAllText(filePath, "");

                // Process
                Process("some-directory/some-file.txt: some error [workflow-repo/some-project/some-project.proj]");
                replacedert.Equal(1, _issues.Count);
                replacedert.Equal("some error", _issues[0].Item1.Message);
                replacedert.Equal("some-project/some-directory/some-file.txt", _issues[0].Item1.Data["file"]);
                replacedert.Equal(0, _commands.Count);
                replacedert.Equal(0, _messages.Count);
            }
        }

19 Source : GenerateNuSpecFileTask.cs
with MIT License
from adamecr

public override bool Execute()
        {
            if (DebugTasks)
            {
                //Wait for debugger
                Log.LogMessage(
                    MessageImportance.High,
                    $"Debugging task {GetType().Name}, set the breakpoint and attach debugger to process with PID = {System.Diagnostics.Process.GetCurrentProcess().Id}");

                while (!System.Diagnostics.Debugger.IsAttached)
                {
                    Thread.Sleep(1000);
                }
            }

            var replacedle = !string.IsNullOrEmpty(replacedle) ? replacedle : PackageId;

            var sb = new System.Text.StringBuilder(); //TODO refactor to LINQ XML
            sb.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            sb.AppendLine($"<package xmlns=\"http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd\">");
            sb.AppendLine($" <metadata>");
            sb.AppendLine($"  <id>{PackageId}</id>");
            sb.AppendLine($"  <version>{PackageVersionFull}</version>");
            sb.AppendLine($"  <authors>{Authors}</authors>");
            sb.AppendLine($"  <replacedle>{replacedle}</replacedle>");
            sb.AppendLine($"  <owners>{Authors}</owners>");
            sb.AppendLine($"  <requireLicenseAcceptance>{PackageRequireLicenseAcceptance}</requireLicenseAcceptance>");
            // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
            if (!string.IsNullOrEmpty(PackageLicense))
            {
                sb.AppendLine($"  <license type=\"expression\">{PackageLicense}</license>");
            }
            else
            {
                sb.AppendLine($"  <licenseUrl>{PackageLicenseUrl}</licenseUrl>");
            }
            sb.AppendLine($"  <projectUrl>{PackageProjectUrl}</projectUrl>");
            sb.AppendLine($"  <iconUrl>{PackageIconUrl}</iconUrl>");
            sb.AppendLine($"  <description>{Description}</description>");
            sb.AppendLine($"  <releaseNotes>{PackageReleaseNotes}</releaseNotes>");
            sb.AppendLine($"  <copyright>{Copyright}</copyright>");
            sb.AppendLine($"  <tags>{PackageTags}</tags>");
            sb.AppendLine(
                $"  <repository url=\"{RepositoryUrl}\" type=\"git\" branch=\"{GitBranch}\" commit=\"{GitCommit}\" />");
            sb.AppendLine($"  <dependencies>");
            sb.AppendLine($"   <group targetFramework=\"{TargetFramework}\">");

            if (PackageReferences != null)
            {
                foreach (var r in PackageReferences)
                {
                    var item = r.ItemSpec;
                    if (item != "NETStandard.Library")
                        sb.AppendLine(
                            $"    <dependency id=\"{r.ItemSpec}\" version=\"{r.GetMetadata("Version")}\" exclude=\"Build,replacedyzers\" />");
                }
            }

            var resolvedProjectReferences =
                new List<string>(); //project references that has been resolved as NuGet packages
            if (ProjectReferences != null)
            {
                foreach (var src in ProjectReferences)
                {
                    var refPackageDependencyFile = Path.Combine(src.GetMetadata("RelativeDir"), IntermediateOutputPath,
                        Configuration, "package_dependency.txt");
                    if (!File.Exists(refPackageDependencyFile)) continue;

                    var refPackageDependency = File.ReadAllText(refPackageDependencyFile);

                    resolvedProjectReferences.Add(refPackageDependency);
                    sb.AppendLine(refPackageDependency);
                }
            }

            sb.AppendLine($"   </group>");
            sb.AppendLine($"  </dependencies>");
            sb.AppendLine($" </metadata>");

            sb.AppendLine($"  <files>");
            var dllFile = Path.Combine(ProjectDirectory, OutputPath, $"{replacedemblyName}.dll");
            sb.AppendLine($@"    <file src=""{dllFile}"" target=""lib\{TargetFramework}\{replacedemblyName}.dll"" />");

            var pdbFile = Path.Combine(ProjectDirectory, OutputPath, $"{replacedemblyName}.pdb");
            if (File.Exists(pdbFile))
            {
                sb.AppendLine($@"    <file src=""{pdbFile}"" target=""lib\{TargetFramework}\{replacedemblyName}.pdb"" />");
            }

            var xmlDocFile = Path.Combine(ProjectDirectory, OutputPath, $"{replacedemblyName}.xml");
            if (File.Exists(xmlDocFile))
            {
                sb.AppendLine(
                    $@"    <file src=""{xmlDocFile}"" target=""lib\{TargetFramework}\{replacedemblyName}.xml"" />");
            }

            if (SourceFiles != null && Configuration.ToLower() != "release")
            {
                sb.AppendLine("");

                foreach (var src in SourceFiles)
                {
                    var srcFileOriginal = src.GetMetadata("OriginalItemSpec");
                    var srcFileRel = srcFileOriginal.Replace($@"{ProjectDirectory}\", "");
                    if (Path.IsPathRooted(srcFileRel)) continue; //not a project file (probably source-only package) - project files have the relative path in srcFileRel, non project files have full path in srcFileRel 

                    var targetFile = Path.Combine("src", ProjectName, srcFileRel);
                    sb.AppendLine($@"    <file src=""{src}"" target=""{targetFile}"" />");
                }
            }

            //include project references that has NOT been resolved as NuGet packages
            if (ProjectReferences != null && ReferenceCopyLocalPaths != null)
            {
                foreach (var rf in ReferenceCopyLocalPaths)
                {
                    if (rf.GetMetadata("ReferenceSourceTarget") == "ProjectReference")
                    {
                        var fileName = rf.GetMetadata("FileName");
                        if (!resolvedProjectReferences.Exists(s => s.Contains($"id=\"{fileName}\"")))
                        {
                            sb.AppendLine(
                                $@"    <file src=""{rf.GetMetadata("FullPath")}"" target=""lib\{TargetFramework}\{rf.GetMetadata("FileName")}{rf.GetMetadata("Extension")}"" />");
                        }
                    }
                }
            }

            sb.AppendLine($"  </files>");

            sb.AppendLine($"</package>  ");

            //Write NuSpec file to /obj directory
            NuSpecFile = Path.Combine(ProjectDirectory, IntermediateOutputPath, Configuration,
                PackageVersionShort + ".nuspec");
            File.WriteAllText(NuSpecFile, sb.ToString());

            Log.LogMessage(sb.ToString());

            //Create dependency file for package in /obj directory
            var dep =
                $@"<dependency id=""{PackageId}"" version=""{PackageVersionFull}"" exclude=""Build,replacedyzers"" />";
            var dependencyFile = Path.Combine(ProjectDirectory, IntermediateOutputPath, Configuration,
                "package_dependency.txt");
            File.WriteAllText(dependencyFile, dep);

            return true;
        }

19 Source : Startup.cs
with MIT License
from ai-traders

public void ConfigureServices(IServiceCollection services)
        {
            services.ConfigureLiGet(Configuration, httpServices: true);

            services.AddSpaStaticFiles(configuration =>
            {
                var sourceDist = Path.Combine(Environment.CurrentDirectory, "src", "LiGet.UI" , "dist");
                if(Directory.Exists(sourceDist))
                {
                    // we are running tests from root of project
                    configuration.RootPath = sourceDist;
                    return;
                }
                sourceDist = Path.Combine("src", "LiGet.UI" , "dist");
                for(int depth=0; depth < 5; depth++) {
                    sourceDist = Path.Combine("..", sourceDist);
                    if(Directory.Exists(sourceDist))
                    {
                        // we are running tests from debugger/editor
                        configuration.RootPath = sourceDist;
                        return;
                    }
                }
                // In production, the UI files will be served from wwwroot directory next to LiGet.dll file
                string codeBase = Path.GetDirectoryName(typeof(Startup).replacedembly.CodeBase);
                configuration.RootPath = Path.Combine(codeBase, "wwwroot");
            });
        }

19 Source : FilePackageStorageService.cs
with MIT License
from ai-traders

private string PackagePath(string lowercasedId, string lowercasedNormalizedVersion)
        {
            return Path.Combine(
                _storePath,
                lowercasedId,
                lowercasedNormalizedVersion,
                $"{lowercasedId}.{lowercasedNormalizedVersion}.nupkg");
        }

19 Source : FilePackageStorageService.cs
with MIT License
from ai-traders

private string NuspecPath(string lowercasedId, string lowercasedNormalizedVersion)
        {
            return Path.Combine(
                _storePath,
                lowercasedId,
                lowercasedNormalizedVersion,
                $"{lowercasedId}.nuspec");
        }

19 Source : FilePackageStorageService.cs
with MIT License
from ai-traders

private string ReadmePath(string lowercasedId, string lowercasedNormalizedVersion)
        {
            return Path.Combine(
                _storePath,
                lowercasedId,
                lowercasedNormalizedVersion,
                "readme");
        }

19 Source : PdbFile.cs
with MIT License
from Akaion

private static async Task<string> DownloadPdb(DebugData debugData, bool isWow64)
        {
            // Ensure a directory exists on disk for the PDB

            var directoryInfo = Directory.CreateDirectory(isWow64 ? Path.Combine(Path.GetTempPath(), "Bleak", "PDB", "WOW64") : Path.Combine(Path.GetTempPath(), "Bleak", "PDB", "x64"));

            var pdbName = $"{debugData.Name}-{debugData.Guid}-{debugData.Age}.pdb";

            var pdbPath = Path.Combine(directoryInfo.FullName, pdbName);

            // Determine if the PDB has already been downloaded

            if (directoryInfo.EnumerateFiles().Any(file => file.Name == pdbName))
            {
                return pdbPath;
            }

            // Clear the directory

            foreach (var file in directoryInfo.EnumerateFiles())
            {
                try
                {
                    file.Delete();
                }

                catch (Exception)
                {
                    // The file is currently open and cannot be safely deleted
                }
            }

            // Download the PDB

            var pdbUri = new Uri($"http://msdl.microsoft.com/download/symbols/{debugData.Name}/{debugData.Guid}{debugData.Age}/{debugData.Name}");

            void ReportDownloadProgress(object sender, ProgressChangedEventArgs eventArgs)
            {
                var progress = eventArgs.ProgressPercentage / 2;

                Console.Write($"\rDownloading required files - [{new string('=', progress)}{new string(' ', 50 - progress)}] - {eventArgs.ProgressPercentage}%");
            }

            using var webClient = new WebClient();

            webClient.DownloadProgressChanged += ReportDownloadProgress;

            await webClient.DownloadFileTaskAsync(pdbUri, pdbPath);

            return pdbPath;
        }

19 Source : PathExpansionPackTests.cs
with MIT License
from AlFasGD

[Test]
        public void GetCommonDirectory()
        {
            AreEqual(PathExpansionPack.ConcatenateDirectoryPath("C:", "users", "user"), PathExpansionPack.GetCommonDirectory(Combine("C:", "users", "user", "Desktop"), Combine("C:", "users", "user")));
            AreEqual(PathExpansionPack.ConcatenateDirectoryPath("C:", "users", "user"), PathExpansionPack.GetCommonDirectory(Combine("C:", "users", "user"), Combine("C:", "users", "user", "Desktop")));
            AreEqual(PathExpansionPack.ConcatenateDirectoryPath("C:", "users"), PathExpansionPack.GetCommonDirectory(Combine("C:", "users", "user", "Desktop"), Combine("C:", "users", "Rekkon")));
            AreEqual(PathExpansionPack.ConcatenateDirectoryPath("C:", "users"), PathExpansionPack.GetCommonDirectory(Combine("C:", "users", "user"), Combine("C:", "users", "Rekkon", "Desktop")));
        }

19 Source : PathExpansionPackTests.cs
with MIT License
from AlFasGD

[Test]
        public void DeterminePathItemType()
        {
            AreEqual(PathItemType.Directory, PathExpansionPack.DeterminePathItemType($"{Combine("C:", "users", "user", "Desktop")}{DirectorySeparatorChar}"));
            AreEqual(PathItemType.Volume, PathExpansionPack.DeterminePathItemType($"C{VolumeSeparatorChar}"));
            AreEqual(PathItemType.File, PathExpansionPack.DeterminePathItemType(Combine("C:", "users", "user", "Desktop", "Some file.txt")));
        }

19 Source : PathExpansionPackTests.cs
with MIT License
from AlFasGD

[Test]
        public void GetPreviousPathDirectoryInNewPath()
        {
            AreEqual("Desktop", PathExpansionPack.GetPreviousPathDirectoryInNewPath(Combine("C:", "users", "user", "Desktop"), Combine("C:", "users", "user")));
            AreEqual("user", PathExpansionPack.GetPreviousPathDirectoryInNewPath(Combine("C:", "users", "user", "Desktop"), Combine("C:", "users")));
            AreEqual(null, PathExpansionPack.GetPreviousPathDirectoryInNewPath(Combine("C:", "users", "user"), Combine("C:", "users", "user", "Desktop")));
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

private void CompareLocalVersion()
        {
            // ffmpeg
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.txt")))
            {
                FFmpegCurrentVersion = File.ReadAllText(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.txt"));
                LabelCurrentFFmpegVersion.Content = FFmpegCurrentVersion;
                if (ParseDate(FFmpegCurrentVersion) < ParseDate(FFmpegUpdateVersion))
                {
                    // Update Version is newer
                    LabelCurrentFFmpegVersion.Foreground = Brushes.Red;
                    LabelUpdateFFmpegVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(FFmpegCurrentVersion) == ParseDate(FFmpegUpdateVersion))
                {
                    // Both Versions are identical
                    LabelCurrentFFmpegVersion.Foreground = Brushes.Green;
                    LabelUpdateFFmpegVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(FFmpegCurrentVersion) > ParseDate(FFmpegUpdateVersion))
                {
                    // Local Version is newer
                    LabelCurrentFFmpegVersion.Foreground = Brushes.Green;
                    LabelUpdateFFmpegVersion.Foreground = Brushes.Red;
                }
            }
            else { LabelCurrentFFmpegVersion.Content = "unknown"; LabelCurrentFFmpegVersion.Foreground = Brushes.Red; }

            // aomenc
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.txt")))
            {
                AomencCurrentVersion = File.ReadAllText(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.txt"));
                LabelCurrentAomencVersion.Content = AomencCurrentVersion;
                if (ParseDate(AomencCurrentVersion) < ParseDate(AomencUpdateVersion))
                {
                    // Update Version is newer
                    LabelCurrentAomencVersion.Foreground = Brushes.Red;
                    LabelUpdateAomencVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(AomencCurrentVersion) == ParseDate(AomencUpdateVersion))
                {
                    // Both Versions are identical
                    LabelCurrentAomencVersion.Foreground = Brushes.Green;
                    LabelUpdateAomencVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(AomencCurrentVersion) > ParseDate(AomencUpdateVersion))
                {
                    // Local Version is newer
                    LabelCurrentAomencVersion.Foreground = Brushes.Green;
                    LabelUpdateAomencVersion.Foreground = Brushes.Red;
                }
            }
            else { LabelCurrentAomencVersion.Content = "unknown"; LabelCurrentAomencVersion.Foreground = Brushes.Red; }
            // rav1e
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.txt")))
            {
                Rav1eCurrentVersion = File.ReadAllText(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.txt"));
                LabelCurrentRav1eVersion.Content = Rav1eCurrentVersion;
                if (ParseDate(Rav1eCurrentVersion) < ParseDate(Rav1eUpdateVersion))
                {
                    // Update Version is newer
                    LabelCurrentRav1eVersion.Foreground = Brushes.Red;
                    LabelUpdateRav1eVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(Rav1eCurrentVersion) == ParseDate(Rav1eUpdateVersion))
                {
                    // Both Versions are identical
                    LabelCurrentRav1eVersion.Foreground = Brushes.Green;
                    LabelUpdateRav1eVersion.Foreground = Brushes.Green;
                }
                else if (ParseDate(Rav1eCurrentVersion) > ParseDate(Rav1eUpdateVersion))
                {
                    // Local Version is newer
                    LabelCurrentRav1eVersion.Foreground = Brushes.Green;
                    LabelUpdateRav1eVersion.Foreground = Brushes.Red;
                }
            }
            else { LabelCurrentRav1eVersion.Content = "unknown"; LabelCurrentRav1eVersion.Foreground = Brushes.Red; }
            // svt-av1
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1", "svt-av1.txt")))
            {
                SVTAV1CurrentVersion = File.ReadAllText(Path.Combine(CurrentDir, "Apps", "svt-av1", "svt-av1.txt"));
                LabelCurrentSVTAV1Version.Content = SVTAV1CurrentVersion;
                if (ParseDate(SVTAV1CurrentVersion) < ParseDate(SVTAV1UpdateVersion))
                {
                    // Update Version is newer
                    LabelCurrentSVTAV1Version.Foreground = Brushes.Red;
                    LabelUpdateSVTAV1Version.Foreground = Brushes.Green;
                }
                else if (ParseDate(SVTAV1CurrentVersion) == ParseDate(SVTAV1UpdateVersion))
                {
                    // Both Versions are identical
                    LabelCurrentSVTAV1Version.Foreground = Brushes.Green;
                    LabelUpdateSVTAV1Version.Foreground = Brushes.Green;
                }
                else if (ParseDate(SVTAV1CurrentVersion) > ParseDate(SVTAV1UpdateVersion))
                {
                    // Local Version is newer
                    LabelCurrentSVTAV1Version.Foreground = Brushes.Green;
                    LabelUpdateSVTAV1Version.Foreground = Brushes.Red;
                }
            }
            else { LabelCurrentSVTAV1Version.Content = "unknown"; LabelCurrentSVTAV1Version.Foreground = Brushes.Red; }
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

private async void ButtonUpdateAomenc_Click(object sender, RoutedEventArgs e)
        {
            ToggleAllButtons(false);

            // Creates the aomenc folder if not existent
            if (!Directory.Exists(Path.Combine(CurrentDir, "Apps", "aomenc")))
                Directory.CreateDirectory(Path.Combine(CurrentDir, "Apps", "aomenc"));
            // Downloads aomenc
            await Task.Run(() => DownloadBin("https://jeremylee.sh/data/bin/aom.7z", Path.Combine(CurrentDir, "Apps", "aom.7z")));
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "aom.7z")))
            {
                // Extracts aomenc
                ExtractFile(Path.Combine(CurrentDir, "Apps", "aom.7z"), Path.Combine(Directory.GetCurrentDirectory(), "Apps", "aomenc"));
                // Writes the version to file
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.exe")))
                {
                    // Deletes aomdec
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "aomenc", "aomdec.exe")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "aomenc", "aomdec.exe"));
                    }
                    // Deletes txt file
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.txt")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.txt"));
                    }

                    File.WriteAllText(Path.Combine(CurrentDir, "Apps", "aomenc", "aomenc.txt"), AomencUpdateVersion);
                }
                // Deletes downloaded archive
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "aom.7z")))
                {
                    File.Delete(Path.Combine(CurrentDir, "Apps", "aom.7z"));
                }

                CompareLocalVersion();
            }

            ToggleAllButtons(true);

            LabelProgressBar.Dispatcher.Invoke(() => LabelProgressBar.Content = "Finished updating Aomenc");
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

private async void ButtonUpdateSVTAV1_Click(object sender, RoutedEventArgs e)
        {
            ToggleAllButtons(false);

            // Creates the svt-av1 folder if not existent
            if (!Directory.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1")))
            {
                Directory.CreateDirectory(Path.Combine(CurrentDir, "Apps", "svt-av1"));
            }
            // Downloads rav1e
            await Task.Run(() => DownloadBin("https://jeremylee.sh/data/bin/svt-av1.7z", Path.Combine(CurrentDir, "Apps", "svt-av1.7z")));
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1.7z")))
            {
                // Extracts rav1e
                ExtractFile(Path.Combine(CurrentDir, "Apps", "svt-av1.7z"), Path.Combine(Directory.GetCurrentDirectory(), "Apps", "svt-av1"));
                // Writes the version to file
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1", "SvtAv1EncApp.exe")))
                {
                    // Deletes SVT-AV1 Decoder
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1", "SvtAv1EncApp.exe")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "svt-av1", "SvtAv1DecApp.exe"));
                    }
                    // Deletes txt file
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1", "svt-av1.txt")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "svt-av1", "svt-av1.txt"));
                    }

                    File.WriteAllText(Path.Combine(CurrentDir, "Apps", "svt-av1", "svt-av1.txt"), SVTAV1UpdateVersion);
                }
                // Deletes downloaded archive
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "svt-av1.7z")))
                {
                    File.Delete(Path.Combine(CurrentDir, "Apps", "svt-av1.7z"));
                }

                CompareLocalVersion();
            }

            ToggleAllButtons(true);

            LabelProgressBar.Dispatcher.Invoke(() => LabelProgressBar.Content = "Finished updating SVT-AV1");
        }

19 Source : DataManager.cs
with MIT License
from alkampfergit

public static String GetTemplateFolder(String templateName)
        {
            return Path.Combine(TestContext.CurrentContext.TestDirectory, "Data", "Templates", templateName);
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

private async void ButtonUpdateRav1e_Click(object sender, RoutedEventArgs e)
        {
            ToggleAllButtons(false);

            // Creates the rav1e folder if not existent
            if (!Directory.Exists(Path.Combine(CurrentDir, "Apps", "rav1e")))
                Directory.CreateDirectory(Path.Combine(CurrentDir, "Apps", "rav1e"));
            // Downloads rav1e
            await Task.Run(() => DownloadBin("https://jeremylee.sh/data/bin/rav1e.7z", Path.Combine(CurrentDir, "Apps", "rav1e.7z")));
            if (File.Exists(Path.Combine(CurrentDir, "Apps", "rav1e.7z")))
            {
                // Extracts rav1e
                ExtractFile(Path.Combine(CurrentDir, "Apps", "rav1e.7z"), Path.Combine(Directory.GetCurrentDirectory(), "Apps", "rav1e"));
                // Writes the version to file
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.exe")))
                {
                    // Deletes txt file
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.txt")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.txt"));
                    }

                    File.WriteAllText(Path.Combine(CurrentDir, "Apps", "rav1e", "rav1e.txt"), Rav1eUpdateVersion);
                }
                // Deletes downloaded archive
                if (File.Exists(Path.Combine(CurrentDir, "Apps", "rav1e.7z")))
                {
                    File.Delete(Path.Combine(CurrentDir, "Apps", "rav1e.7z"));
                }

                CompareLocalVersion();
            }

            ToggleAllButtons(true);

            LabelProgressBar.Dispatcher.Invoke(() => LabelProgressBar.Content = "Finished updating Rav1e");
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

public void ExtractFile(string source, string destination)
        {
            // Extracts the downloaded archives with 7zip
            string zPath = Path.Combine(CurrentDir, "Apps", "7zip", "7za.exe");
            // change the path and give yours
            try
            {
                ProcessStartInfo pro = new ProcessStartInfo
                {
                    WindowStyle = ProcessWindowStyle.Hidden,
                    FileName = zPath,
                    Arguments = "x \"" + source + "\" -aoa -o" + '\u0022' + destination + '\u0022'
                };
                Process x = Process.Start(pro);
                x.WaitForExit();
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

19 Source : CheckDependencies.cs
with MIT License
from Alkl58

public static void Check()
        {
            // Sets / Checks ffmpeg Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "ffmpeg", "ffmpeg.exe")))
            {
                Global.FFmpeg_Path = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "ffmpeg");
            }
            else if (ExistsOnPath("ffmpeg.exe"))
            {
                Global.FFmpeg_Path = GetFullPathWithOutName("ffmpeg.exe");
            }
            else
            {
                Global.FFmpeg_Path = null;
            }

            // Sets / Checks mkvtoolnix Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "mkvtoolnix", "mkvmerge.exe")))
            {
                Global.MKVToolNix_Path = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "mkvtoolnix");
            }
            else if (ExistsOnPath("mkvmerge.exe"))
            {
                Global.MKVToolNix_Path = GetFullPathWithOutName("mkvmerge.exe");
            }
            else if (File.Exists(@"C:\Program Files\MKVToolNix\mkvmerge.exe"))
            {
                Global.MKVToolNix_Path = @"C:\Program Files\MKVToolNix\";
            }
            else
            {
                Global.MKVToolNix_Path = null;
            }

            // Checks if PySceneDetect is found in the Windows PATH environment
            if (ExistsOnPath("scenedetect.exe")) { MainWindow.PySceneFound = true; }

            NotifyUser();
        }

19 Source : Updater.xaml.cs
with MIT License
from Alkl58

private async void ButtonUpdateFFmpeg_Click(object sender, RoutedEventArgs e)
        {
            ToggleAllButtons(false);

            // Creates the ffmpeg folder if not existent
            if (!Directory.Exists(Path.Combine(CurrentDir, "Apps", "ffmpeg")))
            {
                Directory.CreateDirectory(Path.Combine(CurrentDir, "Apps", "ffmpeg"));
            }

            // Downloads ffmpeg
            await Task.Run(() => DownloadBin("https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z", Path.Combine(CurrentDir, "Apps", "ffmpeg-git-full.7z")));

            if (File.Exists(Path.Combine(CurrentDir, "Apps", "ffmpeg-git-full.7z")))
            {
                // Extracts ffmpeg
                ExtractFile(Path.Combine(CurrentDir, "Apps", "ffmpeg-git-full.7z"), Path.Combine(Directory.GetCurrentDirectory(), "Apps", "ffmpeg"));

                if (File.Exists(Path.Combine(CurrentDir, "Apps", "ffmpeg", Git_FFmpeg_Name, "bin", "ffmpeg.exe")))
                {
                    if (File.Exists(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.exe")))
                    {
                        File.Delete(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.txt"));
                        File.Delete(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.exe"));
                    }

                    File.Move(Path.Combine(CurrentDir, "Apps", "ffmpeg", Git_FFmpeg_Name, "bin", "ffmpeg.exe"), Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.exe"));

                    File.WriteAllText(Path.Combine(CurrentDir, "Apps", "ffmpeg", "ffmpeg.txt"), FFmpegUpdateVersion);

                    File.Delete(Path.Combine(CurrentDir, "Apps", "ffmpeg-git-full.7z"));
                    Directory.Delete(Path.Combine(CurrentDir, "Apps", "ffmpeg", Git_FFmpeg_Name), true);

                    CompareLocalVersion();
                }
            }

            ToggleAllButtons(true);

            LabelProgressBar.Dispatcher.Invoke(() => LabelProgressBar.Content = "Finished updating FFmpeg");
        }

19 Source : DatabasePath.cs
with MIT License
from almirvuk

public string GetDbPath() {
            return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDoreplacedents), "..", "Library", "EFCoreDB.db");
        }

19 Source : TestDataUtil.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

private static string GetApplicationPath(string org, string app)
        {
            string unitTestFolder = Path.GetDirectoryName(new Uri(typeof(InstanceMockSI).replacedembly.Location).LocalPath);
            return Path.Combine(unitTestFolder, @"..\..\..\Data\apps\", org + @"\", app + @"\config\applicationmetadata.json");
        }

19 Source : TestDataUtil.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

private static string GetInstancePath(int instanceOwnerId, Guid instanceGuid)
        {
            string unitTestFolder = Path.GetDirectoryName(new Uri(typeof(TestDataUtil).replacedembly.Location).LocalPath);
            return Path.Combine(
                unitTestFolder,
                @"..\..\..\data\cosmoscollections\instances\",
                instanceOwnerId.ToString(),
                instanceGuid + @".json");
        }

19 Source : TestDataHelper.cs
with BSD 3-Clause "New" or "Revised" License
from Altinn

public async static Task<string> CopyRepositoryForTest(string org, string repository, string developer, string targetRepsository)
        {
            var sourceAppRepository = GetTestDataRepositoryDirectory(org, repository, developer);
            var targetDirectory = Path.Combine(GetTestDataRepositoriesRootDirectory(), developer, org, targetRepsository);

            await CopyDirectory(sourceAppRepository, targetDirectory);

            return targetDirectory;
        }

19 Source : LibraryLoader.cs
with MIT License
from amerkoleci

public static IntPtr LoadLibrary(string libraryName)
        {
            if (!libraryName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase))
                libraryName += Extension;


            var osPlatform = GetOSPlatform();
            var architecture = GetArchitecture();

            var libraryPath = GetNativereplacedemblyPath(osPlatform, architecture, libraryName);

            static string GetOSPlatform()
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    return "win";
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    return "linux";
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                    return "osx";

                throw new ArgumentException("Unsupported OS platform.");
            }

            static string GetArchitecture()
            {
                switch (RuntimeInformation.ProcessArchitecture)
                {
                    case Architecture.X86: return "x86";
                    case Architecture.X64: return "x64";
                    case Architecture.Arm: return "arm";
                    case Architecture.Arm64: return "arm64";
                }

                throw new ArgumentException("Unsupported architecture.");
            }

            static string GetNativereplacedemblyPath(string osPlatform, string architecture, string libraryName)
            {
                var replacedemblyLocation = Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location);

                string[] paths = new[]
                {
                    Path.Combine(replacedemblyLocation, libraryName),
                    Path.Combine(replacedemblyLocation, "runtimes", osPlatform, "native", libraryName),
                    Path.Combine(replacedemblyLocation, "runtimes", $"{osPlatform}-{architecture}", "native", libraryName),
                    Path.Combine(replacedemblyLocation, "native", $"{osPlatform}-{architecture}", libraryName),
                };

                foreach (string path in paths)
                {
                    if (File.Exists(path))
                    {
                        return path;
                    }
                }

                return libraryName;
            }

            IntPtr handle;
#if !NET5_0_OR_GREATER
            handle = LoadPlatformLibrary(libraryPath);
#else
            handle = NativeLibrary.Load(libraryPath);
#endif

            if (handle == IntPtr.Zero)
                throw new DllNotFoundException($"Unable to load library '{libraryName}'.");

            return handle;
        }

19 Source : LibraryLoader.cs
with MIT License
from amerkoleci

public static IntPtr LoadLocalLibrary(string libraryName)
        {
            if (!libraryName.EndsWith(Extension, StringComparison.OrdinalIgnoreCase))
                libraryName += Extension;


            var osPlatform = GetOSPlatform();
            var architecture = GetArchitecture();

            var libraryPath = GetNativereplacedemblyPath(osPlatform, architecture, libraryName);

            static string GetOSPlatform()
            {
                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                    return "win";
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    return "linux";
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
                    return "osx";

                throw new ArgumentException("Unsupported OS platform.");
            }

            static string GetArchitecture()
            {
                switch (RuntimeInformation.ProcessArchitecture)
                {
                    case Architecture.X86: return "x86";
                    case Architecture.X64: return "x64";
                    case Architecture.Arm: return "arm";
                    case Architecture.Arm64: return "arm64";
                }

                throw new ArgumentException("Unsupported architecture.");
            }

            static string GetNativereplacedemblyPath(string osPlatform, string architecture, string libraryName)
            {
                var replacedemblyLocation = Path.GetDirectoryName(replacedembly.GetExecutingreplacedembly().Location);

                string[] paths = new[]
                {
                    Path.Combine(replacedemblyLocation, libraryName),
                    Path.Combine(replacedemblyLocation, "runtimes", osPlatform, "native", libraryName),
                    Path.Combine(replacedemblyLocation, "runtimes", $"{osPlatform}-{architecture}", "native", libraryName),
                    Path.Combine(replacedemblyLocation, "native", $"{osPlatform}-{architecture}", libraryName),
                };

                foreach (string path in paths)
                {
                    if (File.Exists(path))
                    {
                        return path;
                    }
                }

                return libraryName;
            }

            IntPtr handle;
#if !NET5_0_OR_GREATER
            handle = LoadPlatformLibrary(libraryPath);
#else
            handle = NativeLibrary.Load(libraryPath);
#endif

            if (handle == IntPtr.Zero)
                throw new DllNotFoundException($"Unable to load library '{libraryName}'.");

            return handle;
        }

19 Source : KernelManager.cs
with MIT License
from andreaschiavinato

public string StartKernel(string sessionId, string kernelName)
        {
            _kernelSpec = KernelSpecs.kernelspecs[kernelName];

            var connectionFile = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "jupyter",
                "runtime",
                sessionId + ".json");
            
            var kernelExe = _kernelSpec.spec.argv[0];
            var kernalArgs = _kernelSpec.spec.argv
                .Skip(1)
                .Aggregate(string.Empty, (a, b) => a + " " + b)
                .Replace("{connection_file}", connectionFile);
            
            _kernelProcess = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName = kernelExe,
                    Arguments = kernalArgs,
                    UseShellExecute = false,
                    RedirectStandardOutput = false,
                    RedirectStandardInput = true,
                    CreateNoWindow = true
                }
            };

            _kernelProcess.Start();
            
            WaitConnectionFileWritten(connectionFile);
            return connectionFile;
        }

19 Source : RoadSearchHelperTests.cs
with MIT License
from AnnoDesigner

private string GetTestDataFile(string testCase)
        {
            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestData", "RoadSearchHelper", $"{testCase}.ad");
        }

19 Source : FileUtils.cs
with MIT License
from AntonyCorbett

public static string GetUserOptionsFilePath(int optionsVersion)
        {
            return Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                AppNamePathSegment,
                optionsVersion.ToString(),
                OptionsFileName);
        }

19 Source : FileUtils.cs
with MIT License
from AntonyCorbett

public static string GetUserOptionsFilePath(int optionsVersion)
        {
            return Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                ThemeCreatorAppNamePathSegment,
                optionsVersion.ToString(),
                OptionsFileName);
        }

19 Source : DebugMethodCmd.cs
with MIT License
from arasplm

public override void ExecuteCommandImpl(object sender, EventArgs args)
		{
			var project = projectManager.SelectedProject;

			EnvDTE.Configuration config = project.ConfigurationManager.ActiveConfiguration;
			EnvDTE.Properties props = config.Properties;

			var outputPath = props.Item("OutputPath");
			var dllFullPath = Path.Combine(project.Properties.Item("FullPath").Value.ToString(), outputPath.Value.ToString(), project.Properties.Item("OutputFileName").Value.ToString());
			var selectedMethodName = projectManager.MethodName;

			string projectConfigPath = projectManager.ProjectConfigPath;

			MethodInfo methodInformation = projectConfigurationManager.CurrentProjectConfiguraiton.MethodInfos.FirstOrDefault(m => m.MethodName == selectedMethodName);

			string selectedMethodPath = projectManager.MethodPath;
			string sourceCode = File.ReadAllText(selectedMethodPath, new UTF8Encoding(true));

			var tree = CSharpSyntaxTree.ParseText(sourceCode);
			SyntaxNode root = tree.GetRoot();
			var member = root.DescendantNodes()
				.OfType<NamespaceDeclarationSyntax>()
				.FirstOrDefault();
			var clreplacedName = GetFullClreplacedName(member);
			var methodName = GetMethodName(member);

			//(me as IdentifierNameSyntax).Identifier.ValueText

			//var selectedClreplacedName =
			//ProjectConfiguraiton projectConfiguration = projectConfigurationManager.Load(projectConfigPath);
			projectManager.ExecuteCommand("Build.BuildSolution");

			var currentDllPath = System.Reflection.replacedembly.GetExecutingreplacedembly().Location;
			var directoryPath = Path.GetDirectoryName(currentDllPath);
			var launcherPath = Path.Combine(directoryPath, "MethodLauncher", "MethodLauncher.exe");
			string netCoreLauncherPath = Path.Combine(directoryPath, "MethodLauncherNetCore", "netcoreapp3.1", "MethodLauncherNetCore.exe");

			string projectType = project.Properties.Item("TargetFrameworkMoniker")?.Value?.ToString();
			bool isNetCoreProject = projectType.Contains(".NETCoreApp");
			if (isNetCoreProject)
			{
				launcherPath = netCoreLauncherPath;
			}

			string packageMethodFolderPath = this.projectConfigurationManager.CurrentProjectConfiguraiton.UseCommonProjectStructure ? methodInformation.Package.MethodFolderPath : string.Empty;
			string methodWorkingFolder = Path.Combine(projectManager.ServerMethodFolderPath, packageMethodFolderPath, methodInformation.MethodName);
			ICodeProvider codeProvider = codeProviderFactory.GetCodeProvider(projectManager.Language);

			string methodCode = codeProvider.LoadMethodCode(methodWorkingFolder, sourceCode);

			var debugMethodView = dialogFactory.GetDebugMethodView(projectConfigurationManager, methodInformation, methodCode, projectConfigPath, project.Name, project.FullName);
			var debugMethodViewResult = debugMethodView.ShowDialog();
			if (debugMethodViewResult?.DialogOperationResult != true)
			{
				return;
			}

			string projectDirectoryPath = Path.GetDirectoryName(projectManager.SelectedProject.FileName);
			string launcherConfigPath = Path.Combine(projectDirectoryPath, "LauncherConfig.xml");

			CreateLauncherConfigFile(dllFullPath, clreplacedName, methodName, debugMethodViewResult, launcherConfigPath,
				CommonData.EventSpecificDataTypeList.FirstOrDefault(ev => ev.EventSpecificData.ToString() == methodInformation.EventData.ToString()).EventDataClreplaced, methodInformation.TemplateName);

			ProcessStartInfo startInfo = new ProcessStartInfo(launcherPath);
			startInfo.WindowStyle = ProcessWindowStyle.Hidden;
			startInfo.Arguments = launcherConfigPath + " " + authManager.InnovatorUser.preplacedwordHash;

			Process process = Process.Start(startInfo);

			projectManager.AttachToProcess(process);
		}

19 Source : CryptoUtils.cs
with GNU Affero General Public License v3.0
from arklumpus

public static void AddPublicKey(RSAParameters publicKey)
        {
            FilePublicKeys.Add(publicKey);

            List<PublicKeyHolder> holders = (from el in FilePublicKeys select new PublicKeyHolder(el)).ToList();

            string tempFile = Path.GetTempFileName();
            File.WriteAllText(tempFile, JsonSerializer.Serialize<List<PublicKeyHolder>>(holders, Modules.DefaultSerializationOptions));

            ModuleUtils.CopyFiles(new[] { (tempFile, Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "TreeViewer", "Keys", "publicKeys.json")) });
        }

19 Source : Factorio.cs
with GNU General Public License v3.0
from Artentus

private static bool TryLoadExecutable(DirectoryInfo directory, out FileInfo executable)
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                executable = new FileInfo(Path.Combine(directory.FullName, "bin", "x64", "factorio.exe"));
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                executable = new FileInfo(Path.Combine(directory.FullName, "bin", "x64", "factorio"));
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                executable = new FileInfo(Path.Combine(directory.FullName, "MacOS", "factorio"));
            }
            else
            {
                throw new PlatformNotSupportedException();
            }

            return executable.Exists;
        }

19 Source : Options.xaml.cs
with MIT License
from Assistant

private void OpenAppDataButton_Click(object sender, RoutedEventArgs e)
        {
            string location = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                "AppData", "LocalLow", "Hyperbolic Magnetism");
            if (Directory.Exists(location))
            {
                Utils.OpenFolder(location);
            }
            else
            {
                MessageBox.Show((string)Application.Current.FindResource("Options:AppDataNotFound"));
            }
        }

19 Source : Utils.cs
with MIT License
from Assistant

public static string GetSteamDir()
        {

            string SteamInstall = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)?.OpenSubKey("SOFTWARE")?.OpenSubKey("WOW6432Node")?.OpenSubKey("Valve")?.OpenSubKey("Steam")?.GetValue("InstallPath").ToString();
            if (string.IsNullOrEmpty(SteamInstall))
            {
                SteamInstall = Registry.LocalMachine.OpenSubKey("SOFTWARE")?.OpenSubKey("WOW6432Node")?.OpenSubKey("Valve")?.OpenSubKey("Steam")?.GetValue("InstallPath").ToString();
            }

            if (string.IsNullOrEmpty(SteamInstall)) return null;

            string vdf = Path.Combine(SteamInstall, @"steamapps\libraryfolders.vdf");
            if (!File.Exists(@vdf)) return null;

            Regex regex = new Regex("\\s\"(?:\\d|path)\"\\s+\"(.+)\"");
            List<string> SteamPaths = new List<string>
            {
                Path.Combine(SteamInstall, @"steamapps")
            };

            using (StreamReader reader = new StreamReader(@vdf))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    Match match = regex.Match(line);
                    if (match.Success)
                    {
                        SteamPaths.Add(Path.Combine(match.Groups[1].Value.Replace(@"\\", @"\"), @"steamapps"));
                    }
                }
            }

            regex = new Regex("\\s\"installdir\"\\s+\"(.+)\"");
            foreach (string path in SteamPaths)
            {
                if (File.Exists(Path.Combine(@path, @"appmanifest_" + Constants.BeatSaberAPPID + ".acf")))
                {
                    using (StreamReader reader = new StreamReader(Path.Combine(@path, @"appmanifest_" + Constants.BeatSaberAPPID + ".acf")))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            Match match = regex.Match(line);
                            if (match.Success)
                            {
                                if (File.Exists(Path.Combine(@path, @"common", match.Groups[1].Value, "Beat Saber.exe")))
                                {
                                    return SetDir(Path.Combine(@path, @"common", match.Groups[1].Value), "Steam");
                                }
                            }
                        }
                    }
                }
            }
            return null;
        }

19 Source : Utils.cs
with MIT License
from Assistant

public static string GetOculusDir()
        {
            string OculusInstall = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)?.OpenSubKey("SOFTWARE")?.OpenSubKey("Wow6432Node")?.OpenSubKey("Oculus VR, LLC")?.OpenSubKey("Oculus")?.OpenSubKey("Config")?.GetValue("InitialAppLibrary").ToString();
            if (string.IsNullOrEmpty(OculusInstall)) return null;

            if (!string.IsNullOrEmpty(OculusInstall))
            {
                if (File.Exists(Path.Combine(OculusInstall, "Software", "hyperbolic-magnetism-beat-saber", "Beat Saber.exe")))
                {
                    return SetDir(Path.Combine(OculusInstall, "Software", "hyperbolic-magnetism-beat-saber"), "Oculus");
                }
            }

            // Yoinked this code from Umbranox's Mod Manager. Lot's of thanks and love for Umbra <3
            using (RegistryKey librariesKey = Registry.CurrentUser.OpenSubKey("Software")?.OpenSubKey("Oculus VR, LLC")?.OpenSubKey("Oculus")?.OpenSubKey("Libraries"))
            {
                // Oculus libraries uses GUID volume paths like this "\\?\Volume{0fea75bf-8ad6-457c-9c24-cbe2396f1096}\Games\Oculus Apps", we need to transform these to "D:\Game"\Oculus Apps"
                WqlObjectQuery wqlQuery = new WqlObjectQuery("SELECT * FROM Win32_Volume");
                using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(wqlQuery))
                {
                    Dictionary<string, string> guidLetterVolumes = new Dictionary<string, string>();

                    foreach (ManagementBaseObject disk in searcher.Get())
                    {
                        var diskId = ((string)disk.GetPropertyValue("DeviceID")).Substring(11, 36);
                        var diskLetter = ((string)disk.GetPropertyValue("DriveLetter")) + @"\";

                        if (!string.IsNullOrWhiteSpace(diskLetter))
                        {
                            guidLetterVolumes.Add(diskId, diskLetter);
                        }
                    }

                    // Search among the library folders
                    foreach (string libraryKeyName in librariesKey.GetSubKeyNames())
                    {
                        using (RegistryKey libraryKey = librariesKey.OpenSubKey(libraryKeyName))
                        {
                            string libraryPath = (string)libraryKey.GetValue("Path");
                            // Yoinked this code from Megalon's fix. <3
                            string GUIDLetter = guidLetterVolumes.FirstOrDefault(x => libraryPath.Contains(x.Key)).Value;
                            if (!string.IsNullOrEmpty(GUIDLetter))
                            {
                                string finalPath = Path.Combine(GUIDLetter, libraryPath.Substring(49), @"Software\hyperbolic-magnetism-beat-saber");
                                if (File.Exists(Path.Combine(finalPath, "Beat Saber.exe")))
                                {
                                    return SetDir(finalPath, "Oculus");
                                }
                            }
                        }
                    }
                }
            }

            return null;
        }

19 Source : Utils.cs
with MIT License
from Assistant

public static string GetManualDir()
        {
            var dialog = new SaveFileDialog()
            {
                replacedle = (string)Application.Current.FindResource("Utils:InstallDir:Dialogreplacedle"),
                Filter = "Directory|*.this.directory",
                FileName = "select"
            };

            if (dialog.ShowDialog() == true)
            {
                string path = dialog.FileName;
                path = path.Replace("\\select.this.directory", "");
                path = path.Replace(".this.directory", "");
                path = path.Replace("\\select.directory", "");
                if (File.Exists(Path.Combine(path, "Beat Saber.exe")))
                {
                    string store;
                    if (File.Exists(Path.Combine(path, "Beat Saber_Data", "Plugins", "steam_api64.dll"))
                       || File.Exists(Path.Combine(path, "Beat Saber_Data", "Plugins", "x86_64", "steam_api64.dll")))
                    {
                        store = "Steam";
                    }
                    else
                    {
                        store = "Oculus";
                    }
                    return SetDir(path, store);
                }
            }
            return null;
        }

19 Source : ModHandler.cs
with MIT License
from AstroTechies

private string CheckSteamPathForGame(int appID, string steamPath)
        {
            try
            {
                if (!Directory.Exists(steamPath)) return null;
                using (StreamReader f = new StreamReader(Path.Combine(steamPath, "steamapps", "appmanifest_" + appID + ".acf")))
                {
                    string acfEntry = null;
                    while ((acfEntry = f.ReadLine()) != null)
                    {
                        Match m = acfEntryReader.Match(acfEntry);
                        if (m.Groups.Count == 3 && m.Groups[1].Value == "installdir")
                        {
                            string astroInstallDir = m.Groups[2].Value;
                            if (!string.IsNullOrEmpty(astroInstallDir))
                            {
                                string decidedAnswer = Path.Combine(steamPath, "steamapps", "common", astroInstallDir);
                                if (!Directory.Exists(decidedAnswer)) return null;
                                return decidedAnswer;
                            }
                        }
                    }
                }
            }
            catch (IOException)
            {
                return null;
            }
            return null;
        }

19 Source : Installer.cs
with MIT License
from Astropilot

private string FindValheimGameInSteamPath(string steamPath)
        {
            var appManifestPath = Path.Combine(steamPath, "steamapps", "appmanifest_892970.acf");

            if (File.Exists(appManifestPath))
            {
                return Path.Combine(steamPath, "steamapps", "common", "Valheim");
            }
            return null;
        }

19 Source : ModHandler.cs
with MIT License
from AstroTechies

public void IntegrateMods()
        {
            if (IsReadOnly || GamePath == null || InstallPath == null) return;

            List<string> optionalMods = new List<string>();
            foreach (Mod mod in Mods)
            {
                if (mod.Enabled && mod.IsOptional) optionalMods.Add(mod.CurrentModData.ModID);
            }

            if (TableHandler.ShouldContainOptionalColumn()) OurIntegrator.OptionalModIDs = optionalMods;
            OurIntegrator.IntegrateMods(InstallPath, Path.Combine(GamePath, "Astro", "Content", "Paks"));
        }

19 Source : ModHandler.cs
with MIT License
from AstroTechies

public string GetGamePathFromBasePath(string basePath)
        {
            ModConfig diskConfig = null;
            try
            {
                diskConfig = JsonConvert.DeserializeObject<ModConfig>(File.ReadAllText(Path.Combine(basePath, "Saved", "Mods", "modconfig.json")));
            }
            catch
            {
                diskConfig = null;
            }

            return diskConfig?.GamePath;
        }

19 Source : BuildCodeBusiness.cs
with MIT License
from awesomedotnetcore

public void Build(BuildInputDTO input)
        {
            string linkId = input.linkId;
            string areaName = input.areaName;
            List<string> tables = input.tables;
            List<int> buildTypes = input.buildTypes;
            _areaName = areaName;
            //内部成员初始化
            _dbHelper = GetTheDbHelper(linkId);
            GetDbTableList(linkId).ForEach(aTable =>
            {
                _dbTableInfoDic.Add(aTable.TableName, aTable);
            });

            tables.ForEach(aTable =>
            {
                var tableFieldInfo = _dbHelper.GetDbTableInfo(aTable);

                //实体名
                string enreplacedyName = aTable;
                //业务逻辑参数名
                string busName = $"{enreplacedyName.ToFirstLowerStr()}Bus";
                //业务逻辑变量名
                string _busName = $"_{busName}";
                List<string> selectOptionsList = new List<string>();
                List<string> listColumnsList = new List<string>();
                List<string> formColumnsList = new List<string>();
                tableFieldInfo.Where(x => !ignoreProperties.Contains(x.Name)).ToList().ForEach(aField =>
                {
                    if (_dbHelper.DbTypeStr_To_CsharpType(aField.Type) == typeof(string))
                        selectOptionsList.Add(
$"                <a-select-option key=\"{aField.Name}\">{aField.Description}</a-select-option>");
                    listColumnsList.Add(
$"  {{ replacedle: '{aField.Description}', dataIndex: '{aField.Name}', width: '10%' }},");
                    formColumnsList.Add(
$@"        <a-form-model-item label=""{aField.Description}"" prop=""{aField.Name}"">
          <a-input v-model=""enreplacedy.{aField.Name}"" autocomplete=""off"" />
        </a-form-model-item>");
                    Dictionary<string, string> renderParamters = new Dictionary<string, string>
                    {
                        {$"%{nameof(areaName)}%",areaName },
                        {$"%{nameof(enreplacedyName)}%",enreplacedyName },
                        {$"%{nameof(busName)}%",busName },
                        {$"%{nameof(_busName)}%",_busName },
                        {$"%selectOptions%",string.Join("\r\n",selectOptionsList) },
                        {$"%listColumns%",string.Join("\r\n",listColumnsList) },
                        {$"%formColumns%",string.Join("\r\n",formColumnsList) }
                    };

                    //buildTypes,实体层=0,业务层=1,接口层=2,页面层=3
                    //实体层
                    if (buildTypes.Contains(0))
                    {
                        BuildEnreplacedy(tableFieldInfo, aTable);
                    }
                    string tmpFileName = string.Empty;
                    string savePath = string.Empty;
                    //业务层
                    if (buildTypes.Contains(1))
                    {
                        //接口
                        tmpFileName = "IBusiness.txt";
                        savePath = Path.Combine(
                            _solutionPath,
                            "Coldairarrow.IBusiness",
                            areaName,
                            $"I{enreplacedyName}Business.cs");
                        WriteCode(renderParamters, tmpFileName, savePath);

                        //实现
                        tmpFileName = "Business.txt";
                        savePath = Path.Combine(
                            _solutionPath,
                            "Coldairarrow.Business",
                            areaName,
                            $"{enreplacedyName}Business.cs");
                        WriteCode(renderParamters, tmpFileName, savePath);
                    }
                    //接口层
                    if (buildTypes.Contains(2))
                    {
                        tmpFileName = "Controller.txt";
                        savePath = Path.Combine(
                            _solutionPath,
                            "Coldairarrow.Api",
                            "Controllers",
                            areaName,
                            $"{enreplacedyName}Controller.cs");
                        WriteCode(renderParamters, tmpFileName, savePath);
                    }
                    //页面层
                    if (buildTypes.Contains(3))
                    {
                        //表格页
                        tmpFileName = "List.txt";
                        savePath = Path.Combine(
                            _solutionPath,
                            "Coldairarrow.Web",
                            "src",
                            "views",
                            areaName,
                            enreplacedyName,
                            "List.vue");
                        WriteCode(renderParamters, tmpFileName, savePath);

                        //表单页
                        tmpFileName = "EditForm.txt";
                        savePath = Path.Combine(
                            _solutionPath,
                            "Coldairarrow.Web",
                            "src",
                            "views",
                            areaName,
                            enreplacedyName,
                            "EditForm.vue");
                        WriteCode(renderParamters, tmpFileName, savePath);
                    }
                });
            });
        }

19 Source : BuildCodeBusiness.cs
with MIT License
from awesomedotnetcore

private void BuildEnreplacedy(List<TableInfo> tableInfo, string tableName)
        {
            string nameSpace = $@"Coldairarrow.Enreplacedy.{_areaName}";
            string filePath = Path.Combine(_solutionPath, "Coldairarrow.Enreplacedy", _areaName, $"{tableName}.cs");

            _dbHelper.SaveEnreplacedyToFile(tableInfo, tableName, _dbTableInfoDic[tableName].Description, filePath, nameSpace);
        }

19 Source : BuildCodeBusiness.cs
with MIT License
from awesomedotnetcore

private void WriteCode(Dictionary<string, string> paramters, string templateFileName, string savePath)
        {
            string tmpFileText = File.ReadAllText(Path.Combine(_solutionPath, "Coldairarrow.Api", "BuildCodeTemplate", templateFileName));
            paramters.ForEach(aParamter =>
            {
                tmpFileText = tmpFileText.Replace(aParamter.Key, aParamter.Value);
            });
            FileHelper.WriteTxt(tmpFileText, savePath, Encoding.UTF8, FileMode.Create);
        }

19 Source : Utilities.cs
with Apache License 2.0
from aws

public static string DetermineBuildLocation(string workingDirectory, string projectLocation, string configuration, string targetFramework)
        {
            var path = Path.Combine(
                DetermineProjectLocation(workingDirectory, projectLocation),
                "bin",
                configuration,
                targetFramework);
            return path;
        }

19 Source : FlattenDependencyTests.cs
with Apache License 2.0
from aws

private ZipArchive GetNugetZip(string package, string version)
        {
            var packagesFolderPath =
                RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                    ? "%UserProfile%\\.nuget\\packages"
                    : @"%HOME%/.nuget/packages";

            var packageFileName = package + "." + version + ".nupkg";
            var packagePath = Path.Combine(Environment.ExpandEnvironmentVariables(packagesFolderPath), package, version, packageFileName);

            if (!File.Exists(packagePath))
            {
                throw new InvalidOperationException($"{nameof(packagePath)} {packagePath} is not found");
            }

            return ZipFile.OpenRead(packagePath);
        }

19 Source : XmlOverridesMerger.cs
with Apache License 2.0
from aws

public static Dictionary<string, XmlElement> ReadOverrides(string folderPath, out string errorMessage)
        {
            errorMessage = null;
            var fileName = Path.Combine(folderPath, "overrides.xml");

            if (!File.Exists(fileName))
            {
                return new Dictionary<string, XmlElement>();
            }

            var schemaFileName = Path.Combine(folderPath, "XmlSchemas", "ConfigurationOverrides", "overrides.xsd");

            var validationMessages = new StringBuilder();
            bool hasErrors = false;
            try
            {
                var settings = new XmlReaderSettings();
                settings.Schemas.Add(null, schemaFileName);
                settings.ValidationType = ValidationType.Schema;                
                settings.ValidationEventHandler += new ValidationEventHandler((sender, e) =>
                {
                    hasErrors = hasErrors || e.Severity == XmlSeverityType.Error;
                    validationMessages.AppendLine($"{e.Severity}: {e.Message}");                    
                });

                var reader = XmlReader.Create(fileName, settings);
                var doreplacedent = new XmlDoreplacedent();
                doreplacedent.Load(reader);
                                
                if (hasErrors)
                {                    
                    errorMessage = $"Override file schema validation failed. The following errors need to be corrected:{Environment.NewLine}{validationMessages}";
                    return new Dictionary<string, XmlElement>();
                }

                return doreplacedent.DoreplacedentElement.ChildNodes
                    .OfType<XmlElement>()
                    .ToDictionary(serviceElement => GetChildElementsByTagName(serviceElement, nameof(ConfigModel.C2jFilename)).Single().InnerText, serviceElement => serviceElement);
            }
            catch (Exception e)
            {
                errorMessage = $"Error deserializing the provided override file. {e.Message}";
                return new Dictionary<string, XmlElement>();
            }
        }

19 Source : UtilsTest.cs
with Apache License 2.0
from aws

[Test]
        public void Parse_Throws_Validation_Exception_When_Enum_Value_Is_Invalid()
        {
            var jsonFilePath = GetTstPath(Path.Combine("CTA.FeatureDetection.Tests", "Examples", "Templates", "test_file_with_nonexistent_feature_scope.json"));
            var jsonContent = File.ReadAllText(jsonFilePath);

            replacedert.Throws<Newtonsoft.Json.JsonException>(() => Utils.ValidateJsonObject(jsonContent, typeof(FeatureConfig)));
        }

19 Source : UtilsTest.cs
with Apache License 2.0
from aws

[Test]
        public void Parse_Throws_Validation_Exception_When_Required_Field_Is_Missing()
        {
            var jsonFilePath = GetTstPath(Path.Combine("CTA.FeatureDetection.Tests", "Examples", "Templates", "test_file_with_missing_feature_scope.json"));
            var jsonContent = File.ReadAllText(jsonFilePath);

            replacedert.Throws<Newtonsoft.Json.JsonException>(() => Utils.ValidateJsonObject(jsonContent, typeof(FeatureConfig)));
        }

See More Examples