Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
1. 修改join的時候,沒有對到的registrykey要Dispose
  • Loading branch information
oven425 committed Feb 5, 2021
1 parent 4394fd3 commit 149a697
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions QSoft.Reg/RegistryKeyEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,44 +87,44 @@ public static IEnumerable<TResult> Join<TInner, TResult>(this RegistryKey src, I
foreach (var subkeyname in subkeynames)
{
RegistryKey reg = src.OpenSubKey(subkeyname);
bool hastrue = false;
foreach (var oo in inner)
{
if (check.Invoke(reg, oo) == true)
{
hastrue = true;
yield return resultSelector.Invoke(reg, oo);
}
}
if(hastrue == false)
{
reg.Dispose();
}
}
}

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, List<TInner>> dic = new Dictionary<RegistryKey, List<TInner>>();
foreach (var subkeyname in subkeynames)
{

RegistryKey reg = src.OpenSubKey(subkeyname);
TKey key_reg = outerKeySelector.Invoke(reg);
bool hastrue = false;
foreach (var oo in inner)
{
TKey key = innerKeySelector.Invoke(oo);
if (key.Equals(key_reg) == true)
{
//if(dic.ContainsKey(reg) == true)
//{
// dic[reg].Add(oo);
//}
//else
//{
// dic.Add(reg, new List<TInner>() { oo});
//}


hastrue = true;
yield return resultSelector.Invoke(reg, oo);
//yield break;
}
}
if (hastrue == false)
{
reg.Dispose();
}
}
}

Expand Down

0 comments on commit 149a697

Please sign in to comment.