PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/mcs/class/Microsoft.JScript/Microsoft.JScript/Namespace.cs

https://bitbucket.org/steenlund/mono-2.6.7-for-amiga
C# | 87 lines | 43 code | 14 blank | 30 comment | 5 complexity | b14848e0b78d7b124984c47b507532a1 MD5 | raw file
Possible License(s): LGPL-2.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, GPL-2.0, LGPL-2.1
  1. //
  2. // Namespace.cs:
  3. //
  4. // Author:
  5. // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
  6. //
  7. // (C) 2003, Cesar Lopez Nataren
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Reflection;
  31. using Microsoft.JScript.Vsa;
  32. using System.Collections;
  33. namespace Microsoft.JScript {
  34. public sealed class Namespace {
  35. static Hashtable namespaces;
  36. //static string fullname;
  37. public Namespace (string name)
  38. {
  39. //fullname = name;
  40. }
  41. static Namespace ()
  42. {
  43. namespaces = new Hashtable ();
  44. }
  45. internal static void GetNamespace (string name, bool create)
  46. {
  47. int pos = name.IndexOf ('.');
  48. Namespace ns;
  49. string first;
  50. if (pos >= 0)
  51. first = name.Substring (0, pos);
  52. else
  53. first = name;
  54. ns = (Namespace) namespaces [first];
  55. if (ns == null) {
  56. if (!create)
  57. throw new Exception ("unknown case");
  58. ns = new Namespace (first);
  59. namespaces.Add (first, ns);
  60. }
  61. if (pos >= 0)
  62. Namespace.GetNamespace (name.Substring (pos + 1), create);
  63. }
  64. public static Namespace GetNamespace (string name, VsaEngine engine)
  65. {
  66. throw new NotImplementedException ();
  67. }
  68. internal static bool IsNamespace (string name)
  69. {
  70. return namespaces.Contains (name);
  71. }
  72. }
  73. }