JsonStoreScriptModule.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * Copyright (c) Contributors
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using Mono.Addins;
  28. using System;
  29. using System.Reflection;
  30. using System.Threading;
  31. using System.Text;
  32. using System.Net;
  33. using System.Net.Sockets;
  34. using log4net;
  35. using Nini.Config;
  36. using OpenMetaverse;
  37. using OpenMetaverse.StructuredData;
  38. using OpenSim.Framework;
  39. using OpenSim.Region.Framework.Interfaces;
  40. using OpenSim.Region.Framework.Scenes;
  41. using OpenSim.Region.Framework.Scenes.Scripting;
  42. using System.Collections.Generic;
  43. using System.Text.RegularExpressions;
  44. using PermissionMask = OpenSim.Framework.PermissionMask;
  45. namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
  46. {
  47. [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "JsonStoreScriptModule")]
  48. public class JsonStoreScriptModule : INonSharedRegionModule
  49. {
  50. private static readonly ILog m_log =
  51. LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  52. private IConfig m_config = null;
  53. private bool m_enabled = false;
  54. private Scene m_scene = null;
  55. private IScriptModuleComms m_comms;
  56. private IJsonStoreModule m_store;
  57. #region Region Module interface
  58. // -----------------------------------------------------------------
  59. /// <summary>
  60. /// Name of this shared module is it's class name
  61. /// </summary>
  62. // -----------------------------------------------------------------
  63. public string Name
  64. {
  65. get { return this.GetType().Name; }
  66. }
  67. // -----------------------------------------------------------------
  68. /// <summary>
  69. /// Initialise this shared module
  70. /// </summary>
  71. /// <param name="scene">this region is getting initialised</param>
  72. /// <param name="source">nini config, we are not using this</param>
  73. // -----------------------------------------------------------------
  74. public void Initialise(IConfigSource config)
  75. {
  76. try
  77. {
  78. if ((m_config = config.Configs["JsonStore"]) == null)
  79. {
  80. // There is no configuration, the module is disabled
  81. // m_log.InfoFormat("[JsonStoreScripts] no configuration info");
  82. return;
  83. }
  84. m_enabled = m_config.GetBoolean("Enabled", m_enabled);
  85. }
  86. catch (Exception e)
  87. {
  88. m_log.ErrorFormat("[JsonStoreScripts]: initialization error: {0}", e.Message);
  89. return;
  90. }
  91. if (m_enabled)
  92. m_log.DebugFormat("[JsonStoreScripts]: module is enabled");
  93. }
  94. // -----------------------------------------------------------------
  95. /// <summary>
  96. /// everything is loaded, perform post load configuration
  97. /// </summary>
  98. // -----------------------------------------------------------------
  99. public void PostInitialise()
  100. {
  101. }
  102. // -----------------------------------------------------------------
  103. /// <summary>
  104. /// Nothing to do on close
  105. /// </summary>
  106. // -----------------------------------------------------------------
  107. public void Close()
  108. {
  109. }
  110. // -----------------------------------------------------------------
  111. /// <summary>
  112. /// </summary>
  113. // -----------------------------------------------------------------
  114. public void AddRegion(Scene scene)
  115. {
  116. }
  117. // -----------------------------------------------------------------
  118. /// <summary>
  119. /// </summary>
  120. // -----------------------------------------------------------------
  121. public void RemoveRegion(Scene scene)
  122. {
  123. // need to remove all references to the scene in the subscription
  124. // list to enable full garbage collection of the scene object
  125. }
  126. // -----------------------------------------------------------------
  127. /// <summary>
  128. /// Called when all modules have been added for a region. This is
  129. /// where we hook up events
  130. /// </summary>
  131. // -----------------------------------------------------------------
  132. public void RegionLoaded(Scene scene)
  133. {
  134. if (m_enabled)
  135. {
  136. m_scene = scene;
  137. m_comms = m_scene.RequestModuleInterface<IScriptModuleComms>();
  138. if (m_comms == null)
  139. {
  140. m_log.ErrorFormat("[JsonStoreScripts]: ScriptModuleComms interface not defined");
  141. m_enabled = false;
  142. return;
  143. }
  144. m_store = m_scene.RequestModuleInterface<IJsonStoreModule>();
  145. if (m_store == null)
  146. {
  147. m_log.ErrorFormat("[JsonStoreScripts]: JsonModule interface not defined");
  148. m_enabled = false;
  149. return;
  150. }
  151. try
  152. {
  153. m_comms.RegisterScriptInvocations(this);
  154. m_comms.RegisterConstants(this);
  155. }
  156. catch (Exception e)
  157. {
  158. // See http://opensimulator.org/mantis/view.php?id=5971 for more information
  159. m_log.WarnFormat("[JsonStoreScripts]: script method registration failed; {0}", e.Message);
  160. m_enabled = false;
  161. }
  162. }
  163. }
  164. /// -----------------------------------------------------------------
  165. /// <summary>
  166. /// </summary>
  167. // -----------------------------------------------------------------
  168. public Type ReplaceableInterface
  169. {
  170. get { return null; }
  171. }
  172. #endregion
  173. #region ScriptConstantsInterface
  174. [ScriptConstant]
  175. public static readonly int JSON_NODETYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
  176. [ScriptConstant]
  177. public static readonly int JSON_NODETYPE_OBJECT = (int)JsonStoreNodeType.Object;
  178. [ScriptConstant]
  179. public static readonly int JSON_NODETYPE_ARRAY = (int)JsonStoreNodeType.Array;
  180. [ScriptConstant]
  181. public static readonly int JSON_NODETYPE_VALUE = (int)JsonStoreNodeType.Value;
  182. [ScriptConstant]
  183. public static readonly int JSON_VALUETYPE_UNDEF = (int)JsonStoreValueType.Undefined;
  184. [ScriptConstant]
  185. public static readonly int JSON_VALUETYPE_BOOLEAN = (int)JsonStoreValueType.Boolean;
  186. [ScriptConstant]
  187. public static readonly int JSON_VALUETYPE_INTEGER = (int)JsonStoreValueType.Integer;
  188. [ScriptConstant]
  189. public static readonly int JSON_VALUETYPE_FLOAT = (int)JsonStoreValueType.Float;
  190. [ScriptConstant]
  191. public static readonly int JSON_VALUETYPE_STRING = (int)JsonStoreValueType.String;
  192. #endregion
  193. #region ScriptInvocationInteface
  194. // -----------------------------------------------------------------
  195. /// <summary>
  196. ///
  197. /// </summary>
  198. // -----------------------------------------------------------------
  199. [ScriptInvocation]
  200. public UUID JsonAttachObjectStore(UUID hostID, UUID scriptID)
  201. {
  202. UUID uuid = UUID.Zero;
  203. if (! m_store.AttachObjectStore(hostID))
  204. GenerateRuntimeError("Failed to create Json store");
  205. return hostID;
  206. }
  207. // -----------------------------------------------------------------
  208. /// <summary>
  209. ///
  210. /// </summary>
  211. // -----------------------------------------------------------------
  212. [ScriptInvocation]
  213. public UUID JsonCreateStore(UUID hostID, UUID scriptID, string value)
  214. {
  215. UUID uuid = UUID.Zero;
  216. if (! m_store.CreateStore(value, ref uuid))
  217. GenerateRuntimeError("Failed to create Json store");
  218. return uuid;
  219. }
  220. // -----------------------------------------------------------------
  221. /// <summary>
  222. ///
  223. /// </summary>
  224. // -----------------------------------------------------------------
  225. [ScriptInvocation]
  226. public int JsonDestroyStore(UUID hostID, UUID scriptID, UUID storeID)
  227. {
  228. return m_store.DestroyStore(storeID) ? 1 : 0;
  229. }
  230. // -----------------------------------------------------------------
  231. /// <summary>
  232. ///
  233. /// </summary>
  234. // -----------------------------------------------------------------
  235. [ScriptInvocation]
  236. public int JsonTestStore(UUID hostID, UUID scriptID, UUID storeID)
  237. {
  238. return m_store.TestStore(storeID) ? 1 : 0;
  239. }
  240. // -----------------------------------------------------------------
  241. /// <summary>
  242. ///
  243. /// </summary>
  244. // -----------------------------------------------------------------
  245. [ScriptInvocation]
  246. public UUID JsonReadNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier)
  247. {
  248. UUID reqID = UUID.Random();
  249. Util.FireAndForget(o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier));
  250. return reqID;
  251. }
  252. // -----------------------------------------------------------------
  253. /// <summary>
  254. ///
  255. /// </summary>
  256. // -----------------------------------------------------------------
  257. [ScriptInvocation]
  258. public UUID JsonWriteNotecard(UUID hostID, UUID scriptID, UUID storeID, string path, string name)
  259. {
  260. UUID reqID = UUID.Random();
  261. Util.FireAndForget(delegate(object o) { DoJsonWriteNotecard(reqID,hostID,scriptID,storeID,path,name); });
  262. return reqID;
  263. }
  264. // -----------------------------------------------------------------
  265. /// <summary>
  266. ///
  267. /// </summary>
  268. // -----------------------------------------------------------------
  269. [ScriptInvocation]
  270. public string JsonList2Path(UUID hostID, UUID scriptID, object[] pathlist)
  271. {
  272. string ipath = ConvertList2Path(pathlist);
  273. string opath;
  274. if (JsonStore.CanonicalPathExpression(ipath,out opath))
  275. return opath;
  276. // This won't parse if passed to the other routines as opposed to
  277. // returning an empty string which is a valid path and would overwrite
  278. // the entire store
  279. return "**INVALID**";
  280. }
  281. // -----------------------------------------------------------------
  282. /// <summary>
  283. ///
  284. /// </summary>
  285. // -----------------------------------------------------------------
  286. [ScriptInvocation]
  287. public int JsonGetNodeType(UUID hostID, UUID scriptID, UUID storeID, string path)
  288. {
  289. return (int)m_store.GetNodeType(storeID,path);
  290. }
  291. // -----------------------------------------------------------------
  292. /// <summary>
  293. ///
  294. /// </summary>
  295. // -----------------------------------------------------------------
  296. [ScriptInvocation]
  297. public int JsonGetValueType(UUID hostID, UUID scriptID, UUID storeID, string path)
  298. {
  299. return (int)m_store.GetValueType(storeID,path);
  300. }
  301. // -----------------------------------------------------------------
  302. /// <summary>
  303. ///
  304. /// </summary>
  305. // -----------------------------------------------------------------
  306. [ScriptInvocation]
  307. public int JsonSetValue(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
  308. {
  309. return m_store.SetValue(storeID,path,value,false) ? 1 : 0;
  310. }
  311. [ScriptInvocation]
  312. public int JsonSetJson(UUID hostID, UUID scriptID, UUID storeID, string path, string value)
  313. {
  314. return m_store.SetValue(storeID,path,value,true) ? 1 : 0;
  315. }
  316. // -----------------------------------------------------------------
  317. /// <summary>
  318. ///
  319. /// </summary>
  320. // -----------------------------------------------------------------
  321. [ScriptInvocation]
  322. public int JsonRemoveValue(UUID hostID, UUID scriptID, UUID storeID, string path)
  323. {
  324. return m_store.RemoveValue(storeID,path) ? 1 : 0;
  325. }
  326. // -----------------------------------------------------------------
  327. /// <summary>
  328. ///
  329. /// </summary>
  330. // -----------------------------------------------------------------
  331. [ScriptInvocation]
  332. public int JsonGetArrayLength(UUID hostID, UUID scriptID, UUID storeID, string path)
  333. {
  334. return m_store.GetArrayLength(storeID,path);
  335. }
  336. // -----------------------------------------------------------------
  337. /// <summary>
  338. ///
  339. /// </summary>
  340. // -----------------------------------------------------------------
  341. [ScriptInvocation]
  342. public string JsonGetValue(UUID hostID, UUID scriptID, UUID storeID, string path)
  343. {
  344. string value = String.Empty;
  345. m_store.GetValue(storeID,path,false,out value);
  346. return value;
  347. }
  348. [ScriptInvocation]
  349. public string JsonGetJson(UUID hostID, UUID scriptID, UUID storeID, string path)
  350. {
  351. string value = String.Empty;
  352. m_store.GetValue(storeID,path,true, out value);
  353. return value;
  354. }
  355. // -----------------------------------------------------------------
  356. /// <summary>
  357. ///
  358. /// </summary>
  359. // -----------------------------------------------------------------
  360. [ScriptInvocation]
  361. public UUID JsonTakeValue(UUID hostID, UUID scriptID, UUID storeID, string path)
  362. {
  363. UUID reqID = UUID.Random();
  364. Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,false); });
  365. return reqID;
  366. }
  367. [ScriptInvocation]
  368. public UUID JsonTakeValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
  369. {
  370. UUID reqID = UUID.Random();
  371. Util.FireAndForget(delegate(object o) { DoJsonTakeValue(scriptID,reqID,storeID,path,true); });
  372. return reqID;
  373. }
  374. // -----------------------------------------------------------------
  375. /// <summary>
  376. ///
  377. /// </summary>
  378. // -----------------------------------------------------------------
  379. [ScriptInvocation]
  380. public UUID JsonReadValue(UUID hostID, UUID scriptID, UUID storeID, string path)
  381. {
  382. UUID reqID = UUID.Random();
  383. Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,false); });
  384. return reqID;
  385. }
  386. [ScriptInvocation]
  387. public UUID JsonReadValueJson(UUID hostID, UUID scriptID, UUID storeID, string path)
  388. {
  389. UUID reqID = UUID.Random();
  390. Util.FireAndForget(delegate(object o) { DoJsonReadValue(scriptID,reqID,storeID,path,true); });
  391. return reqID;
  392. }
  393. #endregion
  394. // -----------------------------------------------------------------
  395. /// <summary>
  396. ///
  397. /// </summary>
  398. // -----------------------------------------------------------------
  399. protected void GenerateRuntimeError(string msg)
  400. {
  401. m_log.InfoFormat("[JsonStore] runtime error: {0}",msg);
  402. throw new Exception("JsonStore Runtime Error: " + msg);
  403. }
  404. // -----------------------------------------------------------------
  405. /// <summary>
  406. ///
  407. /// </summary>
  408. // -----------------------------------------------------------------
  409. protected void DispatchValue(UUID scriptID, UUID reqID, string value)
  410. {
  411. m_comms.DispatchReply(scriptID,1,value,reqID.ToString());
  412. }
  413. // -----------------------------------------------------------------
  414. /// <summary>
  415. ///
  416. /// </summary>
  417. // -----------------------------------------------------------------
  418. private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
  419. {
  420. try
  421. {
  422. m_store.TakeValue(storeID,path,useJson,delegate(string value) { DispatchValue(scriptID,reqID,value); });
  423. return;
  424. }
  425. catch (Exception e)
  426. {
  427. m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
  428. }
  429. DispatchValue(scriptID,reqID,String.Empty);
  430. }
  431. // -----------------------------------------------------------------
  432. /// <summary>
  433. ///
  434. /// </summary>
  435. // -----------------------------------------------------------------
  436. private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
  437. {
  438. try
  439. {
  440. m_store.ReadValue(storeID,path,useJson,delegate(string value) { DispatchValue(scriptID,reqID,value); });
  441. return;
  442. }
  443. catch (Exception e)
  444. {
  445. m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
  446. }
  447. DispatchValue(scriptID,reqID,String.Empty);
  448. }
  449. // -----------------------------------------------------------------
  450. /// <summary>
  451. ///
  452. /// </summary>
  453. // -----------------------------------------------------------------
  454. private void DoJsonReadNotecard(
  455. UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string notecardIdentifier)
  456. {
  457. UUID assetID;
  458. if (!UUID.TryParse(notecardIdentifier, out assetID))
  459. {
  460. SceneObjectPart part = m_scene.GetSceneObjectPart(hostID);
  461. assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard);
  462. }
  463. AssetBase a = m_scene.AssetService.Get(assetID.ToString());
  464. if (a == null)
  465. GenerateRuntimeError(String.Format("Unable to find notecard asset {0}", assetID));
  466. if (a.Type != (sbyte)AssetType.Notecard)
  467. GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID));
  468. m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID);
  469. try
  470. {
  471. string jsondata = SLUtil.ParseNotecardToString(Encoding.UTF8.GetString(a.Data));
  472. int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0;
  473. m_comms.DispatchReply(scriptID, result, "", reqID.ToString());
  474. return;
  475. }
  476. catch (Exception e)
  477. {
  478. m_log.WarnFormat("[JsonStoreScripts]: Json parsing failed; {0}", e.Message);
  479. }
  480. GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID));
  481. m_comms.DispatchReply(scriptID, 0, "", reqID.ToString());
  482. }
  483. // -----------------------------------------------------------------
  484. /// <summary>
  485. ///
  486. /// </summary>
  487. // -----------------------------------------------------------------
  488. private void DoJsonWriteNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string name)
  489. {
  490. string data;
  491. if (! m_store.GetValue(storeID,path,true, out data))
  492. {
  493. m_comms.DispatchReply(scriptID,0,UUID.Zero.ToString(),reqID.ToString());
  494. return;
  495. }
  496. SceneObjectPart host = m_scene.GetSceneObjectPart(hostID);
  497. // Create new asset
  498. UUID assetID = UUID.Random();
  499. AssetBase asset = new AssetBase(assetID, name, (sbyte)AssetType.Notecard, host.OwnerID.ToString());
  500. asset.Description = "Json store";
  501. int textLength = data.Length;
  502. data = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
  503. + textLength.ToString() + "\n" + data + "}\n";
  504. asset.Data = Util.UTF8.GetBytes(data);
  505. m_scene.AssetService.Store(asset);
  506. // Create Task Entry
  507. TaskInventoryItem taskItem = new TaskInventoryItem();
  508. taskItem.ResetIDs(host.UUID);
  509. taskItem.ParentID = host.UUID;
  510. taskItem.CreationDate = (uint)Util.UnixTimeSinceEpoch();
  511. taskItem.Name = asset.Name;
  512. taskItem.Description = asset.Description;
  513. taskItem.Type = (int)AssetType.Notecard;
  514. taskItem.InvType = (int)InventoryType.Notecard;
  515. taskItem.OwnerID = host.OwnerID;
  516. taskItem.CreatorID = host.OwnerID;
  517. taskItem.BasePermissions = (uint)PermissionMask.All;
  518. taskItem.CurrentPermissions = (uint)PermissionMask.All;
  519. taskItem.EveryonePermissions = 0;
  520. taskItem.NextPermissions = (uint)PermissionMask.All;
  521. taskItem.GroupID = host.GroupID;
  522. taskItem.GroupPermissions = 0;
  523. taskItem.Flags = 0;
  524. taskItem.PermsGranter = UUID.Zero;
  525. taskItem.PermsMask = 0;
  526. taskItem.AssetID = asset.FullID;
  527. host.Inventory.AddInventoryItem(taskItem, false);
  528. m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
  529. }
  530. // -----------------------------------------------------------------
  531. /// <summary>
  532. /// Convert a list of values that are path components to a single string path
  533. /// </summary>
  534. // -----------------------------------------------------------------
  535. protected static Regex m_ArrayPattern = new Regex("^([0-9]+|\\+)$");
  536. private string ConvertList2Path(object[] pathlist)
  537. {
  538. string path = "";
  539. for (int i = 0; i < pathlist.Length; i++)
  540. {
  541. string token = "";
  542. if (pathlist[i] is string)
  543. {
  544. token = pathlist[i].ToString();
  545. // Check to see if this is a bare number which would not be a valid
  546. // identifier otherwise
  547. if (m_ArrayPattern.IsMatch(token))
  548. token = '[' + token + ']';
  549. }
  550. else if (pathlist[i] is int)
  551. {
  552. token = "[" + pathlist[i].ToString() + "]";
  553. }
  554. else
  555. {
  556. token = "." + pathlist[i].ToString() + ".";
  557. }
  558. path += token + ".";
  559. }
  560. return path;
  561. }
  562. }
  563. }