PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.Tests/Mocks/MockViewsCollection.cs

#
C# | 55 lines | 33 code | 6 blank | 16 comment | 0 complexity | 27e6de492a44bb655718b95bd21fb9b1 MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System.Collections;
18using System.Collections.Generic;
19using System.Collections.ObjectModel;
20using System.Collections.Specialized;
21using Microsoft.Practices.Prism.Regions;
22
23namespace Microsoft.Practices.Prism.Tests.Mocks
24{
25    class MockViewsCollection : IViewsCollection
26    {
27        public ObservableCollection<object> Items = new ObservableCollection<object>();
28
29        public void Add(object view)
30        {
31            this.Items.Add(view);
32        }
33
34        public bool Contains(object value)
35        {
36            return Items.Contains(value);
37        }
38
39        public IEnumerator<object> GetEnumerator()
40        {
41            return Items.GetEnumerator();
42        }
43
44        IEnumerator IEnumerable.GetEnumerator()
45        {
46            return GetEnumerator();
47        }
48
49        public event NotifyCollectionChangedEventHandler CollectionChanged
50        {
51            add { Items.CollectionChanged += value; }
52            remove { Items.CollectionChanged -= value; }
53        }
54    }
55}