public override void DestroyByType <T>(Func <T, bool> condition) { IRemoteObjectsHash objectsHash = null; IList <object> typedList; typedObjects.TryGetValue(typeof(T), out typedList); if (typedList == null) { return; } foreach (T obj in new List <object>(typedList)) { if (!condition(obj)) { continue; } if (objectsHash == null) { objectsHash = context.Resolve <IRemoteObjectsHash>(); } typedList.Remove(obj); destroyer.Destroy(obj, objectsHash); } }
public override void DestroyAll() { IRemoteObjectsHash objectsHash = context.Resolve <IRemoteObjectsHash>(); foreach (object o in objects) { destroyer.Destroy(o, objectsHash); } objects.Clear(); typedObjects.Clear(); }
private void DestroyMB(MonoBehaviour mb, IRemoteObjectsHash objectsHash) { objectsHash.Remove(mb.gameObject); var ct = mb as IDIClosedContext; if (ct != null) { ct.BeforeFactoryDestruction(); } GameObject.Destroy(mb.gameObject); }
private void RegisterRemoteObject(object instance, bool hashOnly = false) { if (!RemoteObjectsHelper.IsRemoteObject(instance)) { return; } IRemoteObjectsRecord remoteRecord = (IRemoteObjectsRecord)this.ResolveInternal(typeof(IRemoteObjectsRecord), null, null, false); if (!hashOnly) { remoteRecord.Register(instance); } else { IRemoteObjectsHash hash = (IRemoteObjectsHash)this.ResolveInternal(typeof(IRemoteObjectsHash), null, null, false); hash.Register(instance); } }
public void Destroy(object o, IRemoteObjectsHash objectsHash) { var mb = o as MonoBehaviour; if (mb != null) { DestroyMB(mb, objectsHash); return; } var fobj = o as FactoryObjectRecord; if (fobj != null) { DestroyFactoryObject(fobj); } var obj = o as UnityEngine.Object; if (obj != null) { DestroyDefault(obj, objectsHash); } }
private void DestroyDefault(UnityEngine.Object obj, IRemoteObjectsHash objectsHash) { objectsHash.Remove(obj); UnityEngine.Object.Destroy(obj); }