当前位置: 首页>>代码示例>>C#>>正文


C# IEqualityComparer类代码示例

本文整理汇总了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 }
                                        };
        }
开发者ID:QuickOrBeDead,项目名称:Labo.Validation,代码行数:43,代码来源:EqualToEntityPropertyValidator.cs

示例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);
 }
开发者ID:kusl,项目名称:TextFx,代码行数:30,代码来源:TextScanner.cs

示例3: OrderedDictionary

		public OrderedDictionary (int capacity, IEqualityComparer equalityComparer)
		{
			initialCapacity = (capacity < 0) ? 0 : capacity;
			list = new ArrayList (initialCapacity);
			hash = new Hashtable (initialCapacity, equalityComparer);
			comparer = equalityComparer;
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:OrderedDictionary.cs

示例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;
        }
开发者ID:calderonsteven,项目名称:Preparation_For_Exam70-513,代码行数:25,代码来源:ClaimSetListExtensions.cs

示例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;
 }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:7,代码来源:EqualValidator.cs

示例6: BinaryUnitConversionMap

 public BinaryUnitConversionMap(IUnitConversion<double> forwardOperation, IEqualityComparer<IUnit> unitEqualityComparer = null)
     : base(unitEqualityComparer)
 {
     if (null == forwardOperation) throw new ArgumentNullException("forwardOperation");
     Contract.EndContractBlock();
     _forwardOperation = forwardOperation;
 }
开发者ID:aarondandy,项目名称:pigeoid,代码行数:7,代码来源:BinaryUnitConversionMap.cs

示例7: MarshalContext

 public MarshalContext(IEqualityComparer equalityComparer)
 {
     stackMap = new Hashtable(equalityComparer);
     useRepository = false;
     caseSensitive = true;
     AddConverters();
 }
开发者ID:jxqlovejava,项目名称:Tatala-RPC,代码行数:7,代码来源:MarshalContext.cs

示例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;
 }
开发者ID:SowaLabs,项目名称:QueryLib,代码行数:31,代码来源:QueryUtils.cs

示例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>())
 {
 }
开发者ID:RyanLiu99,项目名称:AutoFixture,代码行数:15,代码来源:MemberComparer.cs

示例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();
        }
开发者ID:nick-randal,项目名称:UsefulCSharp,代码行数:7,代码来源:DynamicEntity.cs

示例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();


        }
开发者ID:WebCentrum,项目名称:WebPackUI,代码行数:32,代码来源:MappedHtmlNodeToReferenceNode.cs

示例12: EqualValidator

 public EqualValidator(PropertySelector comparisonProperty, MemberInfo member, IEqualityComparer comparer)
     : base(() => Messages.equal_error)
 {
     func = comparisonProperty;
     MemberToCompare = member;
     this.comparer = comparer;
 }
开发者ID:Tigraine,项目名称:FluentValidation,代码行数:7,代码来源:EqualValidator.cs

示例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;
 }
开发者ID:jmaucher,项目名称:SStack,代码行数:7,代码来源:NotEqualValidator.cs

示例14: NotEqualValidator

 public NotEqualValidator(object comparisonValue, IEqualityComparer equalityComparer)
     : base(() => Messages.notequal_error)
 {
     ValueToCompare = comparisonValue;
     comparer = equalityComparer;
     SupportsStandaloneValidation = true;
 }
开发者ID:Tigraine,项目名称:FluentValidation,代码行数:7,代码来源:NotEqualValidator.cs

示例15: SingleUnityUnitConversionMap

 public SingleUnityUnitConversionMap(IUnit unit, IEqualityComparer<IUnit> unitEqualityComparer = null)
     : base(unitEqualityComparer)
 {
     if (null == unit) throw new ArgumentNullException("unit");
     Contract.EndContractBlock();
     _singleUnit = unit;
 }
开发者ID:aarondandy,项目名称:pigeoid,代码行数:7,代码来源:SingleUnityUnitConversionMap.cs


注:本文中的IEqualityComparer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。