Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oven425 committed Feb 4, 2021
1 parent 7abdc5e commit 4394fd3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 15 deletions.
53 changes: 40 additions & 13 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CTabble1> table1s = new List<CTabble1>();
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<CTable2> table2s = new List<CTable2>();
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");
Expand All @@ -32,6 +56,7 @@ static void Main(string[] args)
List<AppData> apps = new List<AppData>();
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 });
Expand Down Expand Up @@ -65,6 +90,8 @@ static void Main(string[] args)
{
bool hr = false;
string dispay = reg.GetValue<string>("DisplayName");
string uninstall_ = reg.GetValue<string>("Uninstall");
string version = reg.GetValue<string>("Version");
if (app.IsOfficial == true)
{
hr = string.IsNullOrEmpty(dispay) == false && app.Name.Contains(dispay);
Expand All @@ -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}");
Expand Down
12 changes: 10 additions & 2 deletions QSoft.Reg/RegistryKeyEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static IEnumerable<TResult> Join<TInner, TResult>(this RegistryKey src, I
public static IEnumerable<TResult> Join<TInner, TKey, TResult>(this RegistryKey src, IEnumerable<TInner> inner, Func<RegistryKey, TKey> outerKeySelector, Func<TInner, TKey> innerKeySelector, Func<RegistryKey, TInner, TResult> resultSelector)
{
string[] subkeynames = src.GetSubKeyNames();
Dictionary<RegistryKey, TInner> dic = new Dictionary<RegistryKey, TInner>();
//Dictionary<RegistryKey, List<TInner>> dic = new Dictionary<RegistryKey, List<TInner>>();
foreach (var subkeyname in subkeynames)
{

Expand All @@ -111,7 +111,15 @@ public static IEnumerable<TResult> Join<TInner, TKey, TResult>(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<TInner>() { oo});
//}


yield return resultSelector.Invoke(reg, oo);
//yield break;
Expand Down

0 comments on commit 4394fd3

Please sign in to comment.