// Noddybox.Net - Provides simple server interaction classes
// Copyright (C) 2003 Ian Cowburn
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// $Id$
//
namespace Noddybox.Net
{
using System;
using System.Collections;
///
/// Collection of FTPFile objects
///
///
/// created by - ianc
/// created on - 14/09/2003 18:02:58
///
public class FTPFileCollection : IEnumerable
{
// -------------------------------------------------
// - PUBLIC MEMBERS -
// -------------------------------------------------
///
/// Default constructor - initializes all fields to default values
///
public FTPFileCollection()
{
m_list=new ArrayList();
}
///
/// Number of files in the collection
///
public int Count
{
get {return m_list.Count;}
}
///
/// Add a file to the collection
///
public void Add(FTPFile f)
{
m_list.Add(f);
}
///
/// Get a file from the collection
///
public FTPFile Get(int index)
{
return (FTPFile)m_list[index];
}
///
/// Sort the collection
///
public void Sort()
{
m_list.Sort();
}
///
/// Get iterator
///
public Enum GetEnumerator()
{
return new Enum(this);
}
///
/// Get iterator
///
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
///
/// Class for enumeration
///
///
/// created by - ianc
/// created on - 14/09/2003 18:02:58
///
public class Enum : IEnumerator
{
///
/// Default constructor - initializes all fields to default values
///
public Enum(FTPFileCollection c)
{
m_index=-1;
m_col=c;
}
///
/// See IEnumerator
///
public bool MoveNext()
{
m_index++;
return m_index
/// See IEnumerator
///
public FTPFile Current
{
get {return m_col.Get(m_index);}
}
///
/// See IEnumerator
///
public void Reset()
{
m_index=-1;
}
///
/// See IEnumerator
///
object IEnumerator.Current
{
get {return(Current);}
}
private int m_index;
private FTPFileCollection m_col;
}
// -------------------------------------------------
// - PRIVATE MEMBERS -
// -------------------------------------------------
private ArrayList m_list;
}
}