Auxiliary.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963
  1. using LitJson;
  2. using DragonBones;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. using UnityEngine.Advertisements;
  7. using System;
  8. using System.IO;
  9. using System.Xml;
  10. using System.Linq;
  11. using System.Net.Mail;
  12. using System.Net;
  13. using System.Text;
  14. using System.Collections;
  15. using System.Collections.Generic;
  16. using System.Security.Cryptography;
  17. using System.Runtime.Serialization.Formatters.Binary;
  18. using System.Security;
  19. using System.Security.Cryptography.Xml;
  20. using Random = UnityEngine.Random;
  21. using Transform = UnityEngine.Transform;
  22. public enum Unit
  23. {
  24. Second
  25. }
  26. public class Amount
  27. {
  28. public static double 百 = 100;
  29. public static double 千 = 1000;
  30. public static double 万 = 10000;
  31. public static double 十万 = 100000;
  32. public static double 百万 = 1000000;
  33. public static double 千万 = 10000000;
  34. public static double 亿 = 100000000;
  35. public static double 十亿 = 1000000000;
  36. public static double 千亿 = 100000000000;
  37. public static double 万亿 = 1000000000000;
  38. public static double 千万亿 = 1000000000000000;
  39. public static double 万万亿 = 10000000000000000;
  40. }
  41. public class Auxiliary : Regist
  42. {
  43. #region 变量
  44. public string String1;
  45. public string String2;
  46. public Font Font;
  47. public GameObject Go;
  48. public List<GameObject> GoList;
  49. public List<SpriteRenderer> SrList;
  50. public static bool AnyKeyUp;
  51. public static bool AnyKeyDown;
  52. public static Auxiliary Instance;
  53. public static MD5 MD5
  54. {
  55. get
  56. {
  57. if (_MD5 == null)
  58. {
  59. _MD5 = new MD5CryptoServiceProvider();
  60. }
  61. return _MD5;
  62. }
  63. set { _MD5 = value; }
  64. }
  65. public static DESCryptoServiceProvider Des
  66. {
  67. get
  68. {
  69. if (_Des == null)
  70. {
  71. _Des = new DESCryptoServiceProvider();
  72. _Des.IV = Encoding.UTF8.GetBytes("19283740");
  73. _Des.Key = Encoding.UTF8.GetBytes("93287123");
  74. }
  75. return _Des;
  76. }
  77. set { _Des = value; }
  78. }
  79. private static MD5 _MD5;
  80. private static DESCryptoServiceProvider _Des;
  81. #endregion
  82. public override bool RegistImmed()
  83. {
  84. if (base.RegistImmed())
  85. {
  86. return true;
  87. }
  88. enabled = true;
  89. return false;
  90. }
  91. private void Awake()
  92. {
  93. Instance = this;
  94. //gameObject.AddComponent<ManaAnim>().RegistImmed();
  95. }
  96. private void Update()
  97. {
  98. #region 调试
  99. if (Input.GetKeyDown(KeyCode.Escape))
  100. {
  101. }
  102. if (Input.GetKeyDown(KeyCode.Z))
  103. {
  104. ManaPlayer.Player.ChangeClose(BodyPart.Head, "脑壳2");
  105. }
  106. if (Input.GetKeyDown(KeyCode.X))
  107. {
  108. ManaPlayer.Player.ChangeClose(BodyPart.Head, "脑壳3");
  109. }
  110. if (Input.GetKeyDown(KeyCode.C))
  111. {
  112. }
  113. if (Input.GetKeyDown(KeyCode.V))
  114. {
  115. }
  116. //if (Input.GetKeyDown(KeyCode.P))
  117. //{
  118. // ManaData.Level += 20;
  119. //}
  120. //if (Input.GetKeyDown(KeyCode.O))
  121. //{
  122. // for (int i = 0; i < ManaData.SkillList.Count; i++)
  123. // {
  124. // ManaData.SkillList[i].ReceiveCool(1, true, true);
  125. // }
  126. //}
  127. //if (Input.GetKeyDown(KeyCode.I))
  128. //{
  129. // ManaCenter.Coin += 1000;
  130. // ManaCenter.Diamond += 1000;
  131. //}
  132. //if (Input.GetKeyDown(KeyCode.U))
  133. //{
  134. // Data.SavePlayerConfig();
  135. // Data.SaveXml();
  136. //}
  137. //if (Input.GetKeyDown(KeyCode.Y))
  138. //{
  139. // Data.ResetPlayerConfig();
  140. // Data.SaveXml();
  141. //}
  142. //if (Input.GetKeyDown(KeyCode.T))
  143. //{
  144. // ManaData.Pause = !ManaData.Pause;
  145. //}
  146. #endregion
  147. #region 输入检测
  148. if (Input.GetKeyDown(KeyCode.Escape))
  149. {
  150. ManaMiniGame.Pause = true;
  151. Bubble.Show(Language.GetStr("Common", "QuitGame"), null, null, Application.Quit, () => { ManaMiniGame.Pause = false; });
  152. }
  153. if (AnyKeyUp)
  154. {
  155. if (Input.anyKey == false)
  156. {
  157. AnyKeyUp = false;
  158. }
  159. }
  160. if (Input.anyKeyDown)
  161. {
  162. AnyKeyDown = true;
  163. }
  164. if (AnyKeyDown)
  165. {
  166. if (Input.anyKey == false)
  167. {
  168. AnyKeyUp = true;
  169. AnyKeyDown = false;
  170. }
  171. }
  172. #endregion
  173. }
  174. public static byte[] GetMD5(object obj)
  175. {
  176. MemoryStream memoryStream = new MemoryStream();
  177. BinaryFormatter binaryFormatter = new BinaryFormatter();
  178. binaryFormatter.Serialize(memoryStream, obj);
  179. byte[] bytes = memoryStream.GetBuffer();
  180. memoryStream.Dispose();
  181. return MD5.ComputeHash(bytes);
  182. }
  183. public static void EncryptXml(XmlDocument doc)
  184. {
  185. EncryptedXml encryptedXml = new EncryptedXml();
  186. XmlElement xmlElement = doc.DocumentElement;
  187. byte[] bytes = encryptedXml.EncryptData(xmlElement, Des, false);
  188. EncryptedData encryptedData = new EncryptedData();
  189. encryptedData.Type = EncryptedXml.XmlEncElementUrl;
  190. encryptedData.EncryptionMethod = new EncryptionMethod(EncryptedXml.XmlEncDESUrl);
  191. encryptedData.CipherData.CipherValue = bytes;
  192. EncryptedXml.ReplaceElement(xmlElement, encryptedData, false);
  193. }
  194. public static void DecryptXml(XmlDocument doc)
  195. {
  196. EncryptedXml encryptedXml = new EncryptedXml();
  197. XmlElement encryptXmlElement = (XmlElement)doc.GetElementsByTagName("EncryptedData")[0];
  198. EncryptedData encryptedData = new EncryptedData();
  199. encryptedData.LoadXml(encryptXmlElement);
  200. byte[] bytes = encryptedXml.DecryptData(encryptedData, Des);
  201. encryptedXml.ReplaceData(encryptXmlElement, bytes);
  202. }
  203. public static byte[] Encrypt(string str)
  204. {
  205. byte[] bytes = Encoding.UTF8.GetBytes(str);
  206. byte[] encryptBytes = Des.CreateEncryptor().TransformFinalBlock(bytes, 0, bytes.Length);
  207. return encryptBytes;
  208. }
  209. public static byte[] ToBytes(string str)
  210. {
  211. string[] strings = str.Split(' ');
  212. byte[] bytes = new byte[strings.Length];
  213. for (int i = 0; i < bytes.Length; i++)
  214. {
  215. bytes[i] = byte.Parse(strings[i]);
  216. }
  217. return bytes;
  218. }
  219. public static string Decrypt(string str)
  220. {
  221. byte[] encryptBytes = ToBytes(str);
  222. byte[] decryptBytes = Des.CreateDecryptor().TransformFinalBlock(encryptBytes, 0, encryptBytes.Length);
  223. return Encoding.UTF8.GetString(decryptBytes);
  224. }
  225. public static string ToString(byte[] bytes)
  226. {
  227. StringBuilder strB = new StringBuilder();
  228. for (int i = 0; i < bytes.Length; i++)
  229. {
  230. if (i == bytes.Length - 1)
  231. {
  232. strB.Append(bytes[i]);
  233. }
  234. else
  235. {
  236. strB.Append(bytes[i] + " ");
  237. }
  238. }
  239. return strB.ToString();
  240. }
  241. public static void CompileDic(Transform tra, Dictionary<string, Transform> dic, bool enableIgnore = true)
  242. {
  243. Transform[] transforms = tra.GetComponentsInChildren<Transform>(true);
  244. for (int i = 0; i < transforms.Length; i++)
  245. {
  246. if (enableIgnore)
  247. {
  248. if (transforms[i].GetComponent<IgnoreIndexing>())
  249. {
  250. continue;
  251. }
  252. }
  253. if (dic.ContainsKey(transforms[i].name))
  254. {
  255. throw new Exception(transforms[i].name);
  256. }
  257. else
  258. {
  259. dic.Add(transforms[i].name, transforms[i]);
  260. }
  261. }
  262. }
  263. public static string GetUnit(int value, Unit unit)
  264. {
  265. if (unit == Unit.Second)
  266. {
  267. if (ManaLan.CurrentLan == Lan.English)
  268. {
  269. if (value == 0 || value == 1)
  270. {
  271. return " Second";
  272. }
  273. else
  274. {
  275. return " Seconds";
  276. }
  277. }
  278. else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
  279. {
  280. return "秒";
  281. }
  282. else if (ManaLan.CurrentLan == Lan.ChineseTraditional)
  283. {
  284. return "秒";
  285. }
  286. else
  287. {
  288. throw new Exception();
  289. }
  290. }
  291. else
  292. {
  293. throw new Exception();
  294. }
  295. }
  296. public static string GetStreamPath()
  297. {
  298. if (Application.isEditor)
  299. {
  300. return "file://" + Application.streamingAssetsPath;
  301. }
  302. else if (Application.platform == RuntimePlatform.IPhonePlayer)
  303. {
  304. return "file://" + Application.streamingAssetsPath;
  305. }
  306. else if (Application.isMobilePlatform)
  307. {
  308. return Application.streamingAssetsPath;
  309. }
  310. else
  311. {
  312. throw new Exception();
  313. }
  314. }
  315. public void DelayCall(UnityAction function, int frame)
  316. {
  317. StartCoroutine(IDelayCall(function, frame));
  318. }
  319. public void DelayCall(UnityAction function, float time)
  320. {
  321. StartCoroutine(IDelayCall(function, time));
  322. }
  323. public static IEnumerator IDelayCall(UnityAction function, int frame)
  324. {
  325. int count = 0;
  326. while (count < frame)
  327. {
  328. count++;
  329. yield return null;
  330. }
  331. function.Invoke();
  332. }
  333. public static IEnumerator IDelayCall(UnityAction function, float time)
  334. {
  335. yield return new WaitForSeconds(time);
  336. function.Invoke();
  337. }
  338. public static string FmlParse1(string str)
  339. {
  340. int index = 0;
  341. int openIndex = 0;
  342. bool flag = false;
  343. bool group = false;
  344. for (int i = 0; i < str.Length; i++)
  345. {
  346. if (group)
  347. {
  348. if (str[i] == '+' || str[i] == '-' || str[i] == '*' || str[i] == '/')
  349. {
  350. str = str.Replace(openIndex, i - 1, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i - 1)));
  351. i = 0;
  352. group = false;
  353. }
  354. else if (i == str.Length - 1)
  355. {
  356. str = str.Replace(openIndex, i, FmlParse2(str[index], str.Between(openIndex, index - 1), str.Between(index + 1, i)));
  357. break;
  358. }
  359. }
  360. else
  361. {
  362. if (str[i] == '+' || str[i] == '-')
  363. {
  364. flag = true;
  365. openIndex = i + 1;
  366. }
  367. else if (str[i] == '*' || str[i] == '/')
  368. {
  369. index = i;
  370. group = true;
  371. if (!flag)
  372. {
  373. openIndex = 0;
  374. }
  375. }
  376. }
  377. }
  378. group = false;
  379. for (int i = 0; i < str.Length; i++)
  380. {
  381. if (group)
  382. {
  383. if (str[i] == '+' || str[i] == '-')
  384. {
  385. str = str.Replace(0, i - 1, FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i - 1)));
  386. i = -1;
  387. group = false;
  388. }
  389. else if (i == str.Length - 1)
  390. {
  391. return FmlParse2(str[index], str.Between(0, index - 1), str.Between(index + 1, i));
  392. }
  393. }
  394. else
  395. {
  396. if (str[i] == '+' || str[i] == '-')
  397. {
  398. index = i;
  399. group = true;
  400. }
  401. }
  402. }
  403. return str;
  404. }
  405. public static string FmlParse2(char op, string str1, string str2)
  406. {
  407. double var1 = double.Parse(str1);
  408. double var2 = double.Parse(str2);
  409. if (op == '+')
  410. {
  411. return (var1 + var2).ToString();
  412. }
  413. else if (op == '-')
  414. {
  415. return (var1 - var2).ToString();
  416. }
  417. else if (op == '*')
  418. {
  419. return (var1 * var2).ToString();
  420. }
  421. else if (op == '/')
  422. {
  423. return (var1 / var2).ToString();
  424. }
  425. else
  426. {
  427. throw new Exception(op.ToString());
  428. }
  429. }
  430. public static double FmlParse(string str, params string[] strings)
  431. {
  432. for (int i = 0; i < strings.Length; i += 2)
  433. {
  434. if (str.Contains(strings[i]))
  435. {
  436. str = str.Replace(strings[i], strings[i + 1]);
  437. }
  438. else
  439. {
  440. //Debug.Log("No such var " + strings[i + 1]);
  441. }
  442. }
  443. int openIndex = 0;
  444. for (int i = 0; i < str.Length; i++)
  445. {
  446. if (str[i] == '(')
  447. {
  448. openIndex = i;
  449. }
  450. else if (str[i] == ')')
  451. {
  452. str = str.Replace(openIndex, i, FmlParse1(str.Between(openIndex + 1, i - 1)));
  453. i = -1;
  454. }
  455. }
  456. return double.Parse(FmlParse1(str));
  457. }
  458. public static string OmitNumberStr(int accuray, string str)
  459. {
  460. int index = str.IndexOf('.');
  461. if (index == -1)
  462. {
  463. return str;
  464. }
  465. if (accuray == 0)
  466. {
  467. return str.Substring(0, index);
  468. }
  469. else
  470. {
  471. return str.Substring(0, index + accuray + 1);
  472. }
  473. }
  474. public static long ShrinkNumber(double value, int accuracy = 1)
  475. {
  476. long longValue = (long) value;
  477. if (ManaLan.CurrentLan == Lan.English)
  478. {
  479. if (longValue < Amount.千)
  480. {
  481. return longValue;
  482. }
  483. else if (longValue < Amount.百万)
  484. {
  485. long temp = (long) Amount.百;
  486. return (longValue/ temp) * temp;
  487. }
  488. else if (longValue < Amount.十亿)
  489. {
  490. long temp = (long)Amount.十万;
  491. return (longValue / temp) * temp;
  492. }
  493. else if (longValue < Amount.万亿)
  494. {
  495. long temp = (long)Amount.亿;
  496. return (longValue / temp) * temp;
  497. }
  498. else if (longValue < Amount.千万亿)
  499. {
  500. long temp = (long)Amount.千亿;
  501. return (longValue / temp) * temp;
  502. }
  503. else
  504. {
  505. long temp = (long)Amount.千亿;
  506. return (longValue / temp) * temp;
  507. }
  508. }
  509. else if (ManaLan.CurrentLan == Lan.ChineseSimplified || ManaLan.CurrentLan == Lan.ChineseTraditional)
  510. {
  511. if (longValue < Amount.万)
  512. {
  513. return longValue;
  514. }
  515. else if (longValue < Amount.亿)
  516. {
  517. long temp = (long)Amount.千;
  518. return (longValue / temp) * temp;
  519. }
  520. else if (longValue < Amount.万亿)
  521. {
  522. long temp = (long)Amount.千万;
  523. return (longValue / temp) * temp;
  524. }
  525. else if (longValue < Amount.万万亿)
  526. {
  527. long temp = (long)Amount.千亿;
  528. return (longValue / temp) * temp;
  529. }
  530. else
  531. {
  532. long temp = (long)Amount.千亿;
  533. return (longValue / temp) * temp;
  534. }
  535. }
  536. else
  537. {
  538. throw new Exception();
  539. }
  540. }
  541. public static string ShrinkNumberStr(double value, int accuracy = 1)
  542. {
  543. long longValue = (long) value;
  544. if (ManaLan.CurrentLan == Lan.English)
  545. {
  546. if (longValue < Amount.千)
  547. {
  548. return longValue.ToString();
  549. }
  550. else if (longValue < Amount.百万)
  551. {
  552. string str = (longValue / Amount.千).ToString();
  553. return OmitNumberStr(accuracy, str) + "K";
  554. }
  555. else if (longValue < Amount.十亿)
  556. {
  557. string str = (longValue / Amount.百万).ToString();
  558. return OmitNumberStr(accuracy, str) + "M";
  559. }
  560. else if (longValue < Amount.万亿)
  561. {
  562. string str = (longValue / Amount.十亿).ToString();
  563. return OmitNumberStr(accuracy, str) + "B";
  564. }
  565. else if (longValue < Amount.千万亿)
  566. {
  567. string str = (longValue / Amount.万亿).ToString();
  568. return OmitNumberStr(accuracy, str) + "T";
  569. }
  570. else
  571. {
  572. string str = (longValue / Amount.万亿).ToString();
  573. return OmitNumberStr(accuracy, str) + "T";
  574. }
  575. }
  576. else if (ManaLan.CurrentLan == Lan.ChineseSimplified)
  577. {
  578. if (longValue < Amount.万)
  579. {
  580. return longValue.ToString();
  581. }
  582. else if (longValue < Amount.亿)
  583. {
  584. string str = (longValue/Amount.万).ToString();
  585. return OmitNumberStr(accuracy, str) + "万";
  586. }
  587. else if (longValue < Amount.万亿)
  588. {
  589. string str = (longValue / Amount.亿).ToString();
  590. return OmitNumberStr(accuracy, str) + "亿";
  591. }
  592. else if (longValue < Amount.万万亿)
  593. {
  594. string str = (longValue / Amount.万亿).ToString();
  595. return OmitNumberStr(accuracy, str) + "万亿";
  596. }
  597. else
  598. {
  599. string str = (longValue / Amount.万亿).ToString();
  600. return OmitNumberStr(accuracy, str) + "万亿";
  601. }
  602. }
  603. else if (ManaLan.CurrentLan == Lan.ChineseTraditional)
  604. {
  605. if (longValue < Amount.万)
  606. {
  607. return longValue.ToString();
  608. }
  609. else if (longValue < Amount.亿)
  610. {
  611. string str = (longValue / Amount.万).ToString();
  612. return OmitNumberStr(accuracy, str) + "萬";
  613. }
  614. else if (longValue < Amount.万亿)
  615. {
  616. string str = (longValue / Amount.亿).ToString();
  617. return OmitNumberStr(accuracy, str) + "億";
  618. }
  619. else if (longValue < Amount.万万亿)
  620. {
  621. string str = (longValue / Amount.万亿).ToString();
  622. return OmitNumberStr(accuracy, str) + "萬億";
  623. }
  624. else
  625. {
  626. string str = (longValue / Amount.万亿).ToString();
  627. return OmitNumberStr(accuracy, str) + "萬億";
  628. }
  629. }
  630. else
  631. {
  632. throw new Exception();
  633. }
  634. }
  635. public static string ImageParse(Current current)
  636. {
  637. if (current == Current.Coin)
  638. {
  639. return "<(金币)>";
  640. }
  641. else if (current == Current.Diamond)
  642. {
  643. return "<(钻石)>";
  644. }
  645. else if (current == Current.Cash)
  646. {
  647. return Language.GetStr("Common", "Cash");
  648. }
  649. else
  650. {
  651. throw new Exception(current.ToString());
  652. }
  653. }
  654. public static Current CurrentParse(string str)
  655. {
  656. if (string.IsNullOrEmpty(str))
  657. {
  658. return Current.Free;
  659. }
  660. else
  661. {
  662. int number = int.Parse(str);
  663. if (number == 1)
  664. {
  665. return Current.Coin;
  666. }
  667. else if (number == 2)
  668. {
  669. return Current.Diamond;
  670. }
  671. else if (number == 3)
  672. {
  673. return Current.Cash;
  674. }
  675. else if (number == 4)
  676. {
  677. return Current.Other;
  678. }
  679. else if (number == 5)
  680. {
  681. return Current.AD;
  682. }
  683. else
  684. {
  685. throw new Exception(number.ToString());
  686. }
  687. }
  688. }
  689. public static int IntParse(string str, int defaultValue)
  690. {
  691. if (string.IsNullOrEmpty(str))
  692. {
  693. return defaultValue;
  694. }
  695. else
  696. {
  697. return int.Parse(str);
  698. }
  699. }
  700. public static long LongParse(string str, long defaultValue)
  701. {
  702. if (string.IsNullOrEmpty(str))
  703. {
  704. return defaultValue;
  705. }
  706. else
  707. {
  708. return long.Parse(str);
  709. }
  710. }
  711. public static bool BoolParse(string str, bool defaultValue)
  712. {
  713. if (string.IsNullOrEmpty(str))
  714. {
  715. return defaultValue;
  716. }
  717. else
  718. {
  719. return Convert.ToBoolean(int.Parse(str));
  720. }
  721. }
  722. public static float FloatParse(string str, float defaultValue)
  723. {
  724. if (string.IsNullOrEmpty(str))
  725. {
  726. return defaultValue;
  727. }
  728. else
  729. {
  730. return float.Parse(str);
  731. }
  732. }
  733. public static double DoubleParse(string str, double defaultValue)
  734. {
  735. if (string.IsNullOrEmpty(str))
  736. {
  737. return defaultValue;
  738. }
  739. else
  740. {
  741. return float.Parse(str);
  742. }
  743. }
  744. public static List<int> IntListParse(char cah, string str, List<int> defaultValue)
  745. {
  746. if (string.IsNullOrEmpty(str))
  747. {
  748. return defaultValue;
  749. }
  750. else
  751. {
  752. string[] strings = str.Split(cah);
  753. List<int> list = new List<int>();
  754. for (int i = 0; i < strings.Length; i++)
  755. {
  756. list.Add(int.Parse(strings[i]));
  757. }
  758. return list;
  759. }
  760. }
  761. public static List<string> StringListParse(char cah, string str, List<string> defaultValue)
  762. {
  763. if (string.IsNullOrEmpty(str))
  764. {
  765. return defaultValue;
  766. }
  767. else
  768. {
  769. string[] strings = str.Split(cah);
  770. List<string> list = new List<string>();
  771. for (int i = 0; i < strings.Length; i++)
  772. {
  773. list.Add(strings[i]);
  774. }
  775. return list;
  776. }
  777. }
  778. public static List<double> DoubleListParse(char cah, string str, List<double> defaultValue)
  779. {
  780. if (string.IsNullOrEmpty(str))
  781. {
  782. return defaultValue;
  783. }
  784. else
  785. {
  786. string[] strings = str.Split(cah);
  787. List<double> list = new List<double>();
  788. for (int i = 0; i < strings.Length; i++)
  789. {
  790. list.Add(double.Parse(strings[i]));
  791. }
  792. return list;
  793. }
  794. }
  795. }