PageRenderTime 34ms CodeModel.GetById 0ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/CAL/Desktop/Composite.Tests/Mocks/MockAsyncModuleTypeLoader.cs

#
C# | 53 lines | 30 code | 7 blank | 16 comment | 0 complexity | 4964cecd998d2d5cd17863dd36f7c118 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.Threading;
  19. using Microsoft.Practices.Composite.Modularity;
  20. namespace Microsoft.Practices.Composite.Tests.Mocks
  21. {
  22. public class MockAsyncModuleTypeLoader : IModuleTypeLoader
  23. {
  24. private ManualResetEvent callbackEvent;
  25. public MockAsyncModuleTypeLoader(ManualResetEvent callbackEvent)
  26. {
  27. this.callbackEvent = callbackEvent;
  28. }
  29. public int SleepTimeOut { get; set; }
  30. public Exception CallbackArgumentError { get; set; }
  31. public void BeginLoadModuleType(ModuleInfo moduleInfo, ModuleTypeLoadedCallback callback)
  32. {
  33. Thread retrieverThread = new Thread(() =>
  34. {
  35. Thread.Sleep(SleepTimeOut);
  36. callback(moduleInfo, CallbackArgumentError);
  37. callbackEvent.Set();
  38. });
  39. retrieverThread.Start();
  40. }
  41. public bool CanLoadModuleType(ModuleInfo moduleInfo)
  42. {
  43. throw new NotImplementedException();
  44. }
  45. }
  46. }