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