Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
private void bindGrid()
{
Album album = getBestAlbum();
dgSongs.DataSource = album.Songs; //it yacks here
}
using System;
using System.Collections;
namespace ClassLibrary1
{
public class Songs : IList
{
private ArrayList m_SongList;
public Songs()
{
m_SongList = new ArrayList();
}
#region Implementation of IList
public System.Collections.IEnumerator GetEnumerator()
{
return new SongEnumerator(this);
}
/* IList version of the interator wants an Object returned
public Song this[int index]
{
get
{
return (Song)m_SongList[index];
}
set
{
m_SongList[index] = value;
}
}
*/
public Object this[int index]
{
get
{
return m_SongList[index];
}
set
{
if (value.GetType().ToString() == "Song")
{
m_SongList[index] = value;
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
}
public void RemoveAt(int index)
{
m_SongList.RemoveAt(index);
}
public void Insert(int index, object value)
{
if (value.GetType().ToString() == "Song")
{
m_SongList.Insert(index, (Song)value);
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
public void Remove(object value)
{
if (value.GetType().ToString() == "Song")
{
m_SongList.Remove((Song)value);
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
public bool Contains(object value)
{
if (value.GetType().ToString() == "Song")
{
return m_SongList.Contains((Song)value);
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
public void Clear()
{
m_SongList.Clear();
}
public int IndexOf(object value)
{
if (value.GetType().ToString() == "Song")
{
return m_SongList.IndexOf((Song)value);
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
public int Add(object value)
{
if (value.GetType().ToString() == "Song")
{
return m_SongList.Add((Song)value);
}
else
{
throw new ArgumentException("Value is not a Song");
}
}
public bool IsReadOnly
{
get
{
return m_SongList.IsReadOnly;
}
}
public bool IsFixedSize
{
get
{
return m_SongList.IsFixedSize;
}
}
#endregion
#region Implementation of ICollection
public void CopyTo(System.Array array, int index)
{
m_SongList.CopyTo(array, index);
}
public bool IsSynchronized
{
get
{
return m_SongList.IsSynchronized;
}
}
public int Count
{
get
{
return m_SongList.Count;
}
}
public object SyncRoot
{
get
{
return m_SongList.SyncRoot;
}
}
#endregion
private class SongEnumerator : IEnumerator
{
private Songs m_SongRef;
private int m_Location;
public SongEnumerator(Songs SongRef)
{
this.m_SongRef = SongRef;
m_Location = -1;
}
#region Implementation of IEnumerator
public void Reset()
{
m_Location = -1;
}
public bool MoveNext()
{
m_Location++;
return (m_Location <= (m_SongRef.m_SongList.Count - 1));
}
public object Current
{
get
{
if ((m_Location < 0) || (m_Location >
m_SongRef.m_SongList.Count))
{
return null;
}
else
{
return m_SongRef.m_SongList[m_Location];
}
}
}
#endregion
}
}
}