PageRenderTime 27ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/Quickstarts/UI Composition/ViewInjection/Desktop/UIComposition.Modules.Project.Tests/Mocks/MockRegion.cs

#
C# | 98 lines | 67 code | 15 blank | 16 comment | 2 complexity | c35c0cfa61540a1bde65b0f0f048e7a3 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.ComponentModel;
18using System.Windows.Controls;
19using Microsoft.Practices.Composite.Regions;
20
21namespace UIComposition.Modules.Project.Tests.Mocks
22{
23    public class MockRegion : IRegion
24    {
25        public bool ActivateCalled;
26        public int ViewsCount;
27        public string NamedViewAdded;
28
29        public string Name { get; set; }
30
31        public IRegionManager Add(object view)
32        {
33            ViewsCount++;
34            return null;
35        }
36
37        public void Remove(object view)
38        {
39            ViewsCount--;
40        }
41
42        public IViewsCollection Views
43        {
44            get { return null; }
45        }
46
47        public IViewsCollection ActiveViews
48        {
49            get { throw new System.NotImplementedException(); }
50        }
51
52        public object Context
53        {
54            get { throw new System.NotImplementedException(); }
55            set { throw new System.NotImplementedException(); }
56        }
57
58        public void Activate(object view)
59        {
60            ActivateCalled = true;
61        }
62
63        public void Deactivate(object view)
64        {
65            throw new System.NotImplementedException();
66        }
67
68        public IRegionManager Add(object view, string name)
69        {
70            ViewsCount++;
71            NamedViewAdded = name;
72            return null;
73        }
74
75        public object GetView(string name)
76        {
77            if (NamedViewAdded == name)
78                return new UserControl();
79
80            return null;
81        }
82
83        public IRegionManager RegionManager { get; set; }
84        public IRegionBehaviorCollection Behaviors
85        {
86            get { throw new System.NotImplementedException(); }
87        }
88
89        public IRegionManager Add(object view, string name, bool createRegionManagerScope)
90        {
91            ViewsCount++;
92            NamedViewAdded = name;
93            return null;
94        }
95
96        public event PropertyChangedEventHandler PropertyChanged;
97    }
98}