object.GetHashCode()

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

5038 Examples 7

19 View Source File : RasterCacheKey.cs
License : MIT License
Project Creator : adamped

public static uint functorMethod(RasterCacheKey<ID> key)
            {
               return (uint)key.GetHashCode();
            }

19 View Source File : PaymentDetailsResponse.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.AdditionalData != null)
                    hashCode = hashCode * 59 + this.AdditionalData.GetHashCode();
                if (this.Amount != null)
                    hashCode = hashCode * 59 + this.Amount.GetHashCode();
                if (this.DonationToken != null)
                    hashCode = hashCode * 59 + this.DonationToken.GetHashCode();
                if (this.MerchantReference != null)
                    hashCode = hashCode * 59 + this.MerchantReference.GetHashCode();
                if (this.FraudResult != null)
                    hashCode = hashCode * 59 + this.FraudResult.GetHashCode();
                if (this.Order != null)
                    hashCode = hashCode * 59 + this.Order.GetHashCode();
                if (this.PaymentMethod != null)
                    hashCode = hashCode * 59 + this.PaymentMethod.GetHashCode();
                if (this.PspReference != null)
                    hashCode = hashCode * 59 + this.PspReference.GetHashCode();
                if (this.RefusalReason != null)
                    hashCode = hashCode * 59 + this.RefusalReason.GetHashCode();
                if (this.RefusalReasonCode != null)
                    hashCode = hashCode * 59 + this.RefusalReasonCode.GetHashCode();
                if (this.ResultCode != null)
                    hashCode = hashCode * 59 + this.ResultCode.GetHashCode();
                if (this.ShopperLocale != null)
                    hashCode = hashCode * 59 + this.ShopperLocale.GetHashCode();
                if (this.ThreeDS2Result != null)
                    hashCode = hashCode * 59 + this.ThreeDS2Result.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : XshdReference.cs
License : MIT License
Project Creator : Abdesol

static int GetHashCode(object o)
		{
			return o != null ? o.GetHashCode() : 0;
		}

19 View Source File : Observable.cs
License : MIT License
Project Creator : Adam4lexander

public override int GetHashCode() {
            return value.GetHashCode();
        }

19 View Source File : BaseGenericInputSource.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

int IEqualityComparer.GetHashCode(object obj)
        {
            return obj.GetHashCode();
        }

19 View Source File : ReaderCache.cs
License : Apache License 2.0
Project Creator : aadreja

static int GetReaderHash(IDataReader reader)
        {
            unchecked
            {
                int hash = 31; //any prime number
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    object fieldName = reader.GetName(i);
                    object fieldType = reader.GetFieldType(i);

                    //prime numbers to generate hash
                    hash = (-97 * ((hash * 29) + fieldName.GetHashCode())) + fieldType.GetHashCode();
                }
                return hash;
            }
        }

19 View Source File : IVisitorContext.cs
License : MIT License
Project Creator : adrianoc

public override int GetHashCode()
        {
            unchecked
            {
                return (base.GetHashCode() * 397) ^ (Parameters != null ? Parameters.GetHashCode() : 0);
            }
        }

19 View Source File : VSCodeGenAccessors.cs
License : MIT License
Project Creator : 6tail

public override int GetHashCode() {
        return this.Target.GetHashCode();
    }

19 View Source File : CheckoutBalanceCheckResponse.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.AdditionalData != null)
                    hashCode = hashCode * 59 + this.AdditionalData.GetHashCode();
                if (this.Balance != null)
                    hashCode = hashCode * 59 + this.Balance.GetHashCode();
                if (this.FraudResult != null)
                    hashCode = hashCode * 59 + this.FraudResult.GetHashCode();
                if (this.PspReference != null)
                    hashCode = hashCode * 59 + this.PspReference.GetHashCode();
                if (this.RefusalReason != null)
                    hashCode = hashCode * 59 + this.RefusalReason.GetHashCode();
                if (this.ResultCode != null)
                    hashCode = hashCode * 59 + this.ResultCode.GetHashCode();
                if (this.TransactionLimit != null)
                    hashCode = hashCode * 59 + this.TransactionLimit.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : ReactiveTests.cs
License : MIT License
Project Creator : 71

[MethodImpl(MethodImplOptions.NoInlining)]
            public int ComputeHash(object obj)
            {
                return unchecked(obj.GetHashCode() * Seed);
            }

19 View Source File : PXGraphWithCreateInstanceInLambda.cs
License : GNU General Public License v3.0
Project Creator : Acumatica

private void MethodWhichInitializeAnotherGraph(PXAdapter adapter)
        {
            SOOrderMaint maint = PXGraph.CreateInstance<SOOrderMaint>();

            maint.GetHashCode();
        }

19 View Source File : Game.cs
License : Microsoft Public License
Project Creator : achimismaili

public override int GetHashCode()
        {
            return (_board != null ? _board.GetHashCode() : 0);
        }

19 View Source File : OverlayColorData.cs
License : Apache License 2.0
Project Creator : A7ocin

public override int GetHashCode()
		{
			return base.GetHashCode();
		}

19 View Source File : Self.cs
License : MIT License
Project Creator : adamant

public override int GetHashCode()
        {
            return self?.GetHashCode() ?? 0;
        }

19 View Source File : Maybe.cs
License : Apache License 2.0
Project Creator : 42skillz

public override int GetHashCode()
        {
            return this.HasItem ? this.Item.GetHashCode() : 0;
        }

19 View Source File : Global.cs
License : MIT License
Project Creator : adamped

public static string ShortHash(object obj)
        {
            return obj.GetHashCode().ToUnsigned(20).ToRadixString(16).PadLeft(5, '0');
        }

19 View Source File : FdbJoinedTuple.cs
License : MIT License
Project Creator : abdullin

public override int GetHashCode()
		{
			return ((IStructuralEquatable)this).GetHashCode(SimilarValueComparer.Default);
		}

19 View Source File : FraudResult.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.AccountScore != null)
                    hashCode = hashCode * 59 + this.AccountScore.GetHashCode();
                if (this.Results != null)
                    hashCode = hashCode * 59 + this.Results.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : RefType.cs
License : MIT License
Project Creator : 3F

public override int GetHashCode()
        {
            return Value.GetHashCode();
        }

19 View Source File : PaymentMethodsRequest.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.AdditionalData != null)
                    hashCode = hashCode * 59 + this.AdditionalData.GetHashCode();
                if (this.AllowedPaymentMethods != null)
                    hashCode = hashCode * 59 + this.AllowedPaymentMethods.GetHashCode();
                if (this.Amount != null)
                    hashCode = hashCode * 59 + this.Amount.GetHashCode();
                if (this.BlockedPaymentMethods != null)
                    hashCode = hashCode * 59 + this.BlockedPaymentMethods.GetHashCode();
                if (this.Channel != null)
                    hashCode = hashCode * 59 + this.Channel.GetHashCode();
                if (this.CountryCode != null)
                    hashCode = hashCode * 59 + this.CountryCode.GetHashCode();
                if (this.MerchantAccount != null)
                    hashCode = hashCode * 59 + this.MerchantAccount.GetHashCode();
                if (this.Order != null)
                    hashCode = hashCode * 59 + this.Order.GetHashCode();
                if (this.ShopperLocale != null)
                    hashCode = hashCode * 59 + this.ShopperLocale.GetHashCode();
                if (this.ShopperReference != null)
                    hashCode = hashCode * 59 + this.ShopperReference.GetHashCode();
                if (this.SplitCardFundingSources != null)
                    hashCode = hashCode * 59 + this.SplitCardFundingSources.GetHashCode();
                if (this.Store != null)
                    hashCode = hashCode * 59 + this.Store.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : FdbSlicedTuple.cs
License : MIT License
Project Creator : abdullin

int IStructuralEquatable.GetHashCode(IEqualityComparer comparer)
		{
			bool creplacedeCache = object.ReferenceEquals(comparer, SimilarValueComparer.Default);

			if (m_hashCode.HasValue && creplacedeCache)
			{
				return m_hashCode.Value;
			}

			int h = 0;
			for (int i = 0; i < m_count; i++)
			{
				h = FdbTuple.CombineHashCodes(h, comparer.GetHashCode(m_slices[i + m_offset]));
			}
			if (creplacedeCache) m_hashCode = h;
			return h;
		}

19 View Source File : ServiceId.cs
License : MIT License
Project Creator : abdullin

public int GetHashCode(T obj) {
            return _selector(obj).GetHashCode();
        }

19 View Source File : MathExtension.cs
License : MIT License
Project Creator : 3F

public static int CalculateHashCode(this int r, params object[] values)
        {
            int h = r;
            foreach(var v in values) {
                h = h.HashPolynom(v?.GetHashCode() ?? 0);
            }
            return h;
        }

19 View Source File : BaseSpatialObserver.cs
License : Apache License 2.0
Project Creator : abist-co-ltd

public int GetHashCode(object obj)
        {
            return obj.GetHashCode();
        }

19 View Source File : SimpleJSON.cs
License : MIT License
Project Creator : 734843327

public override int GetHashCode ()
		{
			return base.GetHashCode();
		}

public int GetKey()
        {
            SWKMapadocConnMaint maint = PXGraph.CreateInstance<SWKMapadocConnMaint>();

            return maint.GetHashCode();
        }

19 View Source File : ExpressionValue.cs
License : MIT License
Project Creator : actions

public override Int32 GetHashCode()
        {
            if (IsLiteral)
            {
                if (Literal != null)
                {
                    return Literal.GetHashCode();
                }
            }
            else if (Expression != null)
            {
                return Expression.GetHashCode();
            }

            return 0; // unspecified expression values are all the same.
        }

19 View Source File : GeometrySelectorWindow.cs
License : Apache License 2.0
Project Creator : A7ocin

void OnSceneGUI()
        {
            const float WindowHeight = 140;
            const float WindowWidth = 380;
            const float Margin = 20;

            ResetLabelStart();

            Handles.BeginGUI();

            GUI.Window(1, new Rect(SceneView.lastActiveSceneView.position.width -(WindowWidth+Margin), SceneView.lastActiveSceneView.position.height - (WindowHeight+Margin), WindowWidth, WindowHeight), SceneWindow, "UMA Mesh Hide Geometry Selector");
            DrawNextLabel("Left click and drag to area select");
            DrawNextLabel( "Hold SHIFT while dragging to paint");
            DrawNextLabel("Hold ALT while dragging to orbit");
            DrawNextLabel("Return to original scene by pressing \"Save and Return\"");
            Handles.EndGUI();

            if (_Source == null)
                return;
            
            if (!isSelecting && Event.current.alt)
                return;

            if (!isSelecting && Event.current.control)
                return;
            
            Rect selectionRect = new Rect();

            if (Event.current.type == EventType.Layout)
                HandleUtility.AddDefaultControl(GUIUtility.GetControlID(GetHashCode(), FocusType.Preplacedive));

            if (isSelecting)
            {
                Vector2 selectionSize = (Event.current.mousePosition - startMousePos);
                Vector2 correctedPos = startMousePos;
                if (selectionSize.x < 0)
                {
                    selectionSize.x = Mathf.Abs(selectionSize.x);
                    correctedPos.x = startMousePos.x - selectionSize.x;
                }
                if (selectionSize.y < 0)
                {
                    selectionSize.y = Mathf.Abs(selectionSize.y);
                    correctedPos.y = startMousePos.y - selectionSize.y;
                }

                if (Event.current.shift)
                {
                    startMousePos = Event.current.mousePosition;

                    int triangleHit = RayPick();
                    if (triangleHit >= 0)
                    {
                        if (_Source.selectedTriangles[triangleHit] != setSelectedOn)
                        {
                            // avoid constant rebuild.
                            _Source.selectedTriangles[triangleHit] = setSelectedOn;
                            _Source.UpdateSelectionMesh();
                        }
                    }
                }
                else if (selectionSize.x > drawTolerance || selectionSize.y > drawTolerance)
                {
                    Handles.BeginGUI();
                    selectionRect = new Rect(correctedPos, selectionSize);
                    Handles.DrawSolidRectangleWithOutline(selectionRect, selectionColor, Color.black);
                    Handles.EndGUI();
                    HandleUtility.Repaint();
                }

                if (Event.current.type == EventType.MouseDrag)
                {
                    SceneView.RepaintAll();
                    Event.current.Use();
                    return;
                }
            }

            //Single mouse click
            if (Event.current != null && Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                isSelecting = true;
                startMousePos = Event.current.mousePosition;

                int triangleHit = RayPick();
                if (triangleHit >= 0)
                {
                    _Source.selectedTriangles[triangleHit] = !_Source.selectedTriangles[triangleHit];
                    _Source.UpdateSelectionMesh();
                }
            }

            if (Event.current != null && Event.current.type == EventType.MouseUp && Event.current.button == 0)
            {
                if (isSelecting)
                {
                    isSelecting = false;

                    int[] triangles = _Source.meshreplacedet.replacedet.meshData.submeshes[0].triangles;
                    for(int i = 0; i < triangles.Length; i+=3 )
                    {
                        bool found = false;
                        Vector3 center = new Vector3();
                        Vector3 centerNormal = new Vector3();

                        for (int k = 0; k < 3; k++)
                        {
                            Vector3 vertex = _Source.meshreplacedet.replacedet.meshData.vertices[triangles[i+k]];
                            vertex = _Source.transform.localToWorldMatrix.MultiplyVector(vertex);

                            Vector3 normal = _Source.meshreplacedet.replacedet.meshData.normals[triangles[i+k]];
                            normal = _Source.transform.localToWorldMatrix.MultiplyVector(normal);

                            center += vertex;
                            centerNormal += normal;

                            vertex = SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(vertex);
                            vertex.y = SceneView.currentDrawingSceneView.camera.pixelHeight - vertex.y;

                            if (selectionRect.Contains( vertex ))
                            {
                                if (backfaceCull)
                                {
                                    if (Vector3.Dot(normal, SceneView.currentDrawingSceneView.camera.transform.forward) < -0.0f)
                                        found = true;
                                }
                                else
                                    found = true;
                            }
                        }

                        center = center / 3;
                        centerNormal = centerNormal / 3;
                        center = SceneView.currentDrawingSceneView.camera.WorldToScreenPoint(center);
                        center.y = SceneView.currentDrawingSceneView.camera.pixelHeight - center.y;
                        if (selectionRect.Contains(center))
                        {
                            if (backfaceCull)
                            {
                                if (Vector3.Dot(centerNormal, SceneView.currentDrawingSceneView.camera.transform.forward) < -0.0f)
                                    found = true;
                            }
                            else
                                found = true;
                        }

                        if (found)
                            _Source.selectedTriangles[(i / 3)] = setSelectedOn;
                    }

                    _Source.UpdateSelectionMesh();
                }
            }

            if (Event.current.type == EventType.MouseMove)
            {
                SceneView.RepaintAll();
            }
        }

public override void Initialize()
        {
            SWKMapadocConnMaint maint = PXGraph.CreateInstance<SWKMapadocConnMaint>();
            int key = maint.GetHashCode();
        }

19 View Source File : ArgumentHasher.cs
License : Apache License 2.0
Project Creator : 42skillz

private static int GetByValueHashCode(IEnumerable collection)
        {
            var hash = 17;

            foreach (var element in collection)
            {
                var parameterHashCode = element?.GetHashCode() ?? 17;
                hash = hash * 23 + parameterHashCode;
            }

            return hash;
        }

19 View Source File : FixedSet.cs
License : MIT License
Project Creator : adamant

public override int GetHashCode()
        {
            HashCode hash = new HashCode();
            // Order the hash codes so there is a consistent hash order
            foreach (var item in items.OrderBy(i => i?.GetHashCode()))
                hash.Add(item);
            return hash.ToHashCode();
        }

19 View Source File : Program.cs
License : Apache License 2.0
Project Creator : aadreja

static void Main(string[] args)
        {
            DapperTry();

            var t = new { Id = 1 };
            Console.WriteLine("Type {0} Hash {1}", t.GetType().Name, t.GetHashCode());

            var t1 = new { Id = "abc" };
            Console.WriteLine("Type {0} Hash {1}", t1.GetType().Name, t1.GetHashCode());

            var t2 = new { Id = 2 };
            Console.WriteLine("Type {0} Hash {1}", t2.GetType().Name, t2.GetHashCode());

            var t3 = new { Id = "xyz" };
            Console.WriteLine("Type {0} Hash {1}", t3.GetType().Name, t3.GetHashCode());

            defaultColor = Console.ForegroundColor;

            WriteLine("-------------------------------------------", ConsoleColor.Green);
            WriteLine("Vega(Fastest .net ORM) - Sample Application", ConsoleColor.Green);
            WriteLine("-------------------------------------------", ConsoleColor.Green);

            WriteLine("Creating Database with Sample Data");

            CreateDBWithSampleData();

            long id = InsertSample();
            UpdateSample(id);
            ReadById(id);
            DeleteSample(id);
            Read();
            ReadPaged();
            AuditTrial(id);
            PerformanceTest pTest = new PerformanceTest();
            pTest.Run();

            Console.ReadKey();
        }

19 View Source File : DmnExecutionVariable.cs
License : MIT License
Project Creator : adamecr

public override int GetHashCode()
        {
            unchecked
            {
                var hash = 17;
                hash = hash * 23 + Name.GetHashCode();
                hash = hash * 23 + (Value?.GetHashCode() ?? 0);
                return hash;
            }
        }

19 View Source File : IExprTableSource.cs
License : MIT License
Project Creator : 0x1000000

public override int GetHashCode()
        {
            unchecked
            {
                return (this.Tables.GetHashCode() * 397) ^ (this.On != null ? this.On.GetHashCode() : 0);
            }
        }

19 View Source File : Global.cs
License : MIT License
Project Creator : adamped

public static string DescribeIdenreplacedy(object obj)
        {
            return $"{obj.GetType()}#{obj.GetHashCode()}";
        }

19 View Source File : ReaderCache.cs
License : Apache License 2.0
Project Creator : aadreja

static int GetParameterHash(object dynamicObject)
        {
            unchecked
            {
                int hash = 31; //any prime number
                PropertyInfo[] propertyInfo = dynamicObject.GetType().GetProperties();
                for (int i = 0; i < propertyInfo.Length; i++)
                {
                    object propertyName = propertyInfo[i].Name;
                    //dynamic property will always return System.Object as property type. Get Type from the value
                    Type propertyType = GetTypeOfDynamicProperty(propertyInfo[i], dynamicObject);

                    //prime numbers to generate hash
                    hash = (-97 * ((hash * 29) + propertyName.GetHashCode())) + propertyType.GetHashCode();
                }
                return hash;
            }
        }

19 View Source File : Expression.cs
License : MIT License
Project Creator : Adoxio

public override int GetHashCode()
		{
			return (Operands != null ? Operands.GetHashCode() : 0);
		}

19 View Source File : ExpressionTree.cs
License : MIT License
Project Creator : 71

public int GetHashCode(Expression obj) => obj.GetHashCode();

19 View Source File : CecilDefinitionsFactory.cs
License : MIT License
Project Creator : adrianoc

public static IEnumerable<string> MethodBody(string methodVar, string ilVar, InstructionRepresentation[] instructions)
        {
            var tagToInstructionDefMapping = new Dictionary<string, string>();
            var exps = new List<string>();
            exps.Add($"{methodVar}.Body = new MethodBody({methodVar});");

            exps.Add($"var {ilVar} = {methodVar}.Body.GetILProcessor();");
            var methodInstVar = $"{methodVar}_inst";
            exps.Add($"var {methodInstVar} = {methodVar}.Body.Instructions;");

            foreach (var inst in instructions)
            {
                var instVar = "_";
                if (inst.tag != null)
                {
                    instVar = $"{inst.tag}_inst_{instructions.GetHashCode()}";
                    exps.Add($"Instruction {instVar};");
                    tagToInstructionDefMapping[inst.tag] = instVar;
                }

                var operand = inst.operand?.Insert(0, ", ")
                              ?? inst.branchTargetTag?.Replace(inst.branchTargetTag, $", {tagToInstructionDefMapping[inst.branchTargetTag]}")
                              ?? string.Empty;

                exps.Add($"{methodInstVar}.Add({instVar} = {ilVar}.Create({inst.opCode.ConstantName()}{operand}));");
            }

            return exps;
        }

19 View Source File : FdbPrefixedTuple.cs
License : MIT License
Project Creator : abdullin

int IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer)
		{
			return FdbTuple.CombineHashCodes(
				m_prefix.GetHashCode(),
				comparer.GetHashCode(m_items)
			);
		}

19 View Source File : InputDetail.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.Configuration != null)
                    hashCode = hashCode * 59 + this.Configuration.GetHashCode();
                if (this.Details != null)
                    hashCode = hashCode * 59 + this.Details.GetHashCode();
                if (this.InputDetails != null)
                    hashCode = hashCode * 59 + this.InputDetails.GetHashCode();
                if (this.ItemSearchUrl != null)
                    hashCode = hashCode * 59 + this.ItemSearchUrl.GetHashCode();
                if (this.Items != null)
                    hashCode = hashCode * 59 + this.Items.GetHashCode();
                if (this.Key != null)
                    hashCode = hashCode * 59 + this.Key.GetHashCode();
                if (this.Optional != null)
                    hashCode = hashCode * 59 + this.Optional.GetHashCode();
                if (this.Type != null)
                    hashCode = hashCode * 59 + this.Type.GetHashCode();
                if (this.Value != null)
                    hashCode = hashCode * 59 + this.Value.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : CelesteNetTCPUDPConnection.cs
License : MIT License
Project Creator : 0x0ade

public void StartReadUDP() {
            if (UDP == null || ReadUDPThread != null)
                return;

            UDPLocalEndPoint = (IPEndPoint?) UDP.Client.LocalEndPoint;
            try {
                UDPRemoteEndPoint = (IPEndPoint?) UDP.Client.RemoteEndPoint;
            } catch (Exception) {
                UDPRemoteEndPoint = TCPRemoteEndPoint;
            }

            ReadUDPThread = new(ReadUDPLoop) {
                Name = $"{GetType().Name} ReadUDP ({Creator} - {GetHashCode()})",
                IsBackground = true
            };
            ReadUDPThread.Start();
        }

19 View Source File : PaymentMethod.cs
License : MIT License
Project Creator : Adyen

public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = 41;
                if (this.Brand != null)
                    hashCode = hashCode * 59 + this.Brand.GetHashCode();
                if (this.Brands != null)
                    hashCode = hashCode * 59 + this.Brands.GetHashCode();
                if (this.Configuration != null)
                    hashCode = hashCode * 59 + this.Configuration.GetHashCode();
                if (this.FundingSource != null)
                    hashCode = hashCode * 59 + this.FundingSource.GetHashCode();
                if (this.Group != null)
                    hashCode = hashCode * 59 + this.Group.GetHashCode();
                if (this.InputDetails != null)
                    hashCode = hashCode * 59 + this.InputDetails.GetHashCode();
                if (this.Issuers != null)
                    hashCode = hashCode * 59 + this.Issuers.GetHashCode();
                if (this.Name != null)
                    hashCode = hashCode * 59 + this.Name.GetHashCode();
                if (this.Type != null)
                    hashCode = hashCode * 59 + this.Type.GetHashCode();
                return hashCode;
            }
        }

19 View Source File : SimilarValueComparer.cs
License : MIT License
Project Creator : abdullin

int IEqualityComparer<object>.GetHashCode(object obj)
		{
			return obj == null ? -1 : obj.GetHashCode();
		}

19 View Source File : SimpleJSON.cs
License : MIT License
Project Creator : 71

public override int GetHashCode()
        {
            return base.GetHashCode();
        }

19 View Source File : TCPUDPServer.cs
License : MIT License
Project Creator : 0x0ade

public void Start() {
            Logger.Log(LogLevel.CRI, "tcpudp", $"Startup on port {Server.Settings.MainPort}");

            TCPListener = new(IPAddress.IPv6Any, Server.Settings.MainPort);
            TCPListener.Server.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);
            TCPListener.Start();

            TCPListenerThread = new(TCPListenerLoop) {
                Name = $"TCPUDPServer TCPListener ({GetHashCode()})",
                IsBackground = true
            };
            TCPListenerThread.Start();

            int numUdpThreads = Server.Settings.NumUDPThreads;
            bool udpSend = Server.Settings.UDPSend;
            if (numUdpThreads <= 0) {
                // Determine suitable number of UDP threads
                // On Windows, having multiple threads isn't an advantage at all, so start only one
                // On Linux/MacOS, spawn one thread for each logical core
                if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX)
                    numUdpThreads = 1;
                else
                    numUdpThreads = Environment.ProcessorCount;
            }
            Logger.Log(LogLevel.CRI, "tcpudp", $"Starting {numUdpThreads} UDP threads");

            UDPs = new UdpClient[numUdpThreads];
            UDPReadThreads = new Thread[numUdpThreads];
            for (int i = 0; i < numUdpThreads; i++) {
                Socket udpSocket = new(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp);
                udpSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);

                if (numUdpThreads > 1) {
                    udpSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.ReuseAddress, true);

                    // Some Linux/MacOS runtimes don't automatically set SO_REUSEPORT (the option we care about), so set it directly, just in case
                    if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) {
                        if (setsockopt(udpSocket.Handle, SOL_SOCKET, SO_REUSEPORT, new[] { 1 }, sizeof(int)) < 0) {
                            // Even though the method is named GetLastWin32Error, it still works on other platforms
                            // NET 6.0 added the better named method GetLastPInvokeError, which does the same thing
                            // However, still use GetLastWin32Error to remain compatible with the net452 build target
                            Logger.Log(LogLevel.WRN, "tcpudp", $"Failed enabling UDP socket option SO_REUSEPORT for socket {i}: {Marshal.GetLastWin32Error()}");
                        }
                    } else if (i == 0) {
                        // We only have an advantage with multiple threads when SO_REUSEPORT is supported
                        // It tells the Linux kernel to distribute incoming packets evenly among all sockets bound to that port
                        // However, Windows doesn't support it, and it's SO_REUSEADDR behaviour is that only one socket will receive everything 
                        // As such only one thread will handle all messages and actually do any work
                        // TODO BSD/MacOS also supports SO_REUSEPORT, but I couldn't find any explicit mention of the load-balancing behaviour we're looking for
                        // So it might be better to also warn on BSD/MacOS, or make this feature Linux exclusive
                        Logger.Log(LogLevel.WRN, "tcpudp", "Starting more than one UDP thread on a platform without SO_REUSEPORT!");
                    }
                }

                udpSocket.Bind(new IPEndPoint(IPAddress.IPv6Any, Server.Settings.MainPort));
                UDPs[i] = new(AddressFamily.InterNetworkV6);
                UDPs[i].Client.Dispose();
                UDPs[i].Client = udpSocket;

                // This is neccessary, as otherwise i could increment before the thread function is called
                int idx = i;
                UDPReadThreads[i] = new(() => UDPReadLoop(idx, udpSend)) {
                    Name = $"TCPUDPServer UDPRead {i} ({GetHashCode()})",
                    IsBackground = true
                };
                UDPReadThreads[i].Start();
            }

19 View Source File : CelesteNetTCPUDPConnection.cs
License : MIT License
Project Creator : 0x0ade

public void StartReadTCP() {
            if (TCP == null || ReadTCPThread != null)
                return;

            TCPLocalEndPoint = (IPEndPoint?) TCP.Client.LocalEndPoint;
            TCPRemoteEndPoint = (IPEndPoint?) TCP.Client.RemoteEndPoint;

            ReadTCPThread = new(ReadTCPLoop) {
                Name = $"{GetType().Name} ReadTCP ({Creator} - {GetHashCode()})",
                IsBackground = true
            };
            ReadTCPThread.Start();
        }

19 View Source File : ArgumentHasher.cs
License : Apache License 2.0
Project Creator : 42skillz

public static int HashArguments(params object[] arguments)
        {
            var hash = 17;
            foreach (var argument in arguments)
            {
                if (argument is IEnumerable enumerable)
                {
                    var parameterHashCode = GetByValueHashCode(enumerable);
                    hash = hash * 23 + parameterHashCode;
                }
                else
                {
                    var parameterHashCode = argument?.GetHashCode() ?? 17;
                    hash = hash * 23 + parameterHashCode;
                }
            }

            return hash;
        }

19 View Source File : Paradigm.cs
License : MIT License
Project Creator : 8T4

public override int GetHashCode()
        {
            return (Syntagmas != null ? Syntagmas.GetHashCode() : 0);
        }

19 View Source File : PropertiesCollection.cs
License : MIT License
Project Creator : actions

public override Int32 GetHashCode()
        {
            return base.GetHashCode();
        }

See More Examples