Good day!
I have a collection in which the contents of the json file are entered. The file has two properties hash and url .
And there are two methods, one method displays hash from this collection,
the second method takes the url from this collection and displays the hash from the remote server. In simple language, output hash from a local file, and hash from a server (using url , which is taken from the collection).
I need to compare these hashs (remote and local) to identity. But I can not understand how I compare them.
Here is the code:
class RepoInfo : Process { public Uri url { get; set; } public string hash { get; set; } public string GetRemoteHashMethod(string url) { string repourl = Convert.ToString(url); var hash = Repository.ListRemoteReferences(repourl).FirstOrDefault() as SymbolicReference; return hash.Target.TargetIdentifier; } public void PrintLocalHashMethod() { Process GetHashFromFile = new Process(); var repos = GetHashFromFile.GetAllFromFile(); Console.WriteLine("LocalHash:"); foreach (var item in repos) { Console.WriteLine(item.hash); } } public void PrintRemoteHashMethod() { Process GetHashFromFile = new Process(); var repos = GetHashFromFile.GetAllFromFile(); Console.WriteLine("Remote Hash Commit: "); foreach (var item in repos) { RepoInfo PrintRemoteHash = new RepoInfo(); var PrintRemoteHashCommit = PrintRemoteHash.GetRemoteHashMethod(item.url.ToString()); Console.WriteLine(PrintRemoteHashCommit); } Console.WriteLine(); } } class Process { public IEnumerable<RepoInfo> GetAllFromFile() { StreamReader jsonfile = new StreamReader("repo.json"); string json = jsonfile.ReadToEnd(); IEnumerable<RepoInfo> repos = JsonConvert.DeserializeObject<IEnumerable<RepoInfo>>(json); return repos; } } class Program { static void Main(string[] args) { RepoInfo PrintRH = new RepoInfo(); PrintRH.PrintRemoteHashMethod(); RepoInfo PrintLH = new RepoInfo(); PrintLH.PrintLocalHashMethod(); Console.ReadKey(); } } The json file itself:
[ { "hash": "2abead42b6a632e29433b043b11d8eec156394b9", "url": "https://github.com/VladislavsGeidans/wikicar.git" }, { "hash": "bed322e3aa9cbcdeebac7a2d963c2e693a783c2a", "url": "https://github.com/OpenExoplanetCatalogue/open_exoplanet_catalogue.git" }, { "hash": "0cf7da012e23b64c8aadba49b051542d3d5f47ab", "url": "https://github.com/openaddresses/openaddresses.git" }, { "hash": "c798444a83795a5f245dc29ccd82872e61206ad5", "url": "https://github.com/GSA/data.git" }, { "hash": "a45c4cd79a127296acc32aaa8152ebfb49b20640", "url": "https://github.com/unitedstates/congress-legislators.git" }, { "hash": "e92bc448678ef499cfeabb3df93ea7adad47f747", "url": "https://github.com/APIs-guru/openapi-directory.git" } ]
RepoInfo printRH = new RepoInfo();ru.wikipedia.org/wiki/CamelCase - koks_rs