本文整理汇总了C#中ISpecification.IsSatisfiedBy方法的典型用法代码示例。如果您正苦于以下问题:C# ISpecification.IsSatisfiedBy方法的具体用法?C# ISpecification.IsSatisfiedBy怎么用?C# ISpecification.IsSatisfiedBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISpecification
的用法示例。
在下文中一共展示了ISpecification.IsSatisfiedBy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateResponseForSingleFileByCriteria
/// <summary>
/// Create a response for single file by criteria.
/// </summary>
/// <param name="file">
/// The file.
/// </param>
/// <param name="criteria">
/// The criteria.
/// </param>
/// <returns>
/// The <see cref="object"/>.
/// </returns>
protected internal virtual object CreateResponseForSingleFileByCriteria(object file, ISpecification<File> criteria)
{
long count = this.Repository.Count(criteria.IsSatisfiedBy());
this.InsertRangeInResponse(count);
if (count == 0)
{
return this.FileNotFound(file);
}
return count > 1 ? this.TooManyFiles(file) : this.Repository.GetSingle(criteria.IsSatisfiedBy());
}
示例2: FindNeighbours
/// <summary>
/// Finds the number of neighbours of a given cell that meet the passed in specification.
/// </summary>
/// <param name="cell">Cell whose neighbours have to be found.</param>
/// <param name="specification">The specification that should be met by the neighbouring cells.</param>
/// <returns>Returns the collection of cells that meet the passed in specification.</returns>
public ICollection<Cell> FindNeighbours(Cell cell, ISpecification<Cell> specification)
{
List<Cell> cells = new List<Cell>();
if (cell == null)
{
throw new ArgumentNullException(paramName:"Cell");
}
int column = cell.ColumnNumber;
int row = cell.RowNumber;
int startrow;
int startcol;
int endcol;
int endrow;
GetValidStartRowAndColumn(row, column, out startrow, out startcol);
GetValidEndRowAndColumn(row, column, out endrow, out endcol);
for (int xcoord = startrow; xcoord <= endrow; xcoord++)
{
for (int ycoord = startcol; ycoord <= endcol; ycoord++)
{
if (!(xcoord == row && ycoord == column))
{
if (specification == null)
cells.Add(grid[xcoord, ycoord]);
else
if(specification.IsSatisfiedBy(grid[xcoord, ycoord]))
cells.Add(grid[xcoord, ycoord]);
}
}
}
return cells;
}
示例3: IsSatisfiedByFalse
/// <summary>
///
/// </summary>
/// <param name="specification"></param>
/// <param name="item"></param>
/// <param name="reason"></param>
public static void IsSatisfiedByFalse(ISpecification<string> specification, string item, string reason)
{
Assert.IsNotNull(specification);
Assert.IsFalse(specification.IsSatisfiedBy(item));
Assert.AreEqual(specification.ReasonsForDissatisfaction.Count(), 1);
Assert.AreEqual(specification.ReasonsForDissatisfaction.Single(), reason);
}
示例4: By
public IEnumerable<Product> By(IList<Product> products, ISpecification specification)
{
foreach (var product in products)
{
if (specification.IsSatisfiedBy(product))
yield return product;
}
}
示例5: Satisfies
public static bool Satisfies(this IDomainObject domainObject, ISpecification specification)
{
if (specification == null) throw new ArgumentNullException("specification");
return specification.IsSatisfiedBy(domainObject);
}
示例6: GetBySpecification
public virtual IEnumerable<Person> GetBySpecification(ISpecification<Person> specification)
{
return Persons.Where(x => specification.IsSatisfiedBy(x));
}
示例7: CreateResponseForFilesByCriteria
/// <summary>
/// The create response for files by criteria.
/// </summary>
/// <param name="file">
/// The file.
/// </param>
/// <param name="criteria">
/// The criteria.
/// </param>
/// <returns>
/// The <see cref="object"/>.
/// </returns>
protected virtual object CreateResponseForFilesByCriteria(object file, ISpecification<File> criteria)
{
long count = this.Repository.Count(criteria.IsSatisfiedBy());
this.InsertRangeInResponse(count);
return count == 0 ? this.FileNotFound(file) : this.Repository.Where(criteria.IsSatisfiedBy());
}