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


C# IEdmElement.GetHashCode方法代码示例

本文整理汇总了C#中IEdmElement.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# IEdmElement.GetHashCode方法的具体用法?C# IEdmElement.GetHashCode怎么用?C# IEdmElement.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEdmElement的用法示例。


在下文中一共展示了IEdmElement.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareElements

        private int CompareElements(IEdmElement left, IEdmElement right)
        {
            if (left == right)
            {
                return 0;
            }

            /* Left and right are distinct. */

            int leftHash = left.GetHashCode();
            int rightHash = right.GetHashCode();

            if (leftHash < rightHash)
            {
                return -1;
            }

            if (leftHash > rightHash)
            {
                return 1;
            }

            /* Left and right are distinct and have identical hash codes. */

            IEdmNamedElement leftNamed = left as IEdmNamedElement;
            IEdmNamedElement rightNamed = right as IEdmNamedElement;

            if (leftNamed == null)
            {
                if (rightNamed != null)
                {
                    return -1;
                }
            }
            else if (rightNamed == null)
            {
                return 1;
            }
            else
            {
                /* Left and right are both named. */

                int nameComparison = string.Compare(leftNamed.Name, rightNamed.Name, StringComparison.Ordinal);

                if (nameComparison != 0)
                {
                    return nameComparison;
                }
            }
            
            /* Left and right are distinct, have identical hash codes, and have identical names. */

            /* The first element to occur in the unsorted list is the greatest. */

            while (true)
            {
                foreach (IEdmElement element in this.unsortedElements)
                {
                    if (element == left)
                    {
                        return 1;
                    }

                    if (element == right)
                    {
                        return -1;
                    }
                }

                lock (this.unsortedElementsLock)
                {
                    this.unsortedElements = this.unsortedElements.Add(left);
                }
            }
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:75,代码来源:EdmDirectValueAnnotationsManager.cs

示例2: CompareElements

		private int CompareElements(IEdmElement left, IEdmElement right)
		{
			int num;
			if (left != right)
			{
				int hashCode = left.GetHashCode();
				int hashCode1 = right.GetHashCode();
				if (hashCode >= hashCode1)
				{
					if (hashCode <= hashCode1)
					{
						IEdmNamedElement edmNamedElement = left as IEdmNamedElement;
						IEdmNamedElement edmNamedElement1 = right as IEdmNamedElement;
						if (edmNamedElement != null)
						{
							if (edmNamedElement1 != null)
							{
								int num1 = string.Compare(edmNamedElement.Name, edmNamedElement1.Name, StringComparison.Ordinal);
								if (num1 != 0)
								{
									return num1;
								}
							}
							else
							{
								return 1;
							}
						}
						else
						{
							if (edmNamedElement1 != null)
							{
								return -1;
							}
						}
						while (true)
						{
							foreach (IEdmElement unsortedElement in this.unsortedElements)
							{
								if (unsortedElement != left)
								{
									if (unsortedElement != right)
									{
										continue;
									}
									num = -1;
									return num;
								}
								else
								{
									num = 1;
									return num;
								}
							}
							lock (this.unsortedElementsLock)
							{
								this.unsortedElements = this.unsortedElements.Add(left);
							}
						}
						return num;
					}
					else
					{
						return 1;
					}
				}
				else
				{
					return -1;
				}
			}
			else
			{
				return 0;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:76,代码来源:EdmDirectValueAnnotationsManager.cs


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