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