4 Replies - 907 Views - Last Post: 18 September 2012 - 03:25 PM Rate Topic: -----

#1 Flum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-August 12

How to implemement the IObservableList<T> interface

Posted 18 September 2012 - 11:17 AM

Hello! I have a question about the IObservableList<T> interface. I am trying to create a generic class named ObservableList<T> that will implement the IObservableList<T> interface I want to run some Nunit testing on this class.

I have created a list "internalList" for internal data storing. I'm trying to implement the Add method but it doesn't show up when i try to instantiate a new ObservableList<T> list. Can somebody exmplain how I should implement this add method?

public class ObservableList<T> : IEnumerable<T>, IObservableList<T>
    {
        //  private variabel to work as 
        // the internal data storage for the list
        private List<T> internalList;

        public ObservableList()
        {
            internalList = new List<T>();
        }

        public IEnumerator<T> GetEnumerator()
        {
            return internalList.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return ((System.Collections.IEnumerable)internalList).GetEnumerator();
        }


        public void Add(T item)
        {
            internalList.Add(item);
        }

        public event EventHandler<RejectableEventArgs<T>> BeforeChange;

        public event EventHandler<RejectableEventArgs<T>> Changed;

        public bool Contains(T item)
        {
            throw new NotImplementedException();
        }

        public void Remove(T item)
        {
            internalList.Remove(item);
        }

        public bool TryAdd(T item)
        {
            throw new NotImplementedException();
        }

        public bool TryRemove(T item)
        {
            throw new NotImplementedException();
        }
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: How to implemement the IObservableList<T> interface

#2 Curtis Rutland  Icon User is online

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4576
  • View blog
  • Posts: 8,018
  • Joined: 08-June 10

Re: How to implemement the IObservableList<T> interface

Posted 18 September 2012 - 11:35 AM

What namespace is IObservableList<T> defined in? Is it a third party component? I haven't ever seen it, and when I search, all I'm getting back are Java results.

Also, what do you mean by "doesn't show up". If it's a public method, it has to show up.
Was This Post Helpful? 0
  • +
  • -

#3 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: How to implemement the IObservableList<T> interface

Posted 18 September 2012 - 01:50 PM

Why not just use the ObservableCollection<T> class?
Was This Post Helpful? 0
  • +
  • -

#4 Flum  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 04-August 12

Re: How to implemement the IObservableList<T> interface

Posted 18 September 2012 - 02:34 PM

ah yes its in a custom namespace. I will look at this ObservableCollection<T> the reason that i used the IObservableList<T> is that my friend gave me some of his old class assigments and I wanted to try it out. Thanks mates.
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,498
  • Joined: 29-May 08

Re: How to implemement the IObservableList<T> interface

Posted 18 September 2012 - 03:25 PM

IObservable<T> is part the interfaces defined to set the foundations of the Reactive Framework. It's a Push-Based rather than Pull-Based.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1