예제 #1
0
            public void Dispose(OpenGlContext context)
            {
                var disable = context.Enable();

                Parameters.Dispose();
                Model.Dispose();
                if (disable)
                {
                    context.Disable();
                }
            }
예제 #2
0
        /// <summary>
        /// disposes all filters from old list which are no longer used in new list
        /// </summary>
        /// <param name="newList"></param>
        /// <param name="oldList"></param>
        /// <param name="context"></param>
        public static void DisposeUnusedFilter(IReadOnlyList <FilterModel> newList, IReadOnlyList <FilterModel> oldList, OpenGlContext context)
        {
            var disable = context.Enable();

            foreach (var old in oldList)
            {
                // delete if the filter is not used in new list
                if (newList.All(newFilter => !ReferenceEquals(newFilter, old)))
                {
                    old.Dispose();
                }
            }

            if (disable)
            {
                context.Disable();
            }
        }