public uint Register(object value)
        {
            Type valueType = value.GetType();

            if (!_referencesByType.TryGetValue(valueType, out List <Reference> references))
            {
                references = new List <Reference>();
                _referencesByType.Add(valueType, references);
            }

            ReferenceDetectionMethod detectionMethod = _typeManager.GetTypeReferenceDetectionMethod(valueType);
            Reference newReference = new Reference(detectionMethod, _nextReferenceId, value);

            _nextReferenceId++;
            references.Add(newReference);
            return(newReference.Id);
        }
 public Reference(ReferenceDetectionMethod detectionMethod, uint id, object value)
 {
     _detectionMethod = detectionMethod;
     Id     = id;
     _value = value;
 }