Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }