checkpoint

This commit is contained in:
2020-04-30 17:27:50 -04:00
parent 9bc522180d
commit 9aa367e9f5
16 changed files with 176 additions and 98 deletions

View File

@@ -1,10 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
namespace Foodsoft.Alpm
{
public class CachePackageList : IPackageList<CachePackage>, ICollection<CachePackage>
{
private readonly SafeDatabaseHandle _parentHandle;
@@ -17,7 +22,8 @@ namespace Foodsoft.Alpm
_listPtr = listPtr;
_db = db;
}
[PrePrepareMethod]
public IEnumerator<CachePackage> GetEnumerator()
{
var release = false;
@@ -27,10 +33,10 @@ namespace Foodsoft.Alpm
{
_parentHandle.DangerousAddRef(ref release);
if (!release) throw new ObjectDisposedException(_parentHandle.GetType().FullName);
for (var list = _listPtr; list != IntPtr.Zero; list = Wrapper.ListNext(list))
for (var list = _listPtr; list != IntPtr.Zero; list = Detail.ListNext(list))
{
yield return new CachePackage(
new SafeCachePackageHandle(Wrapper.ListData(list), _parentHandle), _db);
new SafeCachePackageHandle(Detail.ListData(list), _parentHandle), _db);
}
}
finally
@@ -51,7 +57,7 @@ namespace Foodsoft.Alpm
return _parentHandle.UseHandle(_listPtr, (list) =>
{
for (; list != IntPtr.Zero; list = Wrapper.ListNext(list))
for (; list != IntPtr.Zero; list = Detail.ListNext(list))
{
if (name == alpm.alpm_pkg_get_name(list))
return true;
@@ -65,15 +71,16 @@ namespace Foodsoft.Alpm
{
_parentHandle.UseHandle(_listPtr, (list) =>
{
for (; list != IntPtr.Zero; list = Wrapper.ListNext(list))
for (; list != IntPtr.Zero; list = Detail.ListNext(list))
{
array[arrayIndex++] = new CachePackage(
new SafeCachePackageHandle(Wrapper.ListData(list), _parentHandle), _db);
new SafeCachePackageHandle(Detail.ListData(list), _parentHandle), _db);
}
return 0;
});
}
public CachePackage? FindSatisfier(string depString)
{
return _parentHandle.UseHandle(_listPtr, (list) =>