D
David
Hi all,
I have a singleton ienumerable that collects data from a database. I have
listed the code below. It has the usual methods of current, move and reset.
I need to go to a certain position or set filters or many other things and I
don't know how to do this. I have just learned singleton AND ienumerable, so
miraculously got this to work so far. I could do with a bit of help to go
further with it. If need by, I may have to change the type to achieve the
aim.
What I want to do next is to select a specific row by passing in an index. I
don't know how to do this at all and no matter what I try, I just can't
compile.
My source is below...
All help is appreciated.
public class Folders : System.Collections.IEnumerable,
System.Collections.IEnumerator
{
private static Folders mObj; // This is used to manage the singleton.
private DataTable DT;
System.Collections.IEnumerator ienum;
// This is the singleton constructor
private Folders()
{
InitData();
}
// This sets up the singleton.
public static Folders SiteFolders
{
get
{
if(mObj == null) // only one instance is created
mObj = new Folders();
return mObj;
}
}
private void InitData()
{
// Get my data from the database and pass into ienum
ienum = DT.Rows.GetEnumerator();
}
public System.Collections.IEnumerator GetEnumerator()
{
// Polymorph this object into an IEnumerator interface
return (System.Collections.IEnumerator)this;
}
public void Reset()
{
ienum.Reset();
}
public bool MoveNext()
{
return ienum.MoveNext();
}
public object Current
{
get
{
return new Folder((DataRow)ienum.Current);
}
}
#endregion
public object SelectFolder(int myRow)
{
// get
// {
return new Folder((DataRow)myRow);
// }
}
}
I have tried using square brackets for the selectfolder as well, but just
won't compile. How can I select a specific row? Incidentally, the Folder
that selectfolder is referencing just takes my datatable and passes it into
some properties.
Because I have just learned about the singleton and ienumerable, I really do
not know how to continue. :-(
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
I have a singleton ienumerable that collects data from a database. I have
listed the code below. It has the usual methods of current, move and reset.
I need to go to a certain position or set filters or many other things and I
don't know how to do this. I have just learned singleton AND ienumerable, so
miraculously got this to work so far. I could do with a bit of help to go
further with it. If need by, I may have to change the type to achieve the
aim.
What I want to do next is to select a specific row by passing in an index. I
don't know how to do this at all and no matter what I try, I just can't
compile.
My source is below...
All help is appreciated.
public class Folders : System.Collections.IEnumerable,
System.Collections.IEnumerator
{
private static Folders mObj; // This is used to manage the singleton.
private DataTable DT;
System.Collections.IEnumerator ienum;
// This is the singleton constructor
private Folders()
{
InitData();
}
// This sets up the singleton.
public static Folders SiteFolders
{
get
{
if(mObj == null) // only one instance is created
mObj = new Folders();
return mObj;
}
}
private void InitData()
{
// Get my data from the database and pass into ienum
ienum = DT.Rows.GetEnumerator();
}
public System.Collections.IEnumerator GetEnumerator()
{
// Polymorph this object into an IEnumerator interface
return (System.Collections.IEnumerator)this;
}
public void Reset()
{
ienum.Reset();
}
public bool MoveNext()
{
return ienum.MoveNext();
}
public object Current
{
get
{
return new Folder((DataRow)ienum.Current);
}
}
#endregion
public object SelectFolder(int myRow)
{
// get
// {
return new Folder((DataRow)myRow);
// }
}
}
I have tried using square brackets for the selectfolder as well, but just
won't compile. How can I select a specific row? Incidentally, the Folder
that selectfolder is referencing just takes my datatable and passes it into
some properties.
Because I have just learned about the singleton and ienumerable, I really do
not know how to continue. :-(
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available