﻿// Decompiled with JetBrains decompiler
// Type: System.Web.UI.WebControls.XmlHierarchicalDataSourceView
// Assembly: System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// MVID: 7E68A73E-4066-4F24-AB0A-F147209F50EC
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Web.dll

using System.Runtime;
using System.Web.UI;
using System.Xml;

namespace System.Web.UI.WebControls
{
  /// <summary>
  /// Represents a data view on an XML node or collection of XML nodes for an <see cref="T:System.Web.UI.WebControls.XmlDataSource"/> control.
  /// </summary>
  public class XmlHierarchicalDataSourceView : HierarchicalDataSourceView
  {
    private XmlDataSource _owner;
    private string _viewPath;

    [TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
    internal XmlHierarchicalDataSourceView(XmlDataSource owner, string viewPath)
    {
      this._owner = owner;
      this._viewPath = viewPath;
    }

    /// <summary>
    /// Gets a list of the data items from the underlying data source.
    /// </summary>
    /// 
    /// <returns>
    /// An <see cref="T:System.Web.UI.IHierarchicalEnumerable"/> collection of data items based on the hierarchical level of the current view.
    /// </returns>
    public override IHierarchicalEnumerable Select()
    {
      XmlNode xmlNode1 = (XmlNode) this._owner.GetXmlDocument();
      XmlNodeList nodeList = (XmlNodeList) null;
      if (!string.IsNullOrEmpty(this._viewPath))
      {
        XmlNode xmlNode2 = xmlNode1.SelectSingleNode(this._viewPath);
        if (xmlNode2 != null)
          nodeList = xmlNode2.ChildNodes;
      }
      else
        nodeList = this._owner.XPath.Length <= 0 ? xmlNode1.ChildNodes : xmlNode1.SelectNodes(this._owner.XPath);
      return (IHierarchicalEnumerable) new XmlHierarchicalEnumerable(nodeList);
    }
  }
}
