int.CompareTo(int)

Here are the examples of the csharp api int.CompareTo(int) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1221 Examples 7

19 Source : Search.cs
with MIT License
from 3583Bytes

private static int Sort(Position s2, Position s1)
        {
            return (s1.Score).CompareTo(s2.Score);
        }

19 Source : SubType.cs
with MIT License
from 404Lcc

public int Compare(SubType x, SubType y)
            {
                if (ReferenceEquals(x, y)) return 0;
                if (x == null) return -1;
                if (y == null) return 1;

                return x.FieldNumber.CompareTo(y.FieldNumber);
            }

19 Source : ValueMember.cs
with MIT License
from 404Lcc

public int Compare(ValueMember x, ValueMember y)
            {
                if (ReferenceEquals(x, y)) return 0;
                if (x == null) return -1;
                if (y == null) return 1;

                return x.FieldNumber.CompareTo(y.FieldNumber);
            }

19 Source : ProtoMemberAttribute.cs
with MIT License
from 404Lcc

public int CompareTo(ProtoMemberAttribute other)
        {
            if (other == null) return -1;
            if ((object)this == (object)other) return 0;
            int result = this.tag.CompareTo(other.tag);
            if (result == 0) result = string.CompareOrdinal(this.name, other.name);
            return result;
        }

19 Source : Helpers.cs
with MIT License
from 71

public static bool TryPrepareMethod(MethodBase method, RuntimeMethodHandle handle)
        {
            // First, try the good ol' RuntimeHelpers.PrepareMethod.
            if (PrepareMethod != null)
            {
                PrepareMethod(handle);
                return true;
            }

            // No chance, we gotta go lower.
            // Invoke the method with uninitialized arguments.
            object sender = null;

            object[] GetArguments(ParameterInfo[] parameters)
            {
                object[] args = new object[parameters.Length];

                for (int i = 0; i < parameters.Length; i++)
                {
                    ParameterInfo param = parameters[i];

                    if (param.HasDefaultValue)
                        args[i] = param.DefaultValue;
                    else if (param.ParameterType.GetTypeInfo().IsValueType)
                        args[i] = Activator.CreateInstance(param.ParameterType);
                    else
                        args[i] = null;
                }

                return args;
            }

            if (!method.IsStatic)
            {
                // Gotta make the instance
                Type declaringType = method.DeclaringType;

                if (declaringType.GetTypeInfo().IsValueType)
                {
                    sender = Activator.CreateInstance(declaringType);
                }
                else if (declaringType.GetTypeInfo().IsAbstract)
                {
                    // Overkill solution: Find a type in the replacedembly that implements the declaring type,
                    // and use it instead.
                    throw new InvalidOperationException("Cannot manually JIT a method");
                }
                else if (GetUninitializedObject != null)
                {
                    sender = GetUninitializedObject(declaringType);
                }
                else
                {
                    /* TODO
                     * Since I just made the whole 'gotta JIT the method' step mandatory
                     * in the MethodRedirection ctor, i should make sure this always returns true.
                     * That means looking up every type for overriding types for the throwing step above,
                     * and testing every possible constructor to create the instance.
                     * 
                     * Additionally, if we want to go even further, we can repeat this step for every
                     * single argument of the ctor, thus making sure that we end up having an actual clreplaced.
                     * In this case, unless the user wants to instantiate an abstract clreplaced with no overriding clreplaced,
                     * everything'll work. HOWEVER, performances would be less-than-ideal. A simple Redirection
                     * may mean scanning the replacedembly a dozen times for overriding types, calling their constructors
                     * hundreds of times, knowing that all of them will be slow (Reflection + Try/Catch blocks aren't
                     * perfs-friendly).
                     */
                    ConstructorInfo ctor = declaringType.GetConstructor(Type.EmptyTypes);

                    if (ctor != null)
                    {
                        sender = ctor.Invoke(null);
                    }
                    else
                    {
                        ConstructorInfo[] ctors = declaringType.GetConstructors(ALL_INSTANCE);

                        Array.Sort(ctors, (a, b) => a.GetParameters().Length.CompareTo(b.GetParameters().Length));

                        ctor = ctors[0];

                        try
                        {
                            sender = ctor.Invoke(GetArguments(ctor.GetParameters()));
                        }
                        catch (TargetInvocationException)
                        {
                            // Nothing we can do, give up.
                            return false;
                        }
                    }
                }
            }

            try
            {
                method.Invoke(sender, GetArguments(method.GetParameters()));
            }
            catch (TargetInvocationException)
            {
                // That's okay.
            }

            return true;
        }

19 Source : Ryder.Lightweight.cs
with MIT License
from 71

public static bool TryPrepareMethod(MethodBase method, RuntimeMethodHandle handle)
            {
                // First, try the good ol' RuntimeHelpers.PrepareMethod.
                if (PrepareMethod != null)
                {
                    PrepareMethod(handle);
                    return true;
                }

                // No chance, we gotta go lower.
                // Invoke the method with uninitialized arguments.
                object sender = null;

                object[] GetArguments(ParameterInfo[] parameters)
                {
                    object[] args = new object[parameters.Length];

                    for (int i = 0; i < parameters.Length; i++)
                    {
                        ParameterInfo param = parameters[i];

                        if (param.HasDefaultValue)
                            args[i] = param.DefaultValue;
                        else if (param.ParameterType.GetTypeInfo().IsValueType)
                            args[i] = Activator.CreateInstance(param.ParameterType);
                        else
                            args[i] = null;
                    }

                    return args;
                }

                if (!method.IsStatic)
                {
                    // Gotta make the instance
                    Type declaringType = method.DeclaringType;

                    if (declaringType.GetTypeInfo().IsValueType)
                    {
                        sender = Activator.CreateInstance(declaringType);
                    }
                    else if (declaringType.GetTypeInfo().IsAbstract)
                    {
                        // Overkill solution: Find a type in the replacedembly that implements the declaring type,
                        // and use it instead.
                        throw new InvalidOperationException("Cannot manually JIT a method");
                    }
                    else if (GetUninitializedObject != null)
                    {
                        sender = GetUninitializedObject(declaringType);
                    }
                    else
                    {
                        /* TODO
                         * Since I just made the whole 'gotta JIT the method' step mandatory
                         * in the MethodRedirection ctor, i should make sure this always returns true.
                         * That means looking up every type for overriding types for the throwing step above,
                         * and testing every possible constructor to create the instance.
                         * 
                         * Additionally, if we want to go even further, we can repeat this step for every
                         * single argument of the ctor, thus making sure that we end up having an actual clreplaced.
                         * In this case, unless the user wants to instantiate an abstract clreplaced with no overriding clreplaced,
                         * everything'll work. HOWEVER, performances would be less-than-ideal. A simple Redirection
                         * may mean scanning the replacedembly a dozen times for overriding types, calling their constructors
                         * hundreds of times, knowing that all of them will be slow (Reflection + Try/Catch blocks aren't
                         * perfs-friendly).
                         */
                        ConstructorInfo ctor = declaringType.GetConstructor(Type.EmptyTypes);

                        if (ctor != null)
                        {
                            sender = ctor.Invoke(null);
                        }
                        else
                        {
                            ConstructorInfo[] ctors = declaringType.GetConstructors(ALL_INSTANCE);

                            Array.Sort(ctors, (a, b) => a.GetParameters().Length.CompareTo(b.GetParameters().Length));

                            ctor = ctors[0];

                            try
                            {
                                sender = ctor.Invoke(GetArguments(ctor.GetParameters()));
                            }
                            catch (TargetInvocationException)
                            {
                                // Nothing we can do, give up.
                                return false;
                            }
                        }
                    }
                }

                try
                {
                    method.Invoke(sender, GetArguments(method.GetParameters()));
                }
                catch (TargetInvocationException)
                {
                    // That's okay.
                }

                return true;
            }

19 Source : NpcCommandHandler.cs
with GNU Lesser General Public License v3.0
from 8720826

private bool CheckField(PlayerEnreplacedy player, string field, string strValue, string strRelation)
        {
            try
            {
                var relations = GetRelations(strRelation);// 1 大于,0 等于 ,-1 小于

                var fieldProp = GetFieldPropertyInfo(player, field);
                if (fieldProp == null)
                {
                    return false;
                }

                var objectValue = fieldProp.GetValue(player);
                var typeCode = Type.GetTypeCode(fieldProp.GetType());
                switch (typeCode)
                {
                    case TypeCode.Int32:
                        return relations.Contains(Convert.ToInt32(strValue).CompareTo(Convert.ToInt32(objectValue)));

                    case TypeCode.Int64:
                        return relations.Contains(Convert.ToInt64(strValue).CompareTo(Convert.ToInt64(objectValue)));

                    case TypeCode.Decimal:
                        return relations.Contains(Convert.ToDecimal(strValue).CompareTo(Convert.ToDecimal(objectValue)));

                    case TypeCode.Double:
                        return relations.Contains(Convert.ToDouble(strValue).CompareTo(Convert.ToDouble(objectValue)));

                    case TypeCode.Boolean:
                        return relations.Contains(Convert.ToBoolean(strValue).CompareTo(Convert.ToBoolean(objectValue)));

                    case TypeCode.DateTime:
                        return relations.Contains(Convert.ToDateTime(strValue).CompareTo(Convert.ToDateTime(objectValue)));

                    case TypeCode.String:
                        return relations.Contains(strValue.CompareTo(objectValue));

                    default:
                        throw new Exception($"不支持的数据类型: {typeCode}");
                }
            }
            catch (Exception ex)
            {
                _logger.LogError($"CheckField Exception:{ex}");
                return false;
            }
        }

19 Source : DatabaseSchemaUpgradeManager.cs
with Microsoft Public License
from AArnott

internal static SchemaCompatibility IsUpgradeRequired(SQLiteConnection db)
	{
		int initialFileVersion = GetCurrentSchema(db);
		return (SchemaCompatibility)initialFileVersion.CompareTo(latestVersion);
	}

19 Source : SortedObservableCollectionTests.cs
with Microsoft Public License
from AArnott

public int Compare(int x, int y) => -x.CompareTo(y);

19 Source : HighlightedLine.cs
with MIT License
from Abdesol

public int CompareTo(HtmlElement other)
			{
				int r = Offset.CompareTo(other.Offset);
				if (r != 0)
					return r;
				if (IsEnd != other.IsEnd) {
					if (IsEnd)
						return -1;
					else
						return 1;
				} else {
					if (IsEnd)
						return other.Nesting.CompareTo(Nesting);
					else
						return Nesting.CompareTo(other.Nesting);
				}
			}

19 Source : TextViewPosition.cs
with MIT License
from Abdesol

public int CompareTo(TextViewPosition other)
		{
			int r = this.Location.CompareTo(other.Location);
			if (r != 0)
				return r;
			r = this.visualColumn.CompareTo(other.visualColumn);
			if (r != 0)
				return r;
			if (isAtEndOfLine && !other.isAtEndOfLine)
				return -1;
			else if (!isAtEndOfLine && other.isAtEndOfLine)
				return 1;
			return 0;
		}

19 Source : TextRangeProvider.cs
with MIT License
from Abdesol

public int CompareEndpoints(TextPatternRangeEndpoint endpoint, ITextRangeProvider targetRange, TextPatternRangeEndpoint targetEndpoint)
		{
			TextRangeProvider other = (TextRangeProvider)targetRange;
			int result = GetEndpoint(endpoint).CompareTo(other.GetEndpoint(targetEndpoint));
			Log("{0}.CompareEndpoints({1}, {2}, {3}) = {4}", ID, endpoint, other.ID, targetEndpoint, result);
			return result;
		}

19 Source : Person.cs
with GNU General Public License v3.0
from abishekaditya

public int CompareTo(object obj)
        {
            var other = (Person)obj;
            if (String.Compare(Name, other.Name, StringComparison.Ordinal) == 0)
            {
                return Age.CompareTo(other.Age);
            }
            return String.Compare(Name, other.Name, StringComparison.Ordinal);
        }

19 Source : Distorter.cs
with Apache License 2.0
from abist-co-ltd

public int CompareTo(Distorter other)
        {
            return other == null ? 0 : DistortOrder.CompareTo(other.DistortOrder);
        }

19 Source : HashComparer.cs
with GNU Affero General Public License v3.0
from ACEmulator

public int Compare(int a, int b)
        {
            var keyA = a % NumBuckets;
            var keyB = b % NumBuckets;

            var result = keyA.CompareTo(keyB);

            if (result == 0)
                result = a.CompareTo(b);

            return result;
        }

19 Source : Feature.cs
with Microsoft Public License
from achimismaili

public int CompareTo(object obj)
        {
            if (!(obj is Feature))
            {
                throw (new System.ArgumentException("Object is not a Feature like the instance"));
            }
            Feature other = (Feature)obj;

            int cmp = this.Scope.CompareTo(other.Scope);
            if (cmp != 0)
            {
                return cmp;
            }

            cmp = string.Compare(this.Name, other.Name);
            if (cmp != 0)
            {
                return cmp;
            }
            cmp = this.Id.CompareTo(other.Id);
            if (cmp != 0)
            {
                return cmp;
            }
            cmp = this.CompatibilityLevel.CompareTo(other.CompatibilityLevel);
            return cmp;
        }

19 Source : PackageVersion.cs
with MIT License
from actions

public Int32 CompareTo(PackageVersion other)
        {
            Int32 rc = Major.CompareTo(other.Major);
            if (rc == 0)
            {
                rc = Minor.CompareTo(other.Minor);
                if (rc == 0)
                {
                    rc = Patch.CompareTo(other.Patch);
                }
            }

            return rc;
        }

19 Source : NumericValueComparer.cs
with MIT License
from Actipro

public override int Compare(IDataModel x, IDataModel y) {
			var xValue = 0;
			var yValue = 1;

			int.TryParse(x.DisplayName, out xValue);
			int.TryParse(y.DisplayName, out yValue);

			return xValue.CompareTo(yValue) * (this.SortDescending ? -1 : 1);
		}

19 Source : TextPosition.cs
with MIT License
from adamant

public int CompareTo(TextPosition other)
        {
            return CharacterOffset.CompareTo(other.CharacterOffset);
        }

19 Source : Version.cs
with Apache License 2.0
from adamralph

public int CompareTo(Version other)
        {
            if (other == null)
            {
                return 1;
            }

            var major = this.major.CompareTo(other.major);
            if (major != 0)
            {
                return major;
            }

            var minor = this.minor.CompareTo(other.minor);
            if (minor != 0)
            {
                return minor;
            }

            var patch = this.patch.CompareTo(other.patch);
            if (patch != 0)
            {
                return patch;
            }

            if (this.preReleaseIdentifiers.Count > 0 && other.preReleaseIdentifiers.Count == 0)
            {
                return -1;
            }

            if (this.preReleaseIdentifiers.Count == 0 && other.preReleaseIdentifiers.Count > 0)
            {
                return 1;
            }

            var maxCount = Max(this.preReleaseIdentifiers.Count, other.preReleaseIdentifiers.Count);
            for (var index = 0; index < maxCount; ++index)
            {
                if (this.preReleaseIdentifiers.Count == index && other.preReleaseIdentifiers.Count > index)
                {
                    return -1;
                }

                if (this.preReleaseIdentifiers.Count > index && other.preReleaseIdentifiers.Count == index)
                {
                    return 1;
                }

                if (int.TryParse(this.preReleaseIdentifiers[index], out var thisNumber) && int.TryParse(other.preReleaseIdentifiers[index], out var otherNumber))
                {
                    var number = thisNumber.CompareTo(otherNumber);
                    if (number != 0)
                    {
                        return number;
                    }
                }
                else
                {
                    var text = string.CompareOrdinal(this.preReleaseIdentifiers[index], other.preReleaseIdentifiers[index]);
                    if (text != 0)
                    {
                        return text;
                    }
                }
            }

            return this.height.CompareTo(other.height);
        }

19 Source : EntitySiteMapDisplayOrderComparer.cs
with MIT License
from Adoxio

public int Compare(Enreplacedy x, Enreplacedy y)
		{
			if (x == null && y == null)
			{
				return 0;
			}

			if (x == null)
			{
				return 1;
			}

			if (y == null)
			{
				return -1;
			}

			int? xDisplayOrder;
				
			// Try get a display order value for x.
			if (x.Attributes.Contains("adx_displayorder"))
			{
				try
				{
					xDisplayOrder = x.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					xDisplayOrder = null;
				}
			}
			else
			{
				xDisplayOrder = null;
			}

			int? yDisplayOrder;
				
			// Try get a display order value for y.
			if (y.Attributes.Contains("adx_displayorder"))
			{
				try
				{
					yDisplayOrder = y.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					yDisplayOrder = null;
				}
			}
			else
			{
				yDisplayOrder = null;
			}

			// If neither has a display order, they are ordered equally.
			if (!(xDisplayOrder.HasValue || yDisplayOrder.HasValue))
			{
				return 0;
			}

			// If x has no display order, and y does, order x after y.
			if (!xDisplayOrder.HasValue)
			{
				return 1;
			}

			// If x has a display order, and y does not, order y after x.
			if (!yDisplayOrder.HasValue)
			{
				return -1;
			}

			// If both have display orders, order by the comparison of that value.
			return xDisplayOrder.Value.CompareTo(yDisplayOrder.Value);
		}

19 Source : StyleExtensions.cs
with MIT License
from Adoxio

public int Compare(DisplayModeFile x, DisplayModeFile y)
			{
				if (x == null) throw new ArgumentNullException("x");
				if (y == null) throw new ArgumentNullException("y");

				if (x.Name.Item3 > y.Name.Item3)
				{
					return 1;
				}

				if (x.Name.Item3 < y.Name.Item3)
				{
					return -1;
				}

				var xIndex = _displayModes.FindIndex(displayMode => string.Equals(displayMode, x.DisplayModeId, StringComparison.OrdinalIgnoreCase));
				var yIndex = _displayModes.FindIndex(displayMode => string.Equals(displayMode, y.DisplayModeId, StringComparison.OrdinalIgnoreCase));

				return xIndex.CompareTo(yIndex);
			}

19 Source : CrmMetadataDataSourceView.cs
with MIT License
from Adoxio

public IEnumerable ExecuteSelect(
			string enreplacedyName,
			string attributeName,
			string sortExpression,
			EnreplacedyFilters enreplacedyFlags,
			EnreplacedyFilters metadataFlags,
			out int rowsAffected)
		{
			rowsAffected = 0;
			IEnumerable result = null;

			var client = OrganizationServiceContextFactory.Create(Owner.CrmDataContextName);

			if (!string.IsNullOrEmpty(enreplacedyName) && !string.IsNullOrEmpty(attributeName))
			{
				Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "RetrieveAttributeMetadata: enreplacedyName={0}, attributeName={1}, sortExpression={2}", enreplacedyName, attributeName, sortExpression);

				var metadata = client.RetrieveAttribute(enreplacedyName, attributeName);

				if (metadata is PicklistAttributeMetadata)
				{
					var picklist = metadata as PicklistAttributeMetadata;

					var options = picklist.OptionSet.Options.ToArray();

					if (!string.IsNullOrEmpty(sortExpression))
					{
						Array.Sort(
							options,
							delegate(OptionMetadata x, OptionMetadata y)
							{
								int comparison = 0;

								if (sortExpression.StartsWith("Value") || sortExpression.StartsWith("OptionValue"))
									comparison = x.Value.Value.CompareTo(y.Value.Value);
								else if (sortExpression.StartsWith("Label") || sortExpression.StartsWith("OptionLabel"))
									comparison = x.Label.UserLocalizedLabel.Label.CompareTo(y.Label.UserLocalizedLabel.Label);

								return (!sortExpression.EndsWith("DESC") ? comparison : -comparison);
							});
					}

					result = options.Select(option => new { OptionLabel = option.Label.UserLocalizedLabel.Label, OptionValue = option.Value });
					rowsAffected = options.Length;
				}
				else if (metadata is StatusAttributeMetadata)
				{
					var status = metadata as StatusAttributeMetadata;

					var options = (StatusOptionMetadata[])status.OptionSet.Options.ToArray();

					if (!string.IsNullOrEmpty(sortExpression))
					{
						Array.Sort(
							options,
							delegate(StatusOptionMetadata x, StatusOptionMetadata y)
							{
								int comparison = 0;

								if (sortExpression.StartsWith("Value") || sortExpression.StartsWith("OptionValue"))
									comparison = x.Value.Value.CompareTo(y.Value.Value);
								else if (sortExpression.StartsWith("Label") || sortExpression.StartsWith("OptionLabel"))
									comparison = x.Label.UserLocalizedLabel.Label.CompareTo(y.Label.UserLocalizedLabel.Label);
								else if (sortExpression.StartsWith("State"))
									comparison = x.State.Value.CompareTo(y.State.Value);

								return (!sortExpression.EndsWith("DESC") ? comparison : -comparison);
							});
					}

					result = options.Select(option => new { OptionLabel = option.Label.UserLocalizedLabel.Label, OptionValue = option.Value });
					rowsAffected = options.Length;
				}
				else if (metadata is StateAttributeMetadata)
				{
					var state = metadata as StateAttributeMetadata;

					var options = (StateOptionMetadata[])state.OptionSet.Options.ToArray();

					if (!string.IsNullOrEmpty(sortExpression))
					{
						Array.Sort(
							options,
							delegate(StateOptionMetadata x, StateOptionMetadata y)
							{
								int comparison = 0;

								if (sortExpression.StartsWith("Value") || sortExpression.StartsWith("OptionValue"))
									comparison = x.Value.Value.CompareTo(y.Value.Value);
								else if (sortExpression.StartsWith("Label") || sortExpression.StartsWith("OptionLabel"))
									comparison = x.Label.UserLocalizedLabel.Label.CompareTo(y.Label.UserLocalizedLabel.Label);
								else if (sortExpression.StartsWith("DefaultStatus"))
									comparison = x.DefaultStatus.Value.CompareTo(y.DefaultStatus.Value);

								return (!sortExpression.EndsWith("DESC") ? comparison : -comparison);
							});
					}

					result = options.Select(option => new { OptionLabel = option.Label.UserLocalizedLabel.Label, OptionValue = option.Value });
					rowsAffected = options.Length;
				}
			}
			else if (!string.IsNullOrEmpty(enreplacedyName))
			{
				Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "RetrieveEnreplacedyMetadata: enreplacedyName={0}, enreplacedyFlags={1}", enreplacedyName, enreplacedyFlags);

				var metadata = client.RetrieveEnreplacedy(enreplacedyName, enreplacedyFlags);
				
				result = metadata.Attributes;
				rowsAffected = metadata.Attributes.Length;
			}
			else
			{
				Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "RetrieveMetadata: metadataFlags={0}", metadataFlags);

				var metadata = client.RetrieveAllEnreplacedies(metadataFlags);

				result = metadata;
				rowsAffected = metadata.Length;
			}

			return result;
		}

19 Source : CrmSiteMapProvider.cs
with MIT License
from Adoxio

public int Compare(SiteMapNode x, SiteMapNode y)
			{
				var crmX = x as CrmSiteMapNode;
				var crmY = y as CrmSiteMapNode;

				// If neither are CrmSiteMapNodes, they are ordered equally.
				if (crmX == null && crmY == null)
				{
					return 0;
				}

				// If x is not a CrmSiteMapNode, and y is, order x after y.
				if (crmX == null)
				{
					return 1;
				}

				// If x is a CrmSiteMapNode, and y is not, order x before y.
				if (crmY == null)
				{
					return -1;
				}

				int? xDisplayOrder;
				
				// Try get a display order value for x.
				try
				{
					xDisplayOrder = crmX.Enreplacedy.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					xDisplayOrder = null;
				}

				int? yDisplayOrder;
				
				// Try get a display order value for y.
				try
				{
					yDisplayOrder = crmY.Enreplacedy.GetAttributeValue<int?>("adx_displayorder");
				}
				catch
				{
					yDisplayOrder = null;
				}

				// If neither has a display order, they are ordered equally.
				if (!(xDisplayOrder.HasValue || yDisplayOrder.HasValue))
				{
					return 0;
				}

				// If x has no display order, and y does, order x after y.
				if (!xDisplayOrder.HasValue)
				{
					return 1;
				}

				// If x has a display order, and y does not, order y after x.
				if (!yDisplayOrder.HasValue)
				{
					return -1;
				}

				// If both have display orders, order by the comparison of that value.
				return xDisplayOrder.Value.CompareTo(yDisplayOrder.Value);
			}

19 Source : ModEntry.cs
with GNU General Public License v3.0
from aedenthorn

public T Load<T>(IreplacedetInfo replacedet)
        {
            Monitor.Log($"loading replacedet for {replacedet.replacedetName}");

            if (replacedet.replacedetName.StartsWith("Characters\\Baby") || replacedet.replacedetName.StartsWith("Characters\\Toddler") || replacedet.replacedetName.StartsWith("Characters/Baby") || replacedet.replacedetName.StartsWith("Characters/Toddler"))
            {
                if(replacedet.replacedetNameEquals("Characters\\Baby") || replacedet.replacedetNameEquals("Characters\\Baby_dark") || replacedet.replacedetNameEquals("Characters\\Toddler") || replacedet.replacedetNameEquals("Characters\\Toddler_dark") || replacedet.replacedetNameEquals("Characters\\Toddler_girl") || replacedet.replacedetNameEquals("Characters\\Toddler_girl_dark"))
                {
                    Monitor.Log($"loading default child replacedet for {replacedet.replacedetName}");
                    return (T)(object)Helper.Content.Load<Texture2D>($"replacedets/{replacedet.replacedetName.Replace("Characters\\", "").Replace("Characters/", "")}.png", ContentSource.ModFolder);
                }
                if(replacedet.replacedetNameEquals("Characters/Baby") || replacedet.replacedetNameEquals("Characters/Baby_dark") || replacedet.replacedetNameEquals("Characters/Toddler") || replacedet.replacedetNameEquals("Characters/Toddler_dark") || replacedet.replacedetNameEquals("Characters/Toddler_girl") || replacedet.replacedetNameEquals("Characters/Toddler_girl_dark"))
                {
                    Monitor.Log($"loading default child replacedet for {replacedet.replacedetName}");
                    return (T)(object)Helper.Content.Load<Texture2D>($"replacedets/{replacedet.replacedetName.Replace("Characters/", "")}.png", ContentSource.ModFolder);
                }

                Monitor.Log($"loading child replacedet for {replacedet.replacedetName}");

                string[] names = replacedet.replacedetName.Split('_');
                Texture2D babySheet = Helper.Content.Load<Texture2D>(string.Join("_", names.Take(names.Length - 1)), ContentSource.GameContent);
                Texture2D parentTexSheet = null;
                string parent = names[names.Length - 1];
                try
                {
                    parentTexSheet = Helper.Content.Load<Texture2D>($"Characters/{parent}", ContentSource.GameContent);
                }
                catch
                {
                    return (T)(object)babySheet;
                }
                if (parentTexSheet == null)
                {
                    Monitor.Log($"couldn't find parent sheet for {replacedet.replacedetName}");
                    return (T)(object)babySheet;
                }
                Rectangle newBounds = parentTexSheet.Bounds;
                newBounds.X = 0;
                newBounds.Y = 64;
                newBounds.Width = 16;
                newBounds.Height = 32;
                Texture2D parentTex = new Texture2D(Game1.graphics.GraphicsDevice, 16, 32);
                Color[] data = new Color[parentTex.Width * parentTex.Height];
                parentTexSheet.GetData(0, newBounds, data, 0, newBounds.Width * newBounds.Height);
                
                int start = -1;
                Dictionary<Color, int> colorCounts = new Dictionary<Color, int>();
                for (int i = 0; i < data.Length; i++)
                {
                    if(data[i] != Color.Transparent)
                    {
                        if(start == -1)
                        {
                            start = i / 16;
                        }
                        else
                        {
                            if (i / 16 - start > 8)
                                break;
                        }
                        if (colorCounts.ContainsKey(data[i]))
                        {
                            colorCounts[data[i]]++;
                        }
                        else
                        {
                            colorCounts.Add(data[i], 1);
                            Monitor.Log($"got hair color: {data[i]}");
                        }
                    }
                }

                if(colorCounts.Count == 0)
                {
                    Monitor.Log($"parent sheet empty for {replacedet.replacedetName}");
                    return (T)(object)babySheet;
                }

                var countsList = colorCounts.ToList();

                countsList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));

                List<Color> hairColors = new List<Color>();
                for (int k = 0; k < Math.Min(countsList.Count, 4); k++)
                {
                    Monitor.Log($"using hair color: {countsList[k].Key} {countsList[k].Value}");
                    hairColors.Add(countsList[k].Key);
                }
                hairColors.Sort((color1, color2) => (color1.R + color1.G + color1.B).CompareTo(color2.R + color2.G + color2.B));

                Texture2D hairSheet = Helper.Content.Load<Texture2D>($"replacedets/hair/{string.Join("_", names.Take(names.Length - 1)).Replace("Characters\\","").Replace("Characters/","").Replace("_dark","")}.png", ContentSource.ModFolder);
                Color[] babyData = new Color[babySheet.Width * babySheet.Height];
                Color[] hairData = new Color[babySheet.Width * babySheet.Height];
                babySheet.GetData(babyData);
                hairSheet.GetData(hairData);

                for(int i = 0; i < babyData.Length; i++)
                {
                    if(hairData[i] != Color.Transparent)
                    {
                        if(hairColors.Count == 1)
                        {
                            hairColors.Add(hairColors[0]);
                            hairColors.Add(hairColors[0]);
                            hairColors.Add(hairColors[0]);
                        }
                        else if(hairColors.Count == 2)
                        {
                            hairColors.Add(hairColors[1]);
                            hairColors.Add(hairColors[1]);
                            hairColors[1] = new Color((hairColors[0].R + hairColors[0].R + hairColors[1].R) / 3, (hairColors[0].G + hairColors[0].G + hairColors[1].G) / 3, (hairColors[0].B + hairColors[0].B + hairColors[1].B) / 3);
                            hairColors[2] = new Color((hairColors[0].R + hairColors[2].R + hairColors[2].R) / 3, (hairColors[0].G + hairColors[2].G + hairColors[2].G) / 3, (hairColors[0].B + hairColors[2].B + hairColors[2].B) / 3);
                        }
                        else if(hairColors.Count == 3)
                        {
                            hairColors.Add(hairColors[2]);
                            hairColors[2] = new Color((hairColors[1].R + hairColors[2].R + hairColors[2].R) / 3, (hairColors[1].G + hairColors[2].G + hairColors[2].G) / 3, (hairColors[1].B + hairColors[2].B + hairColors[2].B) / 3);
                            hairColors[1] = new Color((hairColors[0].R + hairColors[0].R + hairColors[1].R) / 3, (hairColors[0].G + hairColors[0].G + hairColors[1].G) / 3, (hairColors[0].B + hairColors[0].B + hairColors[1].B) / 3);
                        }
                        //Monitor.Log($"Hair grey: {hairData[i].R}");
                        switch (hairData[i].R)
                        {
                            case 42:
                                babyData[i] = hairColors[0];
                                break;
                            case 60:
                                babyData[i] = hairColors[1];
                                break;
                            case 66:
                                babyData[i] = hairColors[1];
                                break;
                            case 82:
                                babyData[i] = hairColors[2];
                                break;
                            case 93:
                                babyData[i] = hairColors[2];
                                break;
                            case 114:
                                babyData[i] = hairColors[3];
                                break;
                        }
                            //Monitor.Log($"Hair color: {babyData[i]}");
                    }
                }
                babySheet.SetData(babyData);
                return (T)(object)babySheet;
            }
            throw new InvalidOperationException($"Unexpected replacedet '{replacedet.replacedetName}'.");
        }

19 Source : UIWidget.cs
with GNU General Public License v3.0
from aelariane

public static BetterList<UIWidget> Raycast(GameObject root, Vector2 mousePos)
    {
        BetterList<UIWidget> betterList = new BetterList<UIWidget>();
        UICamera uicamera = UICamera.FindCameraForLayer(root.layer);
        if (uicamera != null)
        {
            Camera cachedCamera = uicamera.cachedCamera;
            foreach (UIWidget uiwidget in root.GetComponentsInChildren<UIWidget>())
            {
                Vector3[] worldPoints = NGUIMath.CalculateWidgetCorners(uiwidget);
                if (NGUIMath.DistanceToRectangle(worldPoints, mousePos, cachedCamera) == 0f)
                {
                    betterList.Add(uiwidget);
                }
            }
            betterList.Sort((UIWidget w1, UIWidget w2) => w2.mDepth.CompareTo(w1.mDepth));
        }
        return betterList;
    }

19 Source : DocRange.cs
with MIT License
from Aeroblast

public int CompareTo(DocPoint other)
        {
            int i = 0;
            int r = 0;
            while (i < values.Count && i < other.values.Count)
            {
                r = values[i].CompareTo(other.values[i]);
                if (r != 0) break;
                i++;
            }
            return r;
        }

19 Source : TocManage.cs
with MIT License
from Aeroblast

int Compare(int i1, DocPoint p1, int i2, DocPoint p2)
        {
            if (i1 != i2) return i1.CompareTo(i2);
            if (p1 == null)
                if (p2 == null) return 0;
                else return -1;
            else
                if (p2 == null) return 1;

            return p1.CompareTo(p2);
        }

19 Source : ListViewItemComparer.cs
with GNU General Public License v3.0
from ahmed605

public int Compare(object x, object y)
        {
            if (x == null || y == null)
            {
                return 0;
            }

            try
            {
                if (_column > -1)
                {
                    int returnVal;
                    ListViewItem lvix = ((ListViewItem) x);
                    ListViewItem lviy = ((ListViewItem) y);

                    if (lvix.SubItems[_column].Tag is TimeSpan)
                    {
                        TimeSpan tx = (TimeSpan) lvix.SubItems[_column].Tag;
                        TimeSpan ty = (TimeSpan) lviy.SubItems[_column].Tag;
                        returnVal = tx.CompareTo(ty);
                    }
                    else if (lvix.SubItems[_column].Tag is int)
                    {
                        returnVal = ((int) lvix.SubItems[_column].Tag).CompareTo((int) lviy.SubItems[_column].Tag);
                    }
                    else
                    {
                        returnVal = String.Compare(lvix.SubItems[_column].Text, lviy.SubItems[_column].Text);
                    }

                    returnVal *= _descending ? -1 : 1;
                    return returnVal;
                }
                return 0;
            }
            catch
            {
                return 0;
            }
        }

19 Source : MiscellaneousUtils.cs
with MIT License
from akaskela

public static int ByteArrayCompare(byte[] a1, byte[] a2)
        {
            int lengthCompare = a1.Length.CompareTo(a2.Length);
            if (lengthCompare != 0)
            {
                return lengthCompare;
            }

            for (int i = 0; i < a1.Length; i++)
            {
                int valueCompare = a1[i].CompareTo(a2[i]);
                if (valueCompare != 0)
                {
                    return valueCompare;
                }
            }

            return 0;
        }

19 Source : NodesTree.cs
with MIT License
from alaabenfatma

public int CompareTo(object o)
        {
            var a = this;
            var b = (NodeItem) o;
            return b.NodesCount.CompareTo(a.NodesCount);
        }

19 Source : ImagePacker.cs
with MIT License
from Alan-FGR

public int PackImage(
			IEnumerable<string> imageFiles, 
			bool requirePowerOfTwo, 
			bool requireSquareImage, 
			int maximumWidth,
			int maximumHeight,
			int imagePadding,
			bool generateMap,
			out Bitmap outputImage, 
			out Dictionary<string, Rectangle> outputMap)
		{
			files = new List<string>(imageFiles);
			requirePow2 = requirePowerOfTwo;
			requireSquare = requireSquareImage;
			outputWidth = maximumWidth;
			outputHeight = maximumHeight;
			padding = imagePadding;

			outputImage = null;
			outputMap = null;

			// make sure our dictionaries are cleared before starting
			imageSizes.Clear();
			imagePlacement.Clear();

			// get the sizes of all the images
			foreach (var filePath in files)
			{
			    Bitmap bitmap;
			    using (var b = new Bitmap(filePath))
			    {
			        bitmap = new Bitmap(b); //FIXED! DARN NOOBS LOCKING MY FILESS!!!!! :trollface: - Alan, May 21, 3199BC
                    b.Dispose();
			    }
			    imageSizes.Add(filePath, bitmap.Size);
			}

			// sort our files by file size so we place large sprites first
			files.Sort(
				(f1, f2) =>
				{
					Size b1 = imageSizes[f1];
					Size b2 = imageSizes[f2];

					int c = -b1.Width.CompareTo(b2.Width);
					if (c != 0)
						return c;

					c = -b1.Height.CompareTo(b2.Height);
					if (c != 0)
						return c;

					return f1.CompareTo(f2);
				});

			// try to pack the images
			if (!PackImageRectangles())
				return -2;

			// make our output image
			outputImage = CreateOutputImage();
			if (outputImage == null)
				return -3;

			if (generateMap)
			{
				// go through our image placements and replace the width/height found in there with
				// each image's actual width/height (since the ones in imagePlacement will have padding)
				string[] keys = new string[imagePlacement.Keys.Count];
				imagePlacement.Keys.CopyTo(keys, 0);
				foreach (var k in keys)
				{
					// get the actual size
					Size s = imageSizes[k];

					// get the placement rectangle
					Rectangle r = imagePlacement[k];

					// set the proper size
					r.Width = s.Width;
					r.Height = s.Height;

					// insert back into the dictionary
					imagePlacement[k] = r;
				}

				// copy the placement dictionary to the output
				outputMap = new Dictionary<string, Rectangle>();
				foreach (var pair in imagePlacement)
				{
					outputMap.Add(pair.Key, pair.Value);
				}
			}

			// clear our dictionaries just to free up some memory
			imageSizes.Clear();
			imagePlacement.Clear();

			return 0;
		}

19 Source : Enumeration.cs
with MIT License
from AleksandreJavakhishvili

public int CompareTo(object other) => Id.CompareTo(((Enumeration)other).Id);

19 Source : BaseNode.cs
with MIT License
from alelievr

public bool UpdatePortsForFieldLocal(string fieldName, bool sendPortUpdatedEvent = true)
		{
			bool changed = false;

			if (!nodeFields.ContainsKey(fieldName))
				return false;

			var fieldInfo = nodeFields[fieldName];

			if (!HasCustomBehavior(fieldInfo))
				return false;

			List< string > finalPorts = new List< string >();

			var portCollection = fieldInfo.input ? (NodePortContainer)inputPorts : outputPorts;

			// Gather all fields for this port (before to modify them)
			var nodePorts = portCollection.Where(p => p.fieldName == fieldName);
			// Gather all edges connected to these fields:
			var edges = nodePorts.SelectMany(n => n.GetEdges()).ToList();

			if (fieldInfo.behavior != null)
			{
				foreach (var portData in fieldInfo.behavior(edges))
					AddPortData(portData);
			}
			else
			{
				var customPortTypeBehavior = customPortTypeBehaviorMap[fieldInfo.info.FieldType];

				foreach (var portData in customPortTypeBehavior(fieldName, fieldInfo.name, fieldInfo.info.GetValue(this)))
					AddPortData(portData);
			}

			void AddPortData(PortData portData)
			{
				var port = nodePorts.FirstOrDefault(n => n.portData.identifier == portData.identifier);
				// Guard using the port identifier so we don't duplicate identifiers
				if (port == null)
				{
					AddPort(fieldInfo.input, fieldName, portData);
					changed = true;
				}
				else
				{
					// in case the port type have changed for an incompatible type, we disconnect all the edges attached to this port
					if (!BaseGraph.TypesAreConnectable(port.portData.displayType, portData.displayType))
					{
						foreach (var edge in port.GetEdges().ToList())
							graph.Disconnect(edge.GUID);
					}

					// patch the port data
					if (port.portData != portData)
					{
						port.portData.CopyFrom(portData);
						changed = true;
					}
				}

				finalPorts.Add(portData.identifier);
			}

			// TODO
			// Remove only the ports that are no more in the list
			if (nodePorts != null)
			{
				var currentPortsCopy = nodePorts.ToList();
				foreach (var currentPort in currentPortsCopy)
				{
					// If the current port does not appear in the list of final ports, we remove it
					if (!finalPorts.Any(id => id == currentPort.portData.identifier))
					{
						RemovePort(fieldInfo.input, currentPort);
						changed = true;
					}
				}
			}

			// Make sure the port order is correct:
			portCollection.Sort((p1, p2) => {
				int p1Index = finalPorts.FindIndex(id => p1.portData.identifier == id);
				int p2Index = finalPorts.FindIndex(id => p2.portData.identifier == id);

				if (p1Index == -1 || p2Index == -1)
					return 0;

				return p1Index.CompareTo(p2Index);
			});

			if (sendPortUpdatedEvent)
				onPortsUpdated?.Invoke(fieldName);

			return changed;
		}

19 Source : CustomTextureManager.cs
with MIT License
from alelievr

static void UpdateDependencies()
    {
        computeOrder.Clear();
        sortedCustomRenderTextures.Clear();

        // Check if the CRTs are valid first:
        foreach (var crt in customRenderTextures)
            if (!IsValid(crt))
                computeOrder[crt] = -1;

        foreach (var crt in customRenderTextures)
            UpdateComputeOrder(crt, 0);
        
        foreach (var crt in customRenderTextures)
        {
            if (computeOrder.ContainsKey(crt) && computeOrder[crt] != -1)
                sortedCustomRenderTextures.Add(crt);
        }

        sortedCustomRenderTextures.Sort((c1, c2) => {
            if (!computeOrder.TryGetValue(c1, out int i1))
                i1 = -1;
            if (!computeOrder.TryGetValue(c2, out int i2))
                i2 = -1;

            return i1.CompareTo(i2);
        });
    }

19 Source : BaseGraphView.cs
with MIT License
from alelievr

GraphViewChange GraphViewChangedCallback(GraphViewChange changes)
		{
			if (changes.elementsToRemove != null)
			{
				RegisterCompleteObjectUndo("Remove Graph Elements");

				// Destroy priority of objects
				// We need nodes to be destroyed first because we can have a destroy operation that uses node connections
				changes.elementsToRemove.Sort((e1, e2) => {
					int GetPriority(GraphElement e)
					{
						if (e is BaseNodeView)
							return 0;
						else
							return 1;
					}
					return GetPriority(e1).CompareTo(GetPriority(e2));
				});

				//Handle ourselves the edge and node remove
				changes.elementsToRemove.RemoveAll(e => {

					switch (e)
					{
						case EdgeView edge:
							Disconnect(edge);
							return true;
						case BaseNodeView nodeView:
							// For vertical nodes, we need to delete them ourselves as it's not handled by GraphView
							foreach (var pv in nodeView.inputPortViews.Concat(nodeView.outputPortViews))
								if (pv.orientation == Orientation.Vertical)
									foreach (var edge in pv.GetEdges().ToList())
										Disconnect(edge);

							nodeInspector.NodeViewRemoved(nodeView);
							ExceptionToLog.Call(() => nodeView.OnRemoved());
							graph.RemoveNode(nodeView.nodeTarget);
							UpdateSerializedProperties();
							RemoveElement(nodeView);
							if (Selection.activeObject == nodeInspector)
								UpdateNodeInspectorSelection();

							SyncSerializedPropertyPathes();
							return true;
						case GroupView group:
							graph.RemoveGroup(group.group);
							UpdateSerializedProperties();
							RemoveElement(group);
							return true;
						case ExposedParameterFieldView blackboardField:
							graph.RemoveExposedParameter(blackboardField.parameter);
							UpdateSerializedProperties();
							return true;
						case BaseStackNodeView stackNodeView:
							graph.RemoveStackNode(stackNodeView.stackNode);
							UpdateSerializedProperties();
							RemoveElement(stackNodeView);
							return true;
#if UNITY_2020_1_OR_NEWER
						case StickyNoteView stickyNoteView:
							graph.RemoveStickyNote(stickyNoteView.note);
							UpdateSerializedProperties();
							RemoveElement(stickyNoteView);
							return true;
#endif
					}

					return false;
				});
			}

			return changes;
		}

19 Source : TemplateIdManager.cs
with MIT License
from alexismorin

public string BuildShader()
		{
			if( !m_isSorted )
			{
				m_registeredIds.Sort( ( x, y ) => { return x.StartIdx.CompareTo( y.StartIdx ); } );
			}

			int idCount = m_registeredIds.Count;
			int offset = 0;
			string finalShaderBody = m_shaderBody;
			for( int i = 0; i < idCount; i++ )
			{
				if( m_registeredIds[ i ].StartIdx >= 0 && m_registeredIds[ i ].IsReplaced )
				{
					finalShaderBody = finalShaderBody.ReplaceAt( m_registeredIds[ i ].Tag, m_registeredIds[ i ].ReplacementText, offset + m_registeredIds[ i ].StartIdx );
					offset += ( m_registeredIds[ i ].ReplacementText.Length - m_registeredIds[ i ].Tag.Length );
				}
			}

			int count = m_registeredPreplacedIds.Count;
			for( int i = 0; i < count; i++ )
			{
				if( m_registeredPreplacedIds[ i ].RemoveFromShader )
					finalShaderBody = finalShaderBody.Replace( m_registeredPreplacedIds[ i ].PreplacedId, string.Empty );
			}

			for( int i = 0; i < idCount; i++ )
			{
				if( !m_registeredIds[ i ].IsReplaced && !m_registeredIds[ i ].Tag.Equals( m_registeredIds[ i ].ReplacementText ) )
				{
					finalShaderBody = finalShaderBody.Replace( m_registeredIds[ i ].Tag, m_registeredIds[ i ].ReplacementText );
				}
			}

			count = m_registeredTags.Count;
			for( int i = 0; i < count; i++ )
			{
				finalShaderBody = finalShaderBody.Replace( m_registeredTags[ i ].Tag, m_registeredTags[ i ].Replacement );
			}

			//finalShaderBody = finalShaderBody.Replace( TemplatesManager.TemplateExcludeFromGraphTag, string.Empty );
			//finalShaderBody = finalShaderBody.Replace( TemplatesManager.TemplateMainPreplacedTag, string.Empty );

			return finalShaderBody;
		}

19 Source : TemplateIdManager.cs
with GNU General Public License v3.0
from alexismorin

public string BuildShader()
		{
			if( !m_isSorted )
			{
				m_registeredIds.Sort( ( x, y ) => { return x.StartIdx.CompareTo( y.StartIdx ); } );
			}

			int idCount = m_registeredIds.Count;
			int offset = 0;
			string finalShaderBody = m_shaderBody;
			for( int i = 0; i < idCount; i++ )
			{
				if( m_registeredIds[ i ].StartIdx >= 0 && m_registeredIds[ i ].IsReplaced )
				{
					finalShaderBody = finalShaderBody.ReplaceAt( m_registeredIds[ i ].Tag, m_registeredIds[ i ].ReplacementText, offset + m_registeredIds[ i ].StartIdx );
					offset += ( m_registeredIds[ i ].ReplacementText.Length - m_registeredIds[ i ].Tag.Length );
				}
			}

			for( int i = 0; i < idCount; i++ )
			{
				if( !m_registeredIds[ i ].IsReplaced )
				{
					finalShaderBody = finalShaderBody.Replace( m_registeredIds[ i ].Tag, m_registeredIds[ i ].ReplacementText );
				}
			}

			int tagCount = m_registeredTags.Count;
			for( int i = 0; i < tagCount; i++ )
			{
				finalShaderBody = finalShaderBody.Replace( m_registeredTags[ i ].Tag, m_registeredTags[ i ].Replacement );
			}

			finalShaderBody = finalShaderBody.Replace( TemplatesManager.TemplateExcludeFromGraphTag, string.Empty );
			finalShaderBody = finalShaderBody.Replace( TemplatesManager.TemplateMainPreplacedTag, string.Empty );
			
			return finalShaderBody;
		}

19 Source : DnsRecordBase.cs
with Apache License 2.0
from alexreinert

public int CompareTo(DnsRecordBase other)
		{
			int compare = Name.CompareTo(other.Name);
			if (compare != 0)
				return compare;

			compare = RecordType.CompareTo(other.RecordType);
			if (compare != 0)
				return compare;

			compare = RecordClreplaced.CompareTo(other.RecordClreplaced);
			if (compare != 0)
				return compare;

			compare = TimeToLive.CompareTo(other.TimeToLive);
			if (compare != 0)
				return compare;

			byte[] thisBuffer = new byte[MaximumRecordDataLength];
			int thisLength = 0;
			EncodeRecordData(thisBuffer, 0, ref thisLength, null, false);

			byte[] otherBuffer = new byte[other.MaximumRecordDataLength];
			int otherLength = 0;
			other.EncodeRecordData(otherBuffer, 0, ref otherLength, null, false);

			for (int i = 0; i < Math.Min(thisLength, otherLength); i++)
			{
				compare = thisBuffer[i].CompareTo(otherBuffer[i]);
				if (compare != 0)
					return compare;
			}

			return thisLength.CompareTo(otherLength);
		}

19 Source : DomainName.cs
with Apache License 2.0
from alexreinert

public int CompareTo(DomainName other)
		{
			for (int i = 1; i <= Math.Min(LabelCount, other.LabelCount); i++)
			{
				int labelCompare = String.Compare(Labels[LabelCount - i].ToLowerInvariant(), other.Labels[other.LabelCount - i].ToLowerInvariant(), StringComparison.Ordinal);

				if (labelCompare != 0)
					return labelCompare;
			}

			return LabelCount.CompareTo(other.LabelCount);
		}

19 Source : SortedListTests.cs
with MIT License
from AlFasGD

private int CustomComparison(int left, int right) => right.CompareTo(left);

19 Source : ClingyComponent.cs
with MIT License
from all-iver

public int Compare(ExecutionOrder a, ExecutionOrder b) {
                if (a.executionOrder == b.executionOrder)
                    return a.id.CompareTo(b.id);
                return a.executionOrder.CompareTo(b.executionOrder);
            }

19 Source : SceneManagerEditor.cs
with Apache License 2.0
from allenai

private static int PartCompare(string x, string y) {
        int a, b;
        if (int.TryParse(x, out a) && int.TryParse(y, out b))
            return a.CompareTo(b);
        return x.CompareTo(y);
    }

19 Source : ActionDispatcher.cs
with Apache License 2.0
from allenai

public int Compare(MethodInfo a, MethodInfo b) {
        int requiredParamCountA = requiredParamCount(a);
        int requiredParamCountB = requiredParamCount(b);
        int result = requiredParamCountA.CompareTo(requiredParamCountB);
        if (result == 0) {
            result = paramCount(a).CompareTo(paramCount(b));
        }
        return result;
    }

19 Source : FieldKey.cs
with MIT License
from Alprog

public int CompareTo(FieldKey other)
        {
            if (other.TypeId != this.TypeId)
            {
                return this.TypeId.CompareTo(other.TypeId);
            }
            else
            {
                return this.MemberId.CompareTo(other.MemberId);
            }
        }

19 Source : IntExtension.cs
with MIT License
from AlphaYu

public static bool InRange(this int @this, int minValue, int maxValue)
        {
            return @this.CompareTo(minValue) >= 0 && @this.CompareTo(maxValue) <= 0;
        }

19 Source : SuffixVersion.cs
with MIT License
from AmazingDM

public int CompareTo(SuffixVersion other)
        {
            var majorComparison = Major.CompareTo(other.Major);
            if (majorComparison != 0)
                return majorComparison;
            var minorComparison = Minor.CompareTo(other.Minor);
            if (minorComparison != 0)
                return minorComparison;
            var patchComparison = Patch.CompareTo(other.Patch);
            if (patchComparison != 0)
                return patchComparison;
            if (PreRelease == string.Empty)
                return other.PreRelease == string.Empty ? 0 : 1;
            if (other.PreRelease == string.Empty)
                return -1;
            var suffixComparison = string.Compare(PreRelease, other.PreRelease, StringComparison.Ordinal);
            if (suffixComparison != 0)
                return suffixComparison;
            return Build.CompareTo(other.Build);
        }

19 Source : Identity.cs
with MIT License
from ambleside138

public int CompareTo(Idenreplacedy<T> other)
        {
            if(IsTemporary)
            {
                if(other.IsTemporary)
                {
                    return TempValue.CompareTo(other.TempValue);
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                if (other.IsTemporary)
                {
                    return 1;
                }
                else
                {
                    return Value.CompareTo(other.Value);

                }
            }
        }

19 Source : Test NativeMinHeap.cs
with MIT License
from andrew-raphael-lukasik

int IComparer<int>.Compare ( int lhs , int rhs ) => lhs.CompareTo(rhs);

19 Source : IntId.cs
with MIT License
from andrewlock

public int CompareTo(IntId other) => Value.CompareTo(other.Value);

See More Examples