Пример #1
0
        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);
                }
            }
        }
		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;
			}
		}
        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);
                }
            }
        }
Пример #4
0
        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);
            }
        }