Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorCss/Css/StaticSection.cs @ 12762

Last change on this file since 12762 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 1.6 KB
Line 
1
2using System;
3
4namespace SharpVectors.Dom.Css
5{
6    /// <summary>
7    /// Creates a static section for a CssXmlDocument.
8    /// Typical use:
9    /// using(StaticSection.Use(doc))
10    /// {
11    ///     // blah blah
12    /// }
13    /// </summary>
14    public sealed class StaticSection : IDisposable
15    {
16        /// <summary>
17        /// Previous Static state
18        /// </summary>
19        private bool _previousStatic;
20        /// <summary>
21        /// Document to be handled
22        /// </summary>
23        private CssXmlDocument _cssXmlDocument;
24
25        /// <summary>
26        /// Initializes a new instance of the <see cref="StaticSection"/> class.
27        /// </summary>
28        /// <param name="cssXmlDocument">The CSS XML document.</param>
29        private StaticSection(CssXmlDocument cssXmlDocument)
30        {
31            _cssXmlDocument = cssXmlDocument;
32            _previousStatic = cssXmlDocument.Static;
33            cssXmlDocument.Static = true;
34        }
35
36        /// <summary>
37        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
38        /// </summary>
39        public void Dispose()
40        {
41            _cssXmlDocument.Static = _previousStatic;
42        }
43
44        /// <summary>
45        /// Uses the specified CSS XML document with Static state to true.
46        /// </summary>
47        /// <param name="cssXmlDocument">The CSS XML document.</param>
48        public static IDisposable Use(CssXmlDocument cssXmlDocument)
49        {
50            return new StaticSection(cssXmlDocument);
51        }
52    }
53}
Note: See TracBrowser for help on using the repository browser.