Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
4.1 KiB

  1. //***************************************************************************
  2. //This script tests the manipulation of property values, in the case that the
  3. //property is an embedded type
  4. //***************************************************************************
  5. var Service = GetObject("winmgmts:root/default");
  6. //*******************************
  7. //Create an embedded object class
  8. //*******************************
  9. /*
  10. [woobit(24.5)]
  11. class EmObjInner {
  12. [key] uint32 pInner = 10;
  13. };
  14. */
  15. var EmbObjInner = Service.Get();
  16. EmbObjInner.Path_.Class = "EmbObjInner";
  17. EmbObjInner.Qualifiers_.Add ("woobit", 24.5);
  18. var Property = EmbObjInner.Properties_.Add ("pInner", 19);
  19. Property.Qualifiers_.Add ("key", true);
  20. Property.Value = 10;
  21. EmbObjInner.Put_();
  22. EmbObjInner = Service.Get("EmbObjInner");
  23. //************************************
  24. //Create another embedded object class
  25. //************************************
  26. /*
  27. [wazzuck("oxter")]
  28. class EmbObjOuter {
  29. uint32 p0 = 25;
  30. EmbObjInner pOuter = instance of EmbObjInner { pInner = 564; };
  31. EmbObjInner pOuterArray[] = {
  32. instance of EmbObjInner { pInner = 0; },
  33. instance of EmbObjInner { pInner = 1; },
  34. instance of EmbObjInner { pInner = 2; }
  35. };
  36. };
  37. */
  38. var EmbObjOuter = Service.Get();
  39. EmbObjOuter.Path_.Class = "EmbObjOuter";
  40. EmbObjOuter.Qualifiers_.Add ("wazzuck", "oxter");
  41. EmbObjOuter.Properties_.Add ("p0", 19).Value = 25;
  42. var Property = EmbObjOuter.Properties_.Add ("pOuter", 13);
  43. var Instance = EmbObjInner.SpawnInstance_();
  44. Instance.pInner = 564;
  45. Property.Value = Instance;
  46. // Add an array of embedded objects property
  47. var Property = EmbObjOuter.Properties_.Add ("pOuterArray", 13, true);
  48. Property.Qualifiers_.Add ("cimtype","object:EmbObjInner");
  49. var Instance0 = EmbObjInner.SpawnInstance_();
  50. Instance0.pInner = 0;
  51. var Instance1 = EmbObjInner.SpawnInstance_();
  52. Instance1.pInner = 1;
  53. var Instance2 = EmbObjInner.SpawnInstance_();
  54. Instance2.pInner = 2;
  55. Property.Value = new Array (Instance0, Instance1, Instance2);
  56. var Instance3 = EmbObjInner.SpawnInstance_();
  57. Instance3.pInner = 42;
  58. Property.Value(3) = Instance3
  59. EmbObjOuter.Put_();
  60. var EmbObjOuter = Service.Get("EmbObjOuter");
  61. //Create a final class which wraps both embedded objects
  62. var Class = Service.Get();
  63. Class.Path_.Class = "EMBPROPTEST01";
  64. var Property = Class.Properties_.Add ("p1", 13);
  65. var Instance = EmbObjOuter.SpawnInstance_();
  66. Instance.p0 = 2546;
  67. Property.Value = Instance;
  68. Class.Put_();
  69. WScript.Echo ("The initial value of p0 is [2546]", Property.Value.p0);
  70. WScript.Echo ("The initial value of p0 is [2546]", Class.Properties_("p1").Value.Properties_("p0"));
  71. WScript.Echo ("The initial value of pInner is [564]", Property.Value.pOuter.pInner);
  72. WScript.Echo ("The initial value of pInner is [564]",
  73. Class.Properties_("p1").Value.Properties_("pOuter").Value.Properties_("pInner"));
  74. WScript.Echo ("The initial value of EMBPROPTEST01.p1.pOuterArray[0].pInner is", Class.p1.pOuterArray(0).pInner);
  75. WScript.Echo ("The initial value of EMBPROPTEST01.p1.pOuterArray[1].pInner is", Class.p1.pOuterArray(1).pInner);
  76. WScript.Echo ("The initial value of EMBPROPTEST01.p1.pOuterArray[2].pInner is", Class.p1.pOuterArray(2).pInner);
  77. WScript.Echo ("The initial value of EMBPROPTEST01.p1.pOuterArray[3].pInner is", Class.p1.pOuterArray(3).pInner);
  78. var Class = Service.Get("EMBPROPTEST01");
  79. //Now try direct assignment to the outer emb obj
  80. Class.p1.p0 = 23;
  81. WScript.Echo ("The new value of p0 is [23]", Class.p1.p0);
  82. var Property = Class.p1;
  83. Property.p0 = 787;
  84. WScript.Echo ("The new value of p0 is [787]", Class.p1.p0);
  85. Class.Properties_("p1").Value.p0 = 56;
  86. WScript.Echo ("The new value of p0 is [56]", Class.p1.p0);
  87. //Now try direct assignment to the inner emb obj
  88. Class.p1.pOuter.pInner = 4;
  89. WScript.Echo ("The new value of pInner is [4]", Class.p1.pOuter.pInner);
  90. var Property = Class.p1.pOuter;
  91. Property.pInner = 12;
  92. WScript.Echo ("The new value of pInner is [12]", Class.p1.pOuter.pInner);
  93. //Now try assignment to the inner emb obj array
  94. Class.p1.pOuterArray(1).pInner = 5675;
  95. WScript.Echo ("The new value of Class.p1.pOuterArray[1].pInner is [5675]", Class.p1.pOuterArray(1).pInner);