示例#1
0
 private static bool StrongRefByDefault(RefCounted refCounted)
 {
     //if (refCounted is Scene)
     //    return true;
     //if (refCounted is Context)
     //return true;
     return(false);
 }
示例#2
0
        public void Add(RefCounted refCounted)
        {
            lock (_knownObjects)
            {
                if (_knownObjects.TryGetValue(refCounted.Handle, out ReferenceHolder <RefCounted> knownObject))
                {
                    var existingObj = knownObject?.Reference;
                    if (existingObj != null &&
                        !IsInHierarchy(existingObj.GetType(), refCounted.GetType()))
                    {
                        throw new InvalidOperationException($"Handle '{refCounted.Handle}' is in use by '{existingObj.GetType().Name}' (IsDeleted={existingObj.IsDeleted}). {refCounted.GetType()}");
                    }
                }

                _knownObjects[refCounted.Handle] = new ReferenceHolder <RefCounted>(refCounted, weak: refCounted.Refs() < 1 && !StrongRefByDefault(refCounted));
            }
        }
示例#3
0
 public static void RegisterObject(RefCounted refCounted)
 {
     RefCountedCache.Add(refCounted);
 }