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

/base/Applications/Tests/Throw/Throw.cs

#
C# | 57 lines | 41 code | 7 blank | 9 comment | 2 complexity | e4da80e66e472a565d5177c871f40f28 MD5 | raw file
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Microsoft Research Singularity
  4. //
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //
  7. // Note: Simple Singularity test program.
  8. //
  9. using System;
  10. using Microsoft.Singularity.V1.Services;
  11. using Microsoft.Singularity.Channels;
  12. using Microsoft.Contracts;
  13. using Microsoft.SingSharp.Reflection;
  14. using Microsoft.Singularity.Applications;
  15. using Microsoft.Singularity.Io;
  16. using Microsoft.Singularity.Configuration;
  17. [assembly: Transform(typeof(ApplicationResourceTransform))]
  18. namespace Microsoft.Singularity.Applications
  19. {
  20. [ConsoleCategory(DefaultAction=true)]
  21. internal class Parameters {
  22. [InputEndpoint("data")]
  23. public readonly TRef<UnicodePipeContract.Exp:READY> Stdin;
  24. [OutputEndpoint("data")]
  25. public readonly TRef<UnicodePipeContract.Imp:READY> Stdout;
  26. reflective internal Parameters();
  27. internal int AppMain() {
  28. return Throw.AppMain(this);
  29. }
  30. }
  31. public class Throw
  32. {
  33. //[ShellCommand("throw", "Throw an exception")]
  34. internal static int AppMain(Parameters! config)
  35. {
  36. string args = "something";
  37. try {
  38. DebugStub.Print("About to throw exception\n");
  39. if (args == null) {
  40. throw new ArgumentNullException("ArgNullException");
  41. }
  42. throw new ApplicationException("AppException");
  43. }
  44. catch (Exception e) {
  45. Console.WriteLine("Caught exception {0}", e);
  46. }
  47. return 0;
  48. }
  49. }
  50. }