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