PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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

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