diff --git a/ConsoleApp1/Program.cs b/ConsoleApp1/Program.cs index e6a1962..f78f0bb 100644 --- a/ConsoleApp1/Program.cs +++ b/ConsoleApp1/Program.cs @@ -10,10 +10,34 @@ namespace ConsoleApp1 { + public class CTabble1 + { + + public string Key1 { set; get; } + public string Name1 { set; get; } + } + public class CTable2 + { + public string Key2 { set; get; } + public string Name2 { set; get; } + } class Program { static void Main(string[] args) { + List table1s = new List(); + table1s.Add(new CTabble1() { Key1 = "1", Name1 = "table1_1" }); + table1s.Add(new CTabble1() { Key1 = "2", Name1 = "table1_2" }); + table1s.Add(new CTabble1() { Key1 = "3", Name1 = "table1_3" }); + + List table2s = new List(); + table2s.Add(new CTable2() { Key2 = "1", Name2 = "table2_1" }); + table2s.Add(new CTable2() { Key2 = "1", Name2 = "table2_1" }); + table2s.Add(new CTable2() { Key2 = "2", Name2 = "table2_2" }); + table2s.Add(new CTable2() { Key2 = "3", Name2 = "table2_3" }); + + var table = table1s.Join(table2s, x => x.Key1, y => y.Key2, (x, y) => new { x, y }); + RegistryKey reg_32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32); RegistryKey reg_64 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); RegistryKey win_info = reg_64.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); @@ -32,6 +56,7 @@ static void Main(string[] args) List apps = new List(); apps.Join(apps, x => x.Name, y => y.Name, (x,y)=> new {x, y }, StringComparer.OrdinalIgnoreCase); apps.Add(new AppData() { Name = "WinFlash" }); + apps.Add(new AppData() { Name = "WinFlash" }); apps.Add(new AppData() { Name = "Dropbox 25 GB" }); apps.Add(new AppData() { Name = "AnyDes", IsOfficial = true }); //var apptest = apps.Join(apps, func=> { return true; }, (x, y) => new { x, y }); @@ -65,6 +90,8 @@ static void Main(string[] args) { bool hr = false; string dispay = reg.GetValue("DisplayName"); + string uninstall_ = reg.GetValue("Uninstall"); + string version = reg.GetValue("Version"); if (app.IsOfficial == true) { hr = string.IsNullOrEmpty(dispay) == false && app.Name.Contains(dispay); @@ -86,19 +113,19 @@ static void Main(string[] args) System.Diagnostics.Stopwatch sw = System.Diagnostics.Stopwatch.StartNew(); for(int i=0; i< runcount; i++) { - foreach (var oo in uninstall.GetSubKeyNames()) - { - RegistryKey subkey = uninstall.OpenSubKey(oo); - object obj = subkey.GetValue("DisplayName"); - //object obj1 = subkey.GetValue("UninstallString"); - //object obj2 = subkey.GetValue("DisplayVersion"); - //string displayname = subkey.GetValue("DisplayName") as string; - //System.Diagnostics.Trace.WriteLine(displayname); - subkey.Dispose(); - } - - - //existapps.ToList(); + //foreach (var oo in uninstall.GetSubKeyNames()) + //{ + // RegistryKey subkey = uninstall.OpenSubKey(oo); + // object obj = subkey.GetValue("DisplayName"); + // //object obj1 = subkey.GetValue("UninstallString"); + // //object obj2 = subkey.GetValue("DisplayVersion"); + // //string displayname = subkey.GetValue("DisplayName") as string; + // //System.Diagnostics.Trace.WriteLine(displayname); + // subkey.Dispose(); + //} + + + existapps.ToList(); } sw.Stop(); System.Diagnostics.Trace.WriteLine($"{sw.ElapsedMilliseconds/ runcount}"); diff --git a/QSoft.Reg/RegistryKeyEx.cs b/QSoft.Reg/RegistryKeyEx.cs index 1a39c5a..7961628 100644 --- a/QSoft.Reg/RegistryKeyEx.cs +++ b/QSoft.Reg/RegistryKeyEx.cs @@ -100,7 +100,7 @@ public static IEnumerable Join(this RegistryKey src, I public static IEnumerable Join(this RegistryKey src, IEnumerable inner, Func outerKeySelector, Func innerKeySelector, Func resultSelector) { string[] subkeynames = src.GetSubKeyNames(); - Dictionary dic = new Dictionary(); + //Dictionary> dic = new Dictionary>(); foreach (var subkeyname in subkeynames) { @@ -111,7 +111,15 @@ public static IEnumerable Join(this RegistryKey TKey key = innerKeySelector.Invoke(oo); if (key.Equals(key_reg) == true) { - dic.Add(reg, oo); + //if(dic.ContainsKey(reg) == true) + //{ + // dic[reg].Add(oo); + //} + //else + //{ + // dic.Add(reg, new List() { oo}); + //} + yield return resultSelector.Invoke(reg, oo); //yield break;