From a3f6697ffb872f553572627c73261cdd1ce55b67 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 21 Jan 2005 01:03:55 +0000 Subject: Initial checkin --- FTPFileCollection.cs | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 FTPFileCollection.cs (limited to 'FTPFileCollection.cs') diff --git a/FTPFileCollection.cs b/FTPFileCollection.cs new file mode 100644 index 0000000..f1bbe76 --- /dev/null +++ b/FTPFileCollection.cs @@ -0,0 +1,156 @@ +// 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; + } +} -- cgit v1.2.3