Esempio n. 1
0
        public void AddSkip(SkipRule skip)
        {
            List <SkipRule> skips = new List <SkipRule>(_skipRules);

            skips.Add(skip);
            _skipRules = skips;
        }
Esempio n. 2
0
        public void RemoveSkip(SkipRule skip)
        {
            List <SkipRule> skips = new List <SkipRule>(_skipRules);
            int             index = skips.FindIndex
                                    (
                m => string.Equals(m.Expression, skip.Expression, StringComparison.OrdinalIgnoreCase)
                                    );

            if (index > -1)
            {
                skips.RemoveAt(index);
            }

            _skipRules = skips;
        }
Esempio n. 3
0
        public void LoadOrCreate()
        {
            XmlDocument     doc = new XmlDocument();
            XPathNavigator  nav = null;
            bool            hasMore;
            List <SkipRule> newSkips = new List <SkipRule>();

            ClearSkips();

            if (!FileHelper.FileSystem.File.Exists(_filePath))
            {
                Save();
                return;
            }

            using (Stream stream =
                       FileHelper.FileSystem.File.OpenRead(_filePath))
            {
                doc = new XmlDocument();
                doc.Load(stream);
            }

            nav = doc.CreateNavigator();
            nav.MoveToFirstChild();
            hasMore = nav.MoveToFirstChild();

            while (hasMore)
            {
                if (string.Equals(nav.Name, "skipRules", StringComparison.OrdinalIgnoreCase))
                {
                    bool hasMoreSkips = nav.MoveToFirstChild();
                    if (hasMoreSkips)
                    {
                        while (hasMoreSkips)
                        {
                            SkipRule rule = new SkipRule();
                            rule.Expression = nav.Value;

                            if (nav.MoveToFirstAttribute())
                            {
                                if (string.Equals(nav.Name, "isDirectory", StringComparison.OrdinalIgnoreCase))
                                {
                                    bool isDir = false;
                                    bool.TryParse(nav.Value, out isDir);
                                    rule.IsDirectory = isDir;
                                }

                                nav.MoveToParent();
                            }

                            newSkips.Add(rule);
                            hasMoreSkips = nav.MoveToNext();
                        }

                        _skipRules = newSkips;
                        nav.MoveToParent();
                    }
                }

                hasMore = nav.MoveToNext();
            }
        }
        public void LoadOrCreate()
        {
            XmlDocument doc = new XmlDocument();
            XPathNavigator nav = null;
            bool hasMore;
            List<SkipRule> newSkips = new List<SkipRule>();

            ClearSkips();

            if (!FileHelper.FileSystem.File.Exists(_filePath))
            {
                Save();
                return;
            }

            using (Stream stream =
                FileHelper.FileSystem.File.OpenRead(_filePath))
            {
                doc = new XmlDocument();
                doc.Load(stream);
            }

            nav = doc.CreateNavigator();
            nav.MoveToFirstChild();
            hasMore = nav.MoveToFirstChild();

            while (hasMore)
            {
                if (string.Equals(nav.Name, "skipRules", StringComparison.OrdinalIgnoreCase))
                {
                    bool hasMoreSkips = nav.MoveToFirstChild();
                    if (hasMoreSkips)
                    {
                        while (hasMoreSkips)
                        {
                            SkipRule rule = new SkipRule();
                            rule.Expression = nav.Value;

                            if (nav.MoveToFirstAttribute())
                            {
                                if (string.Equals(nav.Name, "isDirectory", StringComparison.OrdinalIgnoreCase))
                                {
                                    bool isDir = false;
                                    bool.TryParse(nav.Value, out isDir);
                                    rule.IsDirectory = isDir;
                                }

                                nav.MoveToParent();
                            }

                            newSkips.Add(rule);
                            hasMoreSkips = nav.MoveToNext();
                        }

                        _skipRules = newSkips;
                        nav.MoveToParent();
                    }
                }

                hasMore = nav.MoveToNext();
            }
        }
 public void AddSkip(SkipRule skip)
 {
     List<SkipRule> skips = new List<SkipRule>(_skipRules);
     skips.Add(skip);
     _skipRules = skips;
 }
        public void RemoveSkip(SkipRule skip)
        {
            List<SkipRule> skips = new List<SkipRule>(_skipRules);
            int index = skips.FindIndex
            (
                m => string.Equals(m.Expression, skip.Expression, StringComparison.OrdinalIgnoreCase)
            );

            if (index > -1)
            {
                skips.RemoveAt(index);
            }

            _skipRules = skips;
        }