ExsltNodeList.cs :  » Content-Management-Systems-CMS » umbraco » umbraco » presentation » xslt » Exslt » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » umbraco 
umbraco » umbraco » presentation » xslt » Exslt » ExsltNodeList.cs
using System;
using System.Collections;
using System.Xml.XPath;

namespace umbraco.presentation.xslt.Exslt{
  /// <summary>
  /// A list that holds XPathNavigator objects
  /// </summary>
  internal class ExsltNodeList
  {

    #region Private Fields and Properties

    /// <summary>
    /// The inner arraylist used by this class. 
    /// </summary>
    internal ArrayList innerList = new ArrayList();  

    #endregion

    
    #region Public Fields and Properties
    
    /// <summary>
    /// Gets or sets the element at the specified index
    /// </summary>
    public XPathNavigator this[int index] {
      get {return (XPathNavigator) this.innerList[index];}
      set { this.innerList[index] = value; }
    }

    /// <summary>
    /// Gets the number of items in the list
    /// </summary>
    public  int Count {get { return this.innerList.Count;}}

    #endregion
  

    #region Constructors
    
    public ExsltNodeList(){}


    /// <summary>
    /// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes 
    /// in the iterator are placed in the list. 
    /// </summary>
    /// <param name="iterator">The iterator to load the nodelist from</param>
    public ExsltNodeList(XPathNodeIterator iterator): this(iterator, false){;}


    
    /// <summary>
    /// Initializes the ExsltNodeList with the specified XPathNodeIterator. All nodes 
    /// in the iterator are placed in the list. 
    /// </summary>
    /// <param name="iterator">The iterator to load the nodelist from</param>
    /// <param name="removeDuplicates">A flag that indicates whether duplicate nodes 
    /// should be loaded into the nodelist or only node with unique identity should 
    /// be added</param>
    public ExsltNodeList(XPathNodeIterator iterator, bool removeDuplicates){
    
      XPathNodeIterator it = iterator.Clone(); 

      while(it.MoveNext()){
        
        if(removeDuplicates){
          if(this.Contains(it.Current)){
            continue; 
          }
        }
        
        this.Add(it.Current.Clone()); 
      }

    }

    #endregion


    #region Public Methods 


    /// <summary>
    /// Returns an enumerator for the entire list.
    /// </summary>
    /// <returns>An enumerator for the entire list</returns>
     public  IEnumerator GetEnumerator(){
      return this.innerList.GetEnumerator(); 
     }

    /// <summary>
    /// Adds an item to the list
    /// </summary>
    /// <param name="value">The item to add</param>
    /// <returns>The position into which the new element was inserted</returns>    
    public int Add( XPathNavigator nav){          

      return this.innerList.Add(nav); 
    }


    /// <summary>
    /// Removes all items from the list. 
    /// </summary>
    public void Clear(){
      this.innerList.Clear(); 
    }

    /// <summary>
    /// Determines whether the list contains a navigator positioned at the same 
    /// location as the specified XPathNavigator. This 
    /// method relies on the IsSamePositon() method of the XPathNavightor. 
    /// </summary>
    /// <param name="value">The object to locate in the list.</param>
    /// <returns>true if the object is found in the list; otherwise, false.</returns>
    public bool Contains(XPathNavigator value){
    
      foreach(XPathNavigator nav in this.innerList){
        if(nav.IsSamePosition(value)){
          return true;
        }
      }
      return false; 
    }

    /// <summary>
    /// Determines whether the list contains a navigator whose Value property matches
    /// the target value
    /// </summary>
    /// <param name="value">The value to locate in the list.</param>
    /// <returns>true if the value is found in the list; otherwise, false.</returns>
    public bool ContainsValue(string  value){
    
      foreach(XPathNavigator nav in this.innerList){
        if(nav.Value.Equals(value)){
          return true;
        }
      }
      return false; 
    }

    /// <summary>
    /// Determines the index of a specific item in the list.
    /// </summary>
    /// <param name="value">The object to locate in the list</param>
    /// <returns>The index of value if found in the list; otherwise, -1.</returns>
    public int IndexOf( object value  ){
    
      return this.innerList.IndexOf(value); 
    }

    /// <summary>
    /// Inserts an item to the list at the specified position.
    /// </summary>
    /// <param name="index">The zero-based index at which value should be inserted. </param>
    /// <param name="value">The object to insert into the list</param>    
    public void Insert(int index,XPathNavigator nav ){        

      this.innerList.Insert(index, nav); 
    }


    /// <summary>
    /// Removes the first occurrence of a specific object from the list.
    /// </summary>
    /// <param name="value">The object to remove from the list.</param>
    public void Remove(XPathNavigator nav){
    
      for(int i = 0; i < this.Count; i++){
        if(nav.IsSamePosition((XPathNavigator) this.innerList[i])){
          this.innerList.RemoveAt(i); 
          return; 
        } 
      }
    }

    /// <summary>
    /// Removes the list item at the specified index.
    /// </summary>
    /// <param name="index">The zero-based index of the item to remove.</param>
    public void RemoveAt(int index){
    
      this.innerList.RemoveAt(index); 
    }


    #endregion

  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.