本文整理汇总了C#中ISpecification类的典型用法代码示例。如果您正苦于以下问题:C# ISpecification类的具体用法?C# ISpecification怎么用?C# ISpecification使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISpecification类属于命名空间,在下文中一共展示了ISpecification类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoCompleteFacet
public AutoCompleteFacet(MethodInfo autoCompleteMethod, int pageSize, int minLength, ISpecification holder)
: this(holder) {
method = autoCompleteMethod;
PageSize = pageSize == 0 ? DefaultPageSize : pageSize;
MinLength = minLength;
methodDelegate = DelegateUtils.CreateDelegate(method);
}
示例2: AuthorizationHideForSessionFacet
public AuthorizationHideForSessionFacet(string roles,
string users,
ISpecification holder)
: base(holder) {
this.roles = FacetUtils.SplitOnComma(roles);
this.users = FacetUtils.SplitOnComma(users);
}
示例3: NamedFacetInferred
public NamedFacetInferred(string value, ISpecification holder)
: base(value, holder) {
ShortName = TypeNameUtils.GetShortName(value);
CapitalizedName = NameUtils.CapitalizeName(ShortName);
SimpleName = NameUtils.SimpleName(ShortName);
NaturalName = NameUtils.NaturalName(ShortName);
}
示例4: Filter
public IList<IProduct> Filter(IList<IProduct> productList, ISpecification specification)
{
if (productList == null || specification == null)
return null;
return productList.Where(product => specification.IsMatched(product)).ToList();
}
示例5: 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;
}
示例6: AllMatching
public IEnumerable<User> AllMatching(ISpecification<User> specification)
{
lock (_users)
{
return _users.Where(specification.SatisfiedBy());
}
}
示例7: DecorateAllHoldersFacets
public void DecorateAllHoldersFacets(ISpecification holder) {
if (facetDecorators.Any()) {
foreach (Type facetType in holder.FacetTypes) {
DecorateFacet(facetType, holder);
}
}
}
示例8: 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);
}
示例9: FindNeighbourCells
/// <summary>
/// This method will return the list of cells that meet the specification.
/// <param name="cell"> source cell, whose neighbours need to find </param>
/// <param name="specification">Actual specification, which need to pass by neighbours. </param>
/// <returns>return the cell collection which pass the specification. </returns>
public ICollection<Cell> FindNeighbourCells(Cell cell, ISpecification<Cell> specification)
{
if(cell == null)
throw new ArgumentNullException("Cell can't be empty");
List<Cell> cells = new List<Cell>();
int startRow;
int startCol;
int endRow;
int endCol;
int colIndex = cell.ColNumber;
int rowIndex = cell.RowNumber;
GetValidStartRowAndCol(rowIndex, colIndex, out startRow, out startCol);
GetValidEndRowAndCol(rowIndex, colIndex, out endRow, out endCol);
for (int xcoord = startRow; xcoord <= endRow; xcoord++)
{
for (int ycoord = startCol; ycoord <= endCol; ycoord++)
{
if (!(xcoord == rowIndex && ycoord == colIndex))
{
if (specification == null)
cells.Add(grid[xcoord, ycoord]);
else
if (specification.IsSpecificationMeet(grid[xcoord, ycoord]))
cells.Add(grid[xcoord, ycoord]);
}
}
}
return cells;
}
示例10: Setup
public void Setup()
{
spec1 = Substitute.For<ISpecification<string>>();
spec2 = Substitute.For<ISpecification<string>>();
spec1.ReasonsForDissatisfaction.Returns(new List<string> { Spec1Dissatisfaction });
spec2.ReasonsForDissatisfaction.Returns(new List<string> { Spec2Dissatisfaction });
}
示例11: ProcessArray
private void ProcessArray(IReflector reflector, Type type, ISpecification holder) {
FacetUtils.AddFacet(new ArrayFacet(holder));
FacetUtils.AddFacet(new TypeOfFacetInferredFromArray(holder));
var elementType = type.GetElementType();
reflector.LoadSpecification(elementType);
}
示例12: Subscribe
public void Subscribe(
string subscriptionName,
ISpecification filter,
Action<IEnumerable<SubscriptionMessage>> messagesReceived)
{
this.InitialiseSubscription(subscriptionName, filter, messagesReceived);
}
示例13: Process
private static void Process(ISpecification holder) {
var facets = new List<IFacet>();
var specImmutable = holder as IMemberSpecImmutable;
if (specImmutable != null) {
facets.Add(new NamedFacetInferred(specImmutable.Identifier.MemberName, holder));
facets.Add(new DescribedAsFacetNone(holder));
}
if (holder is IAssociationSpecImmutable) {
facets.Add(new ImmutableFacetNever(holder));
facets.Add(new PropertyDefaultFacetNone(holder));
facets.Add(new PropertyValidateFacetNone(holder));
}
var immutable = holder as IOneToOneAssociationSpecImmutable;
if (immutable != null) {
facets.Add(new MaxLengthFacetZero(holder));
DefaultTypicalLength(facets, immutable.ReturnSpec, immutable);
facets.Add(new MultiLineFacetNone(holder));
}
if (holder is IActionSpecImmutable) {
facets.Add(new ExecutedFacetDefault(holder));
facets.Add(new ActionDefaultsFacetNone(holder));
facets.Add(new ActionChoicesFacetNone(holder));
facets.Add(new PageSizeFacetDefault(holder));
}
FacetUtils.AddFacets(facets);
}
示例14: CreateAndGetSubscriptionInternal
private SubscriptionClient CreateAndGetSubscriptionInternal(string subscriptionName, ISpecification filterSpecification)
{
var filter = new SqlFilter(filterSpecification.Result());
EnsureSubscriptionNameIsValid(subscriptionName);
log.Info($"Checking subscription for path {subscriptionName} exists");
if (!this.namespaceManager.SubscriptionExists(this.topic, subscriptionName))
{
log.Info("Creating subscription as it does not currently exist");
var subscriptionDescription = new SubscriptionDescription(this.topic, subscriptionName)
{
LockDuration = TimeSpan.FromMinutes(5)
};
this.namespaceManager.CreateSubscription(subscriptionDescription, filter);
log.Info("Subscription created");
}
log.Info("Creating subscription client");
var client = SubscriptionClient.CreateFromConnectionString(
connectionString, this.topic, subscriptionName);
log.Info("Subscription client created");
return client;
}
示例15: IsValid
public static IInteractionBuffer IsValid(ISpecification specification, IInteractionContext ic, IInteractionBuffer buf) {
IEnumerable<IValidatingInteractionAdvisor> facets = specification.GetFacets().Where(f => f is IValidatingInteractionAdvisor).Cast<IValidatingInteractionAdvisor>();
foreach (IValidatingInteractionAdvisor advisor in facets) {
buf.Append(advisor.Invalidates(ic));
}
return buf;
}