using UnityEditor.PackageManager.Requests; //ListRequest
using UnityEditor.PackageManager; //PackageCollection
using System.Collections.Generic; //IEnumerable
namespace Unity.RenderStreaming.Editor {
///
/// An extension class to extend the functionalities of UnityEditor.PackageManager.Requests classes
///
internal static class RequestExtensions
{
///
/// Find a PackageInfo which has the passed parameter
///
/// list of Request object
/// the package name
/// The PackageInfo if found, otherwise null
public static PackageInfo FindPackage(this Request listRequest, string packageName) {
IEnumerable packageInfoCollection = listRequest.Result as IEnumerable;
if (null == packageInfoCollection) {
return null;
}
var enumerator = packageInfoCollection.GetEnumerator();
while (enumerator.MoveNext()) {
PackageInfo curInfo = enumerator.Current;
if (curInfo.name == packageName) {
return curInfo;
}
}
return null;
}
}
} //namespace Unity.RenderStreaming.Editor