本文整理汇总了C#中IEqualityComparer类的典型用法代码示例。如果您正苦于以下问题:C# IEqualityComparer类的具体用法?C# IEqualityComparer怎么用?C# IEqualityComparer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IEqualityComparer类属于命名空间,在下文中一共展示了IEqualityComparer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualToEntityPropertyValidator
/// <summary>
/// Initializes a new instance of the <see cref="EqualToEntityPropertyValidator"/> class.
/// </summary>
/// <param name="memberToCompareFunc">The member to compare function.</param>
/// <param name="member">The member.</param>
/// <param name="ownerType">The owner type.</param>
/// <param name="confirmProperty">if set to <c>true</c> [confirm property].</param>
/// <param name="comparer">The comparer.</param>
/// <exception cref="System.ArgumentNullException">
/// memberToCompareFunc
/// or
/// member
/// or
/// ownerType
/// </exception>
public EqualToEntityPropertyValidator(Func<object, object> memberToCompareFunc, MemberInfo member, Type ownerType, bool confirmProperty = true, IEqualityComparer comparer = null)
{
if (memberToCompareFunc == null)
{
throw new ArgumentNullException("memberToCompareFunc");
}
if (member == null)
{
throw new ArgumentNullException("member");
}
if (ownerType == null)
{
throw new ArgumentNullException("ownerType");
}
OwnerType = ownerType;
m_MemberToCompareFunc = memberToCompareFunc;
m_MemberToCompareMemberInfo = member;
m_ConfirmProperty = confirmProperty;
m_Comparer = comparer;
m_ValidatorProperties = new ValidatorProperties
{
{ Constants.ValidationMessageParameterNames.MEMBER_TO_COMPARE_MEMBER_INFO, m_MemberToCompareMemberInfo },
{ Constants.ValidationMessageParameterNames.OWNER_TYPE, ownerType }
};
}
示例2: TryMatch
public MatchResult TryMatch(string s, IEqualityComparer<string> comparer)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
if (disposed)
{
throw new ObjectDisposedException(GetType().FullName);
}
if (s.Length == 0)
{
return MatchResult.FromMatch(string.Empty, s);
}
var buffer = new char[s.Length];
var len = textSource.ReadBlock(buffer, 0, buffer.Length);
var next = new string(buffer, 0, len);
if (len == 0)
{
endOfInput = true;
return MatchResult.FromEndOfInput(s);
}
if (!comparer.Equals(s, next))
{
textSource.Unread(buffer, 0, len);
return MatchResult.FromMismatch(next, s);
}
Interlocked.Add(ref offset, len);
return MatchResult.FromMatch(next, s);
}
示例3: OrderedDictionary
public OrderedDictionary (int capacity, IEqualityComparer equalityComparer)
{
initialCapacity = (capacity < 0) ? 0 : capacity;
list = new ArrayList (initialCapacity);
hash = new Hashtable (initialCapacity, equalityComparer);
comparer = equalityComparer;
}
示例4: ContainsClaim
public static bool ContainsClaim(this IEnumerable<ClaimSet> claimSets, Claim searchClaim, Claim issuerIdentityClaim, ClaimSearchMode searchMode, IEqualityComparer<Claim> comparer)
{
IEnumerable<ClaimSet> searchSet =
GetClaimSetsCore(claimSets, issuerIdentityClaim, searchMode);
foreach (ClaimSet set in searchSet)
{
bool found = false;
if (comparer != null)
{
found = set.ContainsClaim(searchClaim, comparer);
}
else
{
found = set.ContainsClaim(searchClaim);
}
if (found)
{
return true;
}
}
return false;
}
示例5: EqualValidator
public EqualValidator(Func<object, object> comparisonProperty, MemberInfo member, IEqualityComparer comparer)
: base(() => Messages.equal_error, ValidationErrors.Equal)
{
func = comparisonProperty;
MemberToCompare = member;
this.comparer = comparer;
}
示例6: BinaryUnitConversionMap
public BinaryUnitConversionMap(IUnitConversion<double> forwardOperation, IEqualityComparer<IUnit> unitEqualityComparer = null)
: base(unitEqualityComparer)
{
if (null == forwardOperation) throw new ArgumentNullException("forwardOperation");
Contract.EndContractBlock();
_forwardOperation = forwardOperation;
}
示例7: MarshalContext
public MarshalContext(IEqualityComparer equalityComparer)
{
stackMap = new Hashtable(equalityComparer);
useRepository = false;
caseSensitive = true;
AddConverters();
}
示例8: EvaluateQuery
public static bool EvaluateQuery(ArrayList<string> text, ArrayList<QueryToken> queryPlan, out bool result, IEqualityComparer<string> tokenComparer)
{
result = false;
Stack<bool> stack = new Stack<bool>();
foreach (QueryToken token in queryPlan)
{
bool b;
switch (GetTokenType(token))
{
case TokenType.Term:
stack.Push(Contains(token, text, tokenComparer));
break;
case TokenType.Operator: // AND/OR
if (stack.Count <= 1) { return false; }
bool b1 = stack.Pop();
bool b2 = stack.Pop();
b = b1 && b2;
if (token == "OR") { b = b1 || b2; }
stack.Push(b);
break;
case TokenType.Function: // NOT
if (stack.Count == 0) { return false; }
b = stack.Pop();
stack.Push(!b);
break;
}
}
if (stack.Count != 1) { return false; }
result = stack.Pop();
return true;
}
示例9: MemberComparer
/// <summary>
/// Initializes a new instance of the <see cref="MemberComparer"/>
/// class with the supplied <see cref="IEqualityComparer"/> to support
/// the comparison of properties and fields.
/// </summary>
/// <param name="comparer">
/// The supplied <see cref="IEqualityComparer"/>.
/// </param>
public MemberComparer(IEqualityComparer comparer)
: this(
comparer,
new TrueSpecification<PropertyInfo>(),
new TrueSpecification<FieldInfo>())
{
}
示例10: DynamicEntity
public DynamicEntity(MissingMemberBehavior missingMemberBehavior,
IDynamicEntityConverter converter = null, IEqualityComparer<string> comparer = null)
{
_missingMemberBehavior = missingMemberBehavior;
_dataDictionary = new Dictionary<string, object>(comparer ?? StringComparer.InvariantCultureIgnoreCase);
_converter = converter ?? new NullConverter();
}
示例11: MappedHtmlNodeToReferenceNode
public MappedHtmlNodeToReferenceNode(MappedHtmlNode parent, HtmlNode htmlNode, HtmlNode referenceNode, IEqualityComparer<HtmlNode> comparer, PropertyNameState propertyNameState)
: base(parent)
{
if (htmlNode == null)
{
throw new ArgumentNullException("htmlNode");
}
if (referenceNode == null)
{
throw new ArgumentNullException("referenceNode");
}
if (comparer == null)
{
throw new ArgumentNullException("comparer");
}
if (propertyNameState == null)
{
throw new ArgumentNullException("propertyNameState");
}
this.htmlNode = htmlNode;
this.referenceNode = referenceNode;
this.comparer = comparer;
this.propertyNameState = propertyNameState;
base.children = MapChildren();
}
示例12: EqualValidator
public EqualValidator(PropertySelector comparisonProperty, MemberInfo member, IEqualityComparer comparer)
: base(() => Messages.equal_error)
{
func = comparisonProperty;
MemberToCompare = member;
this.comparer = comparer;
}
示例13: NotEqualValidator
public NotEqualValidator(Func<object, object> func, MemberInfo memberToCompare, IEqualityComparer equalityComparer)
: base(() => Messages.notequal_error, ValidationErrors.NotEqual)
{
this.func = func;
this.comparer = equalityComparer;
MemberToCompare = memberToCompare;
}
示例14: NotEqualValidator
public NotEqualValidator(object comparisonValue, IEqualityComparer equalityComparer)
: base(() => Messages.notequal_error)
{
ValueToCompare = comparisonValue;
comparer = equalityComparer;
SupportsStandaloneValidation = true;
}
示例15: SingleUnityUnitConversionMap
public SingleUnityUnitConversionMap(IUnit unit, IEqualityComparer<IUnit> unitEqualityComparer = null)
: base(unitEqualityComparer)
{
if (null == unit) throw new ArgumentNullException("unit");
Contract.EndContractBlock();
_singleUnit = unit;
}