public AutoDisposable MakeReadOnly(bool autoReleased = false, bool lockLayers = true) { AutoDisposable key = new AutoDisposable(); rokeys.Add(key); AutoDisposable[] layersKey = new AutoDisposable[layers.Length]; if (lockLayers) { for (int i = 0; i < layers.Length; i++) { layersKey[i] = layers[i].MakeReadOnly(autoReleased); } } void release() { rokeys.Remove(key); foreach (var item in layersKey) { item.Dispose(); } } key.Released += release; return(key); }
public AutoDisposable SupressUpdating() { AutoDisposable key = new AutoDisposable() { AutoRelease = true }; sukeys.Add(key); var layersSupressUpdating = layers.Select(a => a.SupressUpdating()).ToArray(); void release() { sukeys.Remove(key); if (sukeys.Count == 0) { OnUpdate(Update.Full, null); } key.Released -= release; foreach (var item in layersSupressUpdating) { item.Dispose(); } } key.Released += release; return(key); }