Beispiel #1
0
        public static NetReference CreateForObject(object value, bool autoCreateIfNotExist = true)
        {
            if (value == null)
            {
                return(null);
            }

            var objectId = value.GetTag();

            if (!autoCreateIfNotExist && !objectId.HasValue)
            {
                // This item isn't tagged, so don't auto tag.
                return(null);
            }

            var typeInfo = NetTypeManager.GetTypeInfo(GetUnproxiedType(value.GetType()));

            if (typeInfo == null)
            {
                throw new InvalidOperationException($"Couldn't create type info from {value.GetType().AssemblyQualifiedName}");
            }

            objectId = value.GetOrCreateTag();
            var newNetReference = new NetReference(objectId.Value, typeInfo);

            ObjectIdReferenceTracker.OnReferenceCreated(value, objectId.Value);

            return(newNetReference);
        }
Beispiel #2
0
 public static void OnRelease(UInt64 objectId)
 {
     ObjectIdReferenceTracker.OnReferenceReleased(objectId);
 }