public bool Exists(string packageId, SemanticVersion version) { IQueryable <DataServicePackage> query = Context.CreateQuery <DataServicePackage>(PackageServiceEntitySetName).AsQueryable(); foreach (string versionString in version.GetComparableVersionStrings()) { try { var packages = query.Where(p => p.Id == packageId && p.Version == versionString) .Select(p => p.Id) // since we only want to check for existence, no need to get all attributes .ToArray(); if (packages.Length == 1) { return(true); } } catch (DataServiceQueryException) { // DataServiceQuery exception will occur when the (id, version) // combination doesn't exist. } } return(false); }
public bool Exists(string packageId, SemanticVersion version) { bool flag; IQueryable <DataServicePackage> queryable = this.Context.CreateQuery <DataServicePackage>("Packages").AsQueryable(); using (IEnumerator <string> enumerator = version.GetComparableVersionStrings().GetEnumerator()) { while (true) { if (enumerator.MoveNext()) { string versionString = enumerator.Current; try { < > c__DisplayClass38_1 class_2; ParameterExpression expression = Expression.Parameter(typeof(DataServicePackage), "p"); ParameterExpression[] parameters = new ParameterExpression[] { expression }; IQueryable <DataServicePackage> queryable1 = Queryable.Where <DataServicePackage>(queryable, Expression.Lambda <Func <DataServicePackage, bool> >(Expression.AndAlso(Expression.Equal(Expression.Property(expression, (MethodInfo)methodof(DataServicePackage.get_Id)), Expression.Field(Expression.Field(Expression.Constant(class_2, typeof(< > c__DisplayClass38_1)), fieldof(< > c__DisplayClass38_1.CS$ < > 8__locals1)), fieldof(< > c__DisplayClass38_0.packageId))), Expression.Equal(Expression.Property(expression, (MethodInfo)methodof(DataServicePackage.get_Version)), Expression.Field(Expression.Constant(class_2, typeof(< > c__DisplayClass38_1)), fieldof(< > c__DisplayClass38_1.versionString)))), parameters)); expression = Expression.Parameter(typeof(DataServicePackage), "p"); ParameterExpression[] expressionArray2 = new ParameterExpression[] { expression }; if (Queryable.Select <DataServicePackage, string>(queryable1, Expression.Lambda <Func <DataServicePackage, string> >(Expression.Property(expression, (MethodInfo)methodof(DataServicePackage.get_Id)), expressionArray2)).ToArray <string>().Length == 1) { flag = true; break; } }
public override bool Exists(string packageId, SemanticVersion version) { if (version != null) { // optimization: if we find the .nuspec file at "id.version"\"id.version".nuspec or // the .nupkg file at "id.version"\"id.version".nupkg, consider it exists bool hasPackageDirectory = version.GetComparableVersionStrings() .Select(v => packageId + "." + v) .Any(path => FileSystem.FileExists(Path.Combine(path, path + Constants.PackageExtension)) || FileSystem.FileExists(Path.Combine(path, path + Constants.ManifestExtension))); if (hasPackageDirectory) { return(true); } } return(FindPackage(packageId, version) != null); }
public IPackage FindPackage(string packageId, SemanticVersion version) { IQueryable <DataServicePackage> query = Context.CreateQuery <DataServicePackage>(PackageServiceEntitySetName).AsQueryable(); foreach (string versionString in version.GetComparableVersionStrings()) { try { var packages = query.Where(p => p.Id == packageId && p.Version == versionString).ToArray(); Debug.Assert(packages == null || packages.Length <= 1); if (packages.Length != 0) { return(packages[0]); } } catch (DataServiceQueryException) { // DataServiceQuery exception will occur when the (id, version) // combination doesn't exist. } } return(null); }
public override bool Exists(string packageId, SemanticVersion version) => (((version == null) || !Enumerable.Any <string>(from v in version.GetComparableVersionStrings() select packageId + "." + v, path => base.FileSystem.FileExists(Path.Combine(path, path + Constants.PackageExtension)) || base.FileSystem.FileExists(Path.Combine(path, path + Constants.ManifestExtension)))) ? (this.FindPackage(packageId, version) != null) : true);