public FactHandle <T> Add <T>(T fact) where T : class { if (fact == null) { throw new ArgumentNullException(nameof(fact)); } var id = Interlocked.Increment(ref _nextId); var factHandle = new RuntimeFactHandle <T>(id, fact, Disconnect); lock (_connections) { _connections.Add(id, factHandle); } return(factHandle); }
public bool Equals(RuntimeFactHandle <T> x, RuntimeFactHandle <T> y) { if (ReferenceEquals(x, y)) { return(true); } if (ReferenceEquals(x, null)) { return(false); } if (ReferenceEquals(y, null)) { return(false); } if (x.GetType() != y.GetType()) { return(false); } return(x._id == y._id); }
public int GetHashCode(RuntimeFactHandle <T> obj) { return(obj._id.GetHashCode()); }