Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1702


Ignore:
Timestamp:
04/29/09 14:34:19 (16 years ago)
Author:
epitzer
Message:

Move ReferenceEqualityComparer inside serializer. (#605)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Core/Serializer.cs

    r1701 r1702  
    99using System.Runtime.InteropServices;
    1010
    11 namespace HeuristicLab.Persistence.Core {
    12 
    13   public class ReferenceEqualityComparer : IEqualityComparer<object> {
    14 
    15     public bool Equals(object a, object b) {
    16       return Object.ReferenceEquals(a, b);
    17     }
    18 
    19     public int GetHashCode(object obj) {
    20       GCHandle handle = GCHandle.Alloc(obj, GCHandleType.Weak);
    21       int address = GCHandle.ToIntPtr(handle).ToInt32();
    22       handle.Free();
    23       return address;
    24     }   
    25 
    26   }
     11namespace HeuristicLab.Persistence.Core { 
    2712
    2813  public class Serializer : IEnumerable<ISerializationToken> {
     14
     15    class ReferenceEqualityComparer : IEqualityComparer<object> {
     16
     17      public bool Equals(object a, object b) {
     18        return Object.ReferenceEquals(a, b);
     19      }
     20
     21      public int GetHashCode(object obj) {
     22        GCHandle handle = GCHandle.Alloc(obj, GCHandleType.Weak);
     23        int address = GCHandle.ToIntPtr(handle).ToInt32();
     24        handle.Free();
     25        return address;
     26      }
     27
     28    }
    2929
    3030    private readonly object obj;
Note: See TracChangeset for help on using the changeset viewer.