Example #1
0
        public bool MoveToFirstChild(string nameFilter = null)
        {
            ScopedNavigator me = null;

            if (this.AtResource)
            {
                me = (ScopedNavigator)this.Clone();

                // Is the current position not a contained resource?
                if (Parent?.ContainedResources().FirstOrDefault() == null)
                {
                    ResourceContext = _wrapped.Clone();
                }
            }

            if (!_wrapped.MoveToFirstChild(nameFilter))
            {
                return(false);
            }

            // If the current position is a resource, we'll be the new _parentScope
            if (me != null)
            {
                Parent = me;
            }

            _cache = new Cache();

            return(true);
        }
Example #2
0
        public bool MoveToFirstChild(string nameFilter = null)
        {
            bool exists = _navigator.MoveToFirstChild(nameFilter);

            if (exists)
            {
                _index = 0;
            }
            return(exists);
        }
        public bool MoveToFirstChild()
        {
            bool exists = _navigator.MoveToFirstChild();

            if (exists)
            {
                _index = 0;
            }
            return(exists);
        }
Example #4
0
        // Generate summary for a single artifact
        static ArtifactSummary generate(
            ArtifactSummaryPropertyBag props,
            IElementNavigator nav,
            ArtifactSummaryHarvester[] harvesters)
        {
            Exception error = null;

            // [WMR 20180419] Support empty harvester list (harvest only default props, no custom props)
            if (harvesters != null && harvesters.Length > 0)
            {
                try
                {
                    // Harvest summary information via specified harvesters
                    // Top-level harvesters receive navigator positioned on the first child element level

                    // Catch individual exceptions inside loop, return as AggregateException
                    var errors = new List <Exception>();
                    if (nav.MoveToFirstChild())
                    {
                        foreach (var harvester in harvesters)
                        {
                            try
                            {
                                if (harvester != null && harvester.Invoke(nav, props))
                                {
                                    break;
                                }
                            }
                            // TODO Catch specific exceptions
                            // catch (FormatException)
                            catch (Exception ex)
                            {
                                errors.Add(ex);
                            }
                        }
                    }

                    // Combine all errors into single AggregateException
                    error = errors.Count > 0 ? new AggregateException(errors) : null;
                }
                // TODO Catch specific exceptions
                // catch (FormatException)
                // catch (NotSupportedException)
                catch (Exception ex)
                {
                    // Error in summary factory?
                    // Make sure we always return a valid summary
                    error = ex;
                }
            }

            // Create final summary from harvested properties and optional error
            return(new ArtifactSummary(props, error));
        }
Example #5
0
        public bool MoveToFirstChild(string nameFilter = null)
        {
            ScopedNavigator me = null;

            if (this.AtResource)
            {
                me = (ScopedNavigator)this.Clone();
            }

            if (!_wrapped.MoveToFirstChild(nameFilter))
            {
                return(false);
            }

            // If the current position is a resource, we'll be the new _parentScope
            if (me != null)
            {
                Parent = me;
            }

            _cache = new Cache();

            return(true);
        }
 public bool MoveToFirstChild(string nameFilter = null) => _current.MoveToFirstChild(nameFilter);