2
0

ModBase.cs 127 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Drawing;
  6. using System.Globalization;
  7. using System.IO;
  8. using System.IO.Compression;
  9. using System.Linq;
  10. using System.Reflection;
  11. using System.Runtime.CompilerServices;
  12. using System.Runtime.InteropServices;
  13. using System.Security.Cryptography;
  14. using System.Security.Principal;
  15. using System.Text;
  16. using System.Text.RegularExpressions;
  17. using System.Threading;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Forms;
  21. using System.Windows.Markup;
  22. using System.Windows.Media;
  23. using System.Windows.Media.Imaging;
  24. using System.Windows.Threading;
  25. using System.Xml.Linq;
  26. using Microsoft.VisualBasic;
  27. using Microsoft.VisualBasic.CompilerServices;
  28. using Microsoft.Win32;
  29. using Newtonsoft.Json;
  30. using Ookii.Dialogs.Wpf;
  31. using PCL.My;
  32. using PCL.My.Resources;
  33. namespace PCL
  34. {
  35. // Token: 0x020001FD RID: 509
  36. [StandardModule]
  37. public sealed class ModBase
  38. {
  39. // Token: 0x060017A7 RID: 6055 RVA: 0x0009A900 File Offset: 0x00098B00
  40. public static string RadixConvert(string Input, int FromRadix, int ToRadix)
  41. {
  42. checked
  43. {
  44. string result;
  45. if (string.IsNullOrEmpty(Input))
  46. {
  47. result = "0";
  48. }
  49. else
  50. {
  51. bool flag;
  52. if (flag = Input.StartsWithF("-", false))
  53. {
  54. Input = Input.TrimStart(new char[]
  55. {
  56. '-'
  57. });
  58. }
  59. long num = 0L;
  60. long num2 = 1L;
  61. try
  62. {
  63. foreach (int num3 in Enumerable.Select<char, int>(Enumerable.Reverse<char>(Input), (ModBase._Closure$__.$I29-0 == null) ? (ModBase._Closure$__.$I29-0 = ((char l) => "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+=".IndexOfF(Conversions.ToString(l), false))) : ModBase._Closure$__.$I29-0))
  64. {
  65. num += unchecked((long)num3) * num2;
  66. num2 *= unchecked((long)FromRadix);
  67. }
  68. }
  69. finally
  70. {
  71. IEnumerator<int> enumerator;
  72. if (enumerator != null)
  73. {
  74. enumerator.Dispose();
  75. }
  76. }
  77. string str = "";
  78. while (num > 0L)
  79. {
  80. int num4 = (int)(num % unchecked((long)ToRadix));
  81. num = (long)Math.Round((double)(num - unchecked((long)num4)) / (double)ToRadix);
  82. str = Conversions.ToString("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/+="[num4]) + str;
  83. }
  84. result = (flag ? "-" : "") + str;
  85. }
  86. return result;
  87. }
  88. }
  89. // Token: 0x060017A8 RID: 6056 RVA: 0x0009AA2C File Offset: 0x00098C2C
  90. public static double MathBezier(double x, double x1, double y1, double x2, double y2, double acc = 0.01)
  91. {
  92. double result;
  93. if (x > 0.0 && !double.IsNaN(x))
  94. {
  95. if (x >= 1.0)
  96. {
  97. result = 1.0;
  98. }
  99. else
  100. {
  101. object obj = x;
  102. object obj2;
  103. do
  104. {
  105. obj2 = Operators.MultiplyObject(Operators.MultiplyObject(3, obj), Operators.AddObject(Operators.AddObject(Operators.MultiplyObject(Operators.MultiplyObject(0.33333333 + x1 - x2, obj), obj), Operators.MultiplyObject(x2 - 2.0 * x1, obj)), x1));
  106. obj = Operators.AddObject(obj, Operators.MultiplyObject(Operators.SubtractObject(x, obj2), 0.5));
  107. }
  108. while (!Operators.ConditionalCompareObjectLess(NewLateBinding.LateGet(null, typeof(Math), "Abs", new object[]
  109. {
  110. Operators.SubtractObject(obj2, x)
  111. }, null, null, null), acc, false));
  112. result = Conversions.ToDouble(Operators.MultiplyObject(Operators.MultiplyObject(3, obj), Operators.AddObject(Operators.AddObject(Operators.MultiplyObject(Operators.MultiplyObject(0.33333333 + y1 - y2, obj), obj), Operators.MultiplyObject(y2 - 2.0 * y1, obj)), y1)));
  113. }
  114. }
  115. else
  116. {
  117. result = 0.0;
  118. }
  119. return result;
  120. }
  121. // Token: 0x060017A9 RID: 6057 RVA: 0x0000D3C5 File Offset: 0x0000B5C5
  122. public static byte MathByte(double d)
  123. {
  124. if (d < 0.0)
  125. {
  126. d = 0.0;
  127. }
  128. if (d > 255.0)
  129. {
  130. d = 255.0;
  131. }
  132. return checked((byte)Math.Round(d));
  133. }
  134. // Token: 0x060017AA RID: 6058 RVA: 0x0009ABA0 File Offset: 0x00098DA0
  135. public static ModBase.MyColor MathRound(ModBase.MyColor col, int w = 0)
  136. {
  137. return new ModBase.MyColor
  138. {
  139. mapperError = Math.Round(col.mapperError, w),
  140. m_ThreadError = Math.Round(col.m_ThreadError, w),
  141. _PropertyError = Math.Round(col._PropertyError, w),
  142. composerError = Math.Round(col.composerError, w)
  143. };
  144. }
  145. // Token: 0x060017AB RID: 6059 RVA: 0x0000D3FC File Offset: 0x0000B5FC
  146. public static double MathPercent(double ValueA, double ValueB, double Percent)
  147. {
  148. return Math.Round(ValueA * (1.0 - Percent) + ValueB * Percent, 6);
  149. }
  150. // Token: 0x060017AC RID: 6060 RVA: 0x0000D415 File Offset: 0x0000B615
  151. public static ModBase.MyColor MathPercent(ModBase.MyColor ValueA, ModBase.MyColor ValueB, double Percent)
  152. {
  153. return ModBase.MathRound(ValueA * (1.0 - Percent) + ValueB * Percent, 6);
  154. }
  155. // Token: 0x060017AD RID: 6061 RVA: 0x0000D43A File Offset: 0x0000B63A
  156. public static double MathClamp(double value, double min, double max)
  157. {
  158. return Math.Max(min, Math.Min(max, value));
  159. }
  160. // Token: 0x060017AE RID: 6062 RVA: 0x0009ABFC File Offset: 0x00098DFC
  161. public static int MathSgn(double Value)
  162. {
  163. int result;
  164. if (Value == 0.0)
  165. {
  166. result = 0;
  167. }
  168. else if (Value > 0.0)
  169. {
  170. result = 1;
  171. }
  172. else
  173. {
  174. result = -1;
  175. }
  176. return result;
  177. }
  178. // Token: 0x060017AF RID: 6063 RVA: 0x0009AC2C File Offset: 0x00098E2C
  179. public static void RenameReg(RegistryKey parentKey, string subKeyName, string newSubKeyName)
  180. {
  181. if (Enumerable.Contains<string>(parentKey.GetSubKeyNames(), newSubKeyName))
  182. {
  183. parentKey.DeleteSubKeyTree(newSubKeyName, false);
  184. }
  185. RegistryKey registryKey = parentKey.OpenSubKey(subKeyName);
  186. if (!Information.IsNothing(registryKey))
  187. {
  188. RegistryKey registryKey2 = parentKey.CreateSubKey(newSubKeyName);
  189. if (registryKey.GetSubKeyNames().Length > 0)
  190. {
  191. throw new NotSupportedException("不支持对包含子键的子键进行重命名:" + registryKey.GetSubKeyNames()[0] + "。");
  192. }
  193. foreach (string name in registryKey.GetValueNames())
  194. {
  195. object objectValue = RuntimeHelpers.GetObjectValue(registryKey.GetValue(name));
  196. RegistryValueKind valueKind = registryKey.GetValueKind(name);
  197. registryKey2.SetValue(name, RuntimeHelpers.GetObjectValue(objectValue), valueKind);
  198. }
  199. parentKey.DeleteSubKeyTree(subKeyName, false);
  200. }
  201. }
  202. // Token: 0x060017B0 RID: 6064 RVA: 0x0009ACDC File Offset: 0x00098EDC
  203. public static string ReadReg(string Key, string DefaultValue = "")
  204. {
  205. string result;
  206. try
  207. {
  208. RegistryKey registryKey = MyWpfExtension.ManageParser().Registry.CurrentUser.OpenSubKey("Software\\PCL", true);
  209. if (registryKey == null)
  210. {
  211. result = DefaultValue;
  212. }
  213. else
  214. {
  215. StringBuilder stringBuilder = new StringBuilder();
  216. stringBuilder.AppendLine(Conversions.ToString(registryKey.GetValue(Key)));
  217. string text = stringBuilder.ToString().Replace("\r\n", "");
  218. result = ((Operators.CompareString(text, "", false) == 0) ? DefaultValue : text);
  219. }
  220. }
  221. catch (Exception ex)
  222. {
  223. ModBase.Log(ex, "读取注册表出错:" + Key, ModBase.LogLevel.Hint, "出现错误");
  224. result = DefaultValue;
  225. }
  226. return result;
  227. }
  228. // Token: 0x060017B1 RID: 6065 RVA: 0x0009AD88 File Offset: 0x00098F88
  229. public static void WriteReg(string Key, string Value, bool ShowException = false)
  230. {
  231. try
  232. {
  233. RegistryKey currentUser = MyWpfExtension.ManageParser().Registry.CurrentUser;
  234. RegistryKey registryKey = currentUser.OpenSubKey("Software\\PCL", true);
  235. if (registryKey == null)
  236. {
  237. registryKey = currentUser.CreateSubKey("Software\\PCL");
  238. }
  239. registryKey.SetValue(Key, Value);
  240. }
  241. catch (Exception ex)
  242. {
  243. ModBase.Log(ex, "写入注册表出错:" + Key, ShowException ? ModBase.LogLevel.Hint : ModBase.LogLevel.Developer, "出现错误");
  244. if (ShowException)
  245. {
  246. throw;
  247. }
  248. }
  249. }
  250. // Token: 0x060017B2 RID: 6066 RVA: 0x0000D449 File Offset: 0x0000B649
  251. public static void IniClearCache(string FileName)
  252. {
  253. if (!FileName.Contains(":\\"))
  254. {
  255. FileName = string.Format("{0}PCL\\{1}.ini", ModBase.Path, FileName);
  256. }
  257. if (ModBase.stateRepository.ContainsKey(FileName))
  258. {
  259. ModBase.stateRepository.Remove(FileName);
  260. }
  261. }
  262. // Token: 0x060017B3 RID: 6067 RVA: 0x0009AE0C File Offset: 0x0009900C
  263. private static Dictionary<string, string> IniGetContent(string FileName)
  264. {
  265. Dictionary<string, string> result;
  266. try
  267. {
  268. if (!FileName.Contains(":\\"))
  269. {
  270. FileName = string.Format("{0}PCL\\{1}.ini", ModBase.Path, FileName);
  271. }
  272. if (ModBase.stateRepository.ContainsKey(FileName))
  273. {
  274. result = ModBase.stateRepository[FileName];
  275. }
  276. else if (!File.Exists(FileName))
  277. {
  278. result = null;
  279. }
  280. else
  281. {
  282. Dictionary<string, string> dictionary = new Dictionary<string, string>();
  283. foreach (string text in ModBase.ReadFile(FileName, null).Split(Enumerable.ToArray<char>("\r\n"), StringSplitOptions.RemoveEmptyEntries))
  284. {
  285. int num = text.IndexOfF(":", false);
  286. if (num > 0)
  287. {
  288. dictionary[text.Substring(0, num)] = text.Substring(checked(num + 1));
  289. }
  290. }
  291. ModBase.stateRepository[FileName] = dictionary;
  292. result = dictionary;
  293. }
  294. }
  295. catch (Exception ex)
  296. {
  297. ModBase.Log(ex, string.Format("生成 ini 文件缓存失败({0})", FileName), ModBase.LogLevel.Hint, "出现错误");
  298. result = null;
  299. }
  300. return result;
  301. }
  302. // Token: 0x060017B4 RID: 6068 RVA: 0x0009AF10 File Offset: 0x00099110
  303. public static string ReadIni(string FileName, string Key, string DefaultValue = "")
  304. {
  305. Dictionary<string, string> dictionary = ModBase.IniGetContent(FileName);
  306. string result;
  307. if (dictionary != null && dictionary.ContainsKey(Key))
  308. {
  309. result = dictionary[Key];
  310. }
  311. else
  312. {
  313. result = DefaultValue;
  314. }
  315. return result;
  316. }
  317. // Token: 0x060017B5 RID: 6069 RVA: 0x0009AF40 File Offset: 0x00099140
  318. public static void WriteIni(string FileName, string Key, string Value)
  319. {
  320. try
  321. {
  322. Key = Key.Replace("\r", "").Replace("\n", "").Replace(":", "");
  323. Value = Value.Replace("\r", "").Replace("\n", "");
  324. Dictionary<string, string> dictionary = ModBase.IniGetContent(FileName);
  325. if (dictionary == null)
  326. {
  327. dictionary = new Dictionary<string, string>();
  328. }
  329. if (!dictionary.ContainsKey(Key) || Operators.CompareString(dictionary[Key], Value, false) != 0)
  330. {
  331. dictionary[Key] = Value;
  332. StringBuilder stringBuilder = new StringBuilder();
  333. try
  334. {
  335. foreach (KeyValuePair<string, string> keyValuePair in dictionary)
  336. {
  337. stringBuilder.Append(keyValuePair.Key);
  338. stringBuilder.Append(":");
  339. stringBuilder.Append(keyValuePair.Value);
  340. stringBuilder.Append("\r\n");
  341. }
  342. }
  343. finally
  344. {
  345. Dictionary<string, string>.Enumerator enumerator;
  346. ((IDisposable)enumerator).Dispose();
  347. }
  348. if (!FileName.Contains(":\\"))
  349. {
  350. FileName = string.Format("{0}PCL\\{1}.ini", ModBase.Path, FileName);
  351. }
  352. ModBase.WriteFile(FileName, stringBuilder.ToString(), false, null);
  353. }
  354. }
  355. catch (Exception ex)
  356. {
  357. ModBase.Log(ex, string.Format("写入文件失败({0} → {1}:{2})", FileName, Key, Value), ModBase.LogLevel.Hint, "出现错误");
  358. }
  359. }
  360. // Token: 0x060017B6 RID: 6070 RVA: 0x0009B0C4 File Offset: 0x000992C4
  361. public static string GetPathFromFullPath(string FilePath)
  362. {
  363. if (!FilePath.Contains("\\") && !FilePath.Contains("/"))
  364. {
  365. throw new Exception("不包含路径:" + FilePath);
  366. }
  367. checked
  368. {
  369. string text;
  370. if (!FilePath.EndsWithF("\\", false) && !FilePath.EndsWithF("/", false))
  371. {
  372. text = Strings.Left(FilePath, FilePath.LastIndexOfAny(new char[]
  373. {
  374. '\\',
  375. '/'
  376. }) + 1);
  377. if (Operators.CompareString(text, "", false) == 0)
  378. {
  379. throw new Exception("不包含路径:" + FilePath);
  380. }
  381. }
  382. else
  383. {
  384. bool flag = FilePath.EndsWithF("\\", false);
  385. FilePath = Strings.Left(FilePath, Strings.Len(FilePath) - 1);
  386. text = Strings.Left(FilePath, FilePath.LastIndexOfAny(new char[]
  387. {
  388. '\\',
  389. '/'
  390. })) + (flag ? "\\" : "/");
  391. if (Operators.CompareString(text, "", false) == 0)
  392. {
  393. throw new Exception("不包含路径:" + FilePath);
  394. }
  395. }
  396. return text;
  397. }
  398. }
  399. // Token: 0x060017B7 RID: 6071 RVA: 0x0009B1C4 File Offset: 0x000993C4
  400. public static string GetFileNameFromPath(string FilePath)
  401. {
  402. FilePath = FilePath.Replace("/", "\\");
  403. if (FilePath.EndsWithF("\\", false))
  404. {
  405. throw new Exception("不包含文件名:" + FilePath);
  406. }
  407. if (FilePath.Contains("?"))
  408. {
  409. FilePath = FilePath.Substring(0, FilePath.IndexOfF("?", false));
  410. }
  411. if (FilePath.Contains("\\"))
  412. {
  413. FilePath = FilePath.Substring(checked(FilePath.LastIndexOfF("\\", false) + 1));
  414. }
  415. int length = FilePath.Length;
  416. if (length == 0)
  417. {
  418. throw new Exception("不包含文件名:" + FilePath);
  419. }
  420. if (length > 250)
  421. {
  422. throw new PathTooLongException("文件名过长:" + FilePath);
  423. }
  424. return FilePath;
  425. }
  426. // Token: 0x060017B8 RID: 6072 RVA: 0x0009B27C File Offset: 0x0009947C
  427. public static string GetFileNameWithoutExtentionFromPath(string FilePath)
  428. {
  429. string fileNameFromPath = ModBase.GetFileNameFromPath(FilePath);
  430. string result;
  431. if (fileNameFromPath.Contains("."))
  432. {
  433. result = fileNameFromPath.Substring(0, fileNameFromPath.LastIndexOfF(".", false));
  434. }
  435. else
  436. {
  437. result = fileNameFromPath;
  438. }
  439. return result;
  440. }
  441. // Token: 0x060017B9 RID: 6073 RVA: 0x0009B2B8 File Offset: 0x000994B8
  442. public static string GetFolderNameFromPath(string FolderPath)
  443. {
  444. string result;
  445. if (!FolderPath.EndsWithF(":\\", false) && !FolderPath.EndsWithF(":\\\\", false))
  446. {
  447. if (FolderPath.EndsWithF("\\", false) || FolderPath.EndsWithF("/", false))
  448. {
  449. FolderPath = Strings.Left(FolderPath, checked(FolderPath.Length - 1));
  450. }
  451. result = ModBase.GetFileNameFromPath(FolderPath);
  452. }
  453. else
  454. {
  455. result = FolderPath.Substring(0, 1);
  456. }
  457. return result;
  458. }
  459. // Token: 0x060017BA RID: 6074 RVA: 0x0009B320 File Offset: 0x00099520
  460. public static void CopyFile(string FromPath, string ToPath)
  461. {
  462. try
  463. {
  464. if (!FromPath.Contains(":\\"))
  465. {
  466. FromPath = ModBase.Path + FromPath;
  467. }
  468. if (!ToPath.Contains(":\\"))
  469. {
  470. ToPath = ModBase.Path + ToPath;
  471. }
  472. if (Operators.CompareString(FromPath, ToPath, false) != 0)
  473. {
  474. Directory.CreateDirectory(ModBase.GetPathFromFullPath(ToPath));
  475. File.Copy(FromPath, ToPath, true);
  476. }
  477. }
  478. catch (Exception innerException)
  479. {
  480. throw new Exception("复制文件出错:" + FromPath + " → " + ToPath, innerException);
  481. }
  482. }
  483. // Token: 0x060017BB RID: 6075 RVA: 0x0009B3B4 File Offset: 0x000995B4
  484. public static byte[] ReadFileBytes(string FilePath, Encoding Encoding = null)
  485. {
  486. checked
  487. {
  488. byte[] result;
  489. try
  490. {
  491. if (!FilePath.Contains(":\\"))
  492. {
  493. FilePath = ModBase.Path + FilePath;
  494. }
  495. if (File.Exists(FilePath))
  496. {
  497. byte[] array;
  498. using (FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
  499. {
  500. array = new byte[(int)(fileStream.Length - 1L) + 1];
  501. fileStream.Read(array, 0, (int)fileStream.Length);
  502. }
  503. result = array;
  504. }
  505. else
  506. {
  507. ModBase.Log("[System] 欲读取的文件不存在,已返回空内容:" + FilePath, ModBase.LogLevel.Normal, "出现错误");
  508. result = new byte[0];
  509. }
  510. }
  511. catch (Exception ex)
  512. {
  513. ModBase.Log(ex, "读取文件出错:" + FilePath, ModBase.LogLevel.Debug, "出现错误");
  514. result = new byte[0];
  515. }
  516. return result;
  517. }
  518. }
  519. // Token: 0x060017BC RID: 6076 RVA: 0x0009B490 File Offset: 0x00099690
  520. public static string ReadFile(string FilePath, Encoding Encoding = null)
  521. {
  522. byte[] bytes = ModBase.ReadFileBytes(FilePath, null);
  523. return (Encoding == null) ? ModBase.DecodeBytes(bytes) : Encoding.GetString(bytes);
  524. }
  525. // Token: 0x060017BD RID: 6077 RVA: 0x0009B4BC File Offset: 0x000996BC
  526. public static string ReadFile(Stream Stream, Encoding Encoding = null)
  527. {
  528. string result;
  529. try
  530. {
  531. byte[] array = new byte[16385];
  532. int i = Stream.Read(array, 0, 16384);
  533. List<byte> list = new List<byte>();
  534. while (i > 0)
  535. {
  536. if (i > 0)
  537. {
  538. list.AddRange(Enumerable.ToList<byte>(array).GetRange(0, i));
  539. }
  540. i = Stream.Read(array, 0, 16384);
  541. }
  542. byte[] bytes = list.ToArray();
  543. result = (Encoding ?? ModBase.GetEncoding(bytes)).GetString(bytes);
  544. }
  545. catch (Exception ex)
  546. {
  547. ModBase.Log(ex, "读取流出错", ModBase.LogLevel.Debug, "出现错误");
  548. result = "";
  549. }
  550. return result;
  551. }
  552. // Token: 0x060017BE RID: 6078 RVA: 0x0009B56C File Offset: 0x0009976C
  553. public static void WriteFile(string FilePath, string Text, bool Append = false, Encoding Encoding = null)
  554. {
  555. if (!FilePath.Contains(":\\"))
  556. {
  557. FilePath = ModBase.Path + FilePath;
  558. }
  559. Directory.CreateDirectory(ModBase.GetPathFromFullPath(FilePath));
  560. if (File.Exists(FilePath))
  561. {
  562. using (StreamWriter streamWriter = new StreamWriter(FilePath, Append, Encoding ?? ModBase.GetEncoding(ModBase.ReadFileBytes(FilePath, null))))
  563. {
  564. streamWriter.Write(Text);
  565. streamWriter.Flush();
  566. streamWriter.Close();
  567. return;
  568. }
  569. }
  570. File.WriteAllText(FilePath, Text, Encoding ?? new UTF8Encoding(false));
  571. }
  572. // Token: 0x060017BF RID: 6079 RVA: 0x0000D483 File Offset: 0x0000B683
  573. public static void WriteFile(string FilePath, byte[] Content, bool Append = false)
  574. {
  575. if (!FilePath.Contains(":\\"))
  576. {
  577. FilePath = ModBase.Path + FilePath;
  578. }
  579. Directory.CreateDirectory(ModBase.GetPathFromFullPath(FilePath));
  580. File.WriteAllBytes(FilePath, Content);
  581. }
  582. // Token: 0x060017C0 RID: 6080 RVA: 0x0009B604 File Offset: 0x00099804
  583. public static bool WriteFile(string FilePath, Stream Stream)
  584. {
  585. bool result;
  586. try
  587. {
  588. if (!FilePath.Contains(":\\"))
  589. {
  590. FilePath = ModBase.Path + FilePath;
  591. }
  592. Directory.CreateDirectory(ModBase.GetPathFromFullPath(FilePath));
  593. using (FileStream fileStream = new FileStream(FilePath, FileMode.Create, FileAccess.Write))
  594. {
  595. byte[] array = new byte[16385];
  596. for (int i = Stream.Read(array, 0, 16384); i > 0; i = Stream.Read(array, 0, 16384))
  597. {
  598. if (i > 0)
  599. {
  600. fileStream.Write(array, 0, i);
  601. }
  602. }
  603. fileStream.Close();
  604. }
  605. result = true;
  606. }
  607. catch (Exception ex)
  608. {
  609. ModBase.Log(ex, "保存流出错", ModBase.LogLevel.Debug, "出现错误");
  610. result = false;
  611. }
  612. return result;
  613. }
  614. // Token: 0x060017C1 RID: 6081 RVA: 0x0009B6D0 File Offset: 0x000998D0
  615. public static Encoding GetEncoding(byte[] Bytes)
  616. {
  617. Encoding result;
  618. if (Enumerable.Count<byte>(Bytes) < 3)
  619. {
  620. result = new UTF8Encoding(false);
  621. }
  622. else if (Bytes[0] >= 239)
  623. {
  624. if (Bytes[0] == 239 && Bytes[1] == 187)
  625. {
  626. result = new UTF8Encoding(true);
  627. }
  628. else if (Bytes[0] == 254 && Bytes[1] == 255)
  629. {
  630. result = Encoding.BigEndianUnicode;
  631. }
  632. else if (Bytes[0] == 255 && Bytes[1] == 254)
  633. {
  634. result = Encoding.Unicode;
  635. }
  636. else
  637. {
  638. result = Encoding.GetEncoding("GB18030");
  639. }
  640. }
  641. else
  642. {
  643. string @string = Encoding.UTF8.GetString(Bytes);
  644. char value = Encoding.UTF8.GetString(new byte[]
  645. {
  646. 239,
  647. 191,
  648. 189
  649. }).ToCharArray()[0];
  650. if (@string.Contains(Conversions.ToString(value)))
  651. {
  652. result = Encoding.GetEncoding("GB18030");
  653. }
  654. else
  655. {
  656. result = new UTF8Encoding(false);
  657. }
  658. }
  659. return result;
  660. }
  661. // Token: 0x060017C2 RID: 6082 RVA: 0x0009B7B4 File Offset: 0x000999B4
  662. public static string DecodeBytes(byte[] Bytes)
  663. {
  664. int num = Bytes.Length;
  665. checked
  666. {
  667. string result;
  668. if (num < 3)
  669. {
  670. result = Encoding.UTF8.GetString(Bytes);
  671. }
  672. else if (Bytes[0] >= 239)
  673. {
  674. if (Bytes[0] == 239 && Bytes[1] == 187)
  675. {
  676. result = Encoding.UTF8.GetString(Bytes, 3, num - 3);
  677. }
  678. else if (Bytes[0] == 254 && Bytes[1] == 255)
  679. {
  680. result = Encoding.BigEndianUnicode.GetString(Bytes, 3, num - 3);
  681. }
  682. else if (Bytes[0] == 255 && Bytes[1] == 254)
  683. {
  684. result = Encoding.Unicode.GetString(Bytes, 3, num - 3);
  685. }
  686. else
  687. {
  688. result = Encoding.GetEncoding("GB18030").GetString(Bytes, 3, num - 3);
  689. }
  690. }
  691. else
  692. {
  693. string @string = Encoding.UTF8.GetString(Bytes);
  694. char value = Encoding.UTF8.GetString(new byte[]
  695. {
  696. 239,
  697. 191,
  698. 189
  699. }).ToCharArray()[0];
  700. if (@string.Contains(Conversions.ToString(value)))
  701. {
  702. result = Encoding.GetEncoding("GB18030").GetString(Bytes);
  703. }
  704. else
  705. {
  706. result = @string;
  707. }
  708. }
  709. return result;
  710. }
  711. }
  712. // Token: 0x060017C3 RID: 6083 RVA: 0x0009B8CC File Offset: 0x00099ACC
  713. public static string SelectAs(string Title, string FileName, string FileFilter = null, string DefaultDir = null)
  714. {
  715. string text;
  716. using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
  717. {
  718. saveFileDialog.AddExtension = true;
  719. saveFileDialog.AutoUpgradeEnabled = true;
  720. saveFileDialog.Title = Title;
  721. saveFileDialog.FileName = FileName;
  722. if (FileFilter != null)
  723. {
  724. saveFileDialog.Filter = FileFilter;
  725. }
  726. if (DefaultDir != null)
  727. {
  728. saveFileDialog.InitialDirectory = DefaultDir;
  729. }
  730. saveFileDialog.ShowDialog();
  731. text = (saveFileDialog.FileName.Contains(":\\") ? saveFileDialog.FileName : "");
  732. ModBase.Log("[UI] 选择文件返回:" + text, ModBase.LogLevel.Normal, "出现错误");
  733. }
  734. return text;
  735. }
  736. // Token: 0x060017C4 RID: 6084 RVA: 0x0009B96C File Offset: 0x00099B6C
  737. public static string SelectFile(string FileFilter, string Title)
  738. {
  739. string fileName;
  740. using (System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
  741. {
  742. openFileDialog.AddExtension = true;
  743. openFileDialog.AutoUpgradeEnabled = true;
  744. openFileDialog.CheckFileExists = true;
  745. openFileDialog.Filter = FileFilter;
  746. openFileDialog.Multiselect = false;
  747. openFileDialog.Title = Title;
  748. openFileDialog.ValidateNames = true;
  749. openFileDialog.ShowDialog();
  750. ModBase.Log("[UI] 选择单个文件返回:" + openFileDialog.FileName, ModBase.LogLevel.Normal, "出现错误");
  751. fileName = openFileDialog.FileName;
  752. }
  753. return fileName;
  754. }
  755. // Token: 0x060017C5 RID: 6085 RVA: 0x0009B9F8 File Offset: 0x00099BF8
  756. public static string[] SelectFiles(string FileFilter, string Title)
  757. {
  758. string[] fileNames;
  759. using (System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
  760. {
  761. openFileDialog.AddExtension = true;
  762. openFileDialog.AutoUpgradeEnabled = true;
  763. openFileDialog.CheckFileExists = true;
  764. openFileDialog.Filter = FileFilter;
  765. openFileDialog.Multiselect = true;
  766. openFileDialog.Title = Title;
  767. openFileDialog.ValidateNames = true;
  768. openFileDialog.ShowDialog();
  769. ModBase.Log("[UI] 选择多个文件返回:" + openFileDialog.FileNames.Join(","), ModBase.LogLevel.Normal, "出现错误");
  770. fileNames = openFileDialog.FileNames;
  771. }
  772. return fileNames;
  773. }
  774. // Token: 0x060017C6 RID: 6086 RVA: 0x0009BA8C File Offset: 0x00099C8C
  775. public static string SelectFolder(string Title = "选择文件夹")
  776. {
  777. VistaFolderBrowserDialog vistaFolderBrowserDialog = new VistaFolderBrowserDialog
  778. {
  779. ShowNewFolderButton = true,
  780. RootFolder = Environment.SpecialFolder.Desktop,
  781. Description = Title,
  782. UseDescriptionForTitle = true
  783. };
  784. vistaFolderBrowserDialog.ShowDialog();
  785. string text = string.IsNullOrEmpty(vistaFolderBrowserDialog.SelectedPath) ? "" : (vistaFolderBrowserDialog.SelectedPath + (vistaFolderBrowserDialog.SelectedPath.EndsWithF("\\", false) ? "" : "\\"));
  786. ModBase.Log("[UI] 选择文件夹返回:" + text, ModBase.LogLevel.Normal, "出现错误");
  787. return text;
  788. }
  789. // Token: 0x060017C7 RID: 6087 RVA: 0x0009BB18 File Offset: 0x00099D18
  790. public static bool CheckPermission(string Path)
  791. {
  792. bool result;
  793. try
  794. {
  795. if (string.IsNullOrEmpty(Path))
  796. {
  797. result = false;
  798. }
  799. else
  800. {
  801. if (!Path.EndsWithF("\\", false))
  802. {
  803. Path += "\\";
  804. }
  805. if (!Path.EndsWithF(":\\System Volume Information\\", false) && !Path.EndsWithF(":\\$RECYCLE.BIN\\", false))
  806. {
  807. if (!Directory.Exists(Path))
  808. {
  809. result = false;
  810. }
  811. else
  812. {
  813. string str = "CheckPermission" + Conversions.ToString(ModBase.GetUuid());
  814. if (File.Exists(Path + str))
  815. {
  816. File.Delete(Path + str);
  817. }
  818. File.Create(Path + str).Dispose();
  819. File.Delete(Path + str);
  820. result = true;
  821. }
  822. }
  823. else
  824. {
  825. result = false;
  826. }
  827. }
  828. }
  829. catch (Exception ex)
  830. {
  831. ModBase.Log(ex, "没有对文件夹 " + Path + " 的权限,请尝试以管理员权限运行 PCL", ModBase.LogLevel.Debug, "出现错误");
  832. result = false;
  833. }
  834. return result;
  835. }
  836. // Token: 0x060017C8 RID: 6088 RVA: 0x0009BC0C File Offset: 0x00099E0C
  837. public static void CheckPermissionWithException(string Path)
  838. {
  839. if (string.IsNullOrWhiteSpace(Path))
  840. {
  841. throw new ArgumentNullException("文件夹名不能为空!");
  842. }
  843. if (!Path.EndsWithF("\\", false))
  844. {
  845. Path += "\\";
  846. }
  847. if (!Directory.Exists(Path))
  848. {
  849. throw new DirectoryNotFoundException("文件夹不存在!");
  850. }
  851. if (File.Exists(Path + "CheckPermission"))
  852. {
  853. File.Delete(Path + "CheckPermission");
  854. }
  855. File.Create(Path + "CheckPermission").Dispose();
  856. File.Delete(Path + "CheckPermission");
  857. }
  858. // Token: 0x060017C9 RID: 6089 RVA: 0x0009BCA4 File Offset: 0x00099EA4
  859. public static string smethod_0(string FilePath)
  860. {
  861. bool flag = false;
  862. checked
  863. {
  864. string result;
  865. for (;;)
  866. {
  867. try
  868. {
  869. StringBuilder stringBuilder = new StringBuilder();
  870. FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  871. byte[] array = new MD5CryptoServiceProvider().ComputeHash(fileStream);
  872. fileStream.Close();
  873. int num = array.Length - 1;
  874. for (int i = 0; i <= num; i++)
  875. {
  876. stringBuilder.Append(array[i].ToString("x2"));
  877. }
  878. result = stringBuilder.ToString();
  879. break;
  880. }
  881. catch (Exception ex)
  882. {
  883. if (flag || ex is FileNotFoundException)
  884. {
  885. ModBase.Log(ex, "获取文件 MD5 失败:" + FilePath, ModBase.LogLevel.Debug, "出现错误");
  886. result = "";
  887. break;
  888. }
  889. flag = true;
  890. ModBase.Log(ex, "获取文件 MD5 可重试失败:" + FilePath, ModBase.LogLevel.Normal, "出现错误");
  891. Thread.Sleep(ModBase.RandomInteger(200, 500));
  892. }
  893. }
  894. return result;
  895. }
  896. }
  897. // Token: 0x060017CA RID: 6090 RVA: 0x0009BD9C File Offset: 0x00099F9C
  898. public static string GetFileSHA256(string FilePath)
  899. {
  900. bool flag = false;
  901. checked
  902. {
  903. string result;
  904. for (;;)
  905. {
  906. try
  907. {
  908. FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  909. byte[] array = new SHA256CryptoServiceProvider().ComputeHash(fileStream);
  910. fileStream.Close();
  911. StringBuilder stringBuilder = new StringBuilder();
  912. int num = array.Length - 1;
  913. for (int i = 0; i <= num; i++)
  914. {
  915. stringBuilder.Append(array[i].ToString("x2"));
  916. }
  917. result = stringBuilder.ToString();
  918. break;
  919. }
  920. catch (Exception ex)
  921. {
  922. if (flag || ex is FileNotFoundException)
  923. {
  924. ModBase.Log(ex, "获取文件 SHA256 失败:" + FilePath, ModBase.LogLevel.Debug, "出现错误");
  925. result = "";
  926. break;
  927. }
  928. flag = true;
  929. ModBase.Log(ex, "获取文件 SHA256 可重试失败:" + FilePath, ModBase.LogLevel.Normal, "出现错误");
  930. Thread.Sleep(ModBase.RandomInteger(200, 500));
  931. }
  932. }
  933. return result;
  934. }
  935. }
  936. // Token: 0x060017CB RID: 6091 RVA: 0x0009BE94 File Offset: 0x0009A094
  937. public static string smethod_1(string FilePath)
  938. {
  939. bool flag = false;
  940. checked
  941. {
  942. string result;
  943. for (;;)
  944. {
  945. try
  946. {
  947. FileStream fileStream = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
  948. byte[] array = new SHA1CryptoServiceProvider().ComputeHash(fileStream);
  949. fileStream.Close();
  950. StringBuilder stringBuilder = new StringBuilder();
  951. int num = array.Length - 1;
  952. for (int i = 0; i <= num; i++)
  953. {
  954. stringBuilder.Append(array[i].ToString("x2"));
  955. }
  956. result = stringBuilder.ToString();
  957. break;
  958. }
  959. catch (Exception ex)
  960. {
  961. if (flag || ex is FileNotFoundException)
  962. {
  963. ModBase.Log(ex, "获取文件 SHA1 失败:" + FilePath, ModBase.LogLevel.Debug, "出现错误");
  964. result = "";
  965. break;
  966. }
  967. flag = true;
  968. ModBase.Log(ex, "获取文件 SHA1 可重试失败:" + FilePath, ModBase.LogLevel.Normal, "出现错误");
  969. Thread.Sleep(ModBase.RandomInteger(200, 500));
  970. }
  971. }
  972. return result;
  973. }
  974. }
  975. // Token: 0x060017CC RID: 6092 RVA: 0x0009BF8C File Offset: 0x0009A18C
  976. public static string smethod_2(Stream Stream)
  977. {
  978. checked
  979. {
  980. string result;
  981. try
  982. {
  983. byte[] array = new SHA1CryptoServiceProvider().ComputeHash(Stream);
  984. StringBuilder stringBuilder = new StringBuilder();
  985. int num = array.Length - 1;
  986. for (int i = 0; i <= num; i++)
  987. {
  988. stringBuilder.Append(array[i].ToString("x2"));
  989. }
  990. result = stringBuilder.ToString();
  991. }
  992. catch (Exception ex)
  993. {
  994. ModBase.Log(ex, "获取流 SHA1 失败", ModBase.LogLevel.Debug, "出现错误");
  995. result = "";
  996. }
  997. return result;
  998. }
  999. }
  1000. // Token: 0x060017CD RID: 6093 RVA: 0x0009C01C File Offset: 0x0009A21C
  1001. public static void ExtractFile(string CompressFilePath, string DestDirectory, Encoding Encode = null, Action<double> ProgressIncrementHandler = null)
  1002. {
  1003. Directory.CreateDirectory(DestDirectory);
  1004. if (CompressFilePath.EndsWithF(".gz", true))
  1005. {
  1006. GZipStream gzipStream = new GZipStream(new FileStream(CompressFilePath, FileMode.Open, FileAccess.ReadWrite), 0);
  1007. FileStream fileStream = new FileStream(DestDirectory + ModBase.GetFileNameFromPath(CompressFilePath).ToLower().Replace(".tar", "").Replace(".gz", ""), FileMode.OpenOrCreate, FileAccess.Write);
  1008. for (int num = gzipStream.ReadByte(); num != -1; num = gzipStream.ReadByte())
  1009. {
  1010. fileStream.WriteByte(checked((byte)num));
  1011. }
  1012. fileStream.Close();
  1013. gzipStream.Close();
  1014. return;
  1015. }
  1016. using (ZipArchive zipArchive = ZipFile.Open(CompressFilePath, ZipArchiveMode.Read, Encode ?? Encoding.GetEncoding("GB18030")))
  1017. {
  1018. int count = zipArchive.Entries.Count;
  1019. try
  1020. {
  1021. foreach (ZipArchiveEntry zipArchiveEntry in zipArchive.Entries)
  1022. {
  1023. if (ProgressIncrementHandler != null)
  1024. {
  1025. ProgressIncrementHandler(1.0 / (double)count);
  1026. }
  1027. string text = System.IO.Path.Combine(DestDirectory, zipArchiveEntry.FullName);
  1028. if (!text.EndsWithF("\\", false) && !text.EndsWithF("/", false))
  1029. {
  1030. Directory.CreateDirectory(ModBase.GetPathFromFullPath(text));
  1031. zipArchiveEntry.ExtractToFile(text, true);
  1032. }
  1033. }
  1034. }
  1035. finally
  1036. {
  1037. IEnumerator<ZipArchiveEntry> enumerator;
  1038. if (enumerator != null)
  1039. {
  1040. enumerator.Dispose();
  1041. }
  1042. }
  1043. }
  1044. }
  1045. // Token: 0x060017CE RID: 6094 RVA: 0x0009C180 File Offset: 0x0009A380
  1046. public static int DeleteDirectory(string Path, bool IgnoreIssue = false)
  1047. {
  1048. checked
  1049. {
  1050. int result;
  1051. if (!Directory.Exists(Path))
  1052. {
  1053. result = 0;
  1054. }
  1055. else
  1056. {
  1057. int num = 0;
  1058. string[] files;
  1059. try
  1060. {
  1061. files = Directory.GetFiles(Path);
  1062. }
  1063. catch (DirectoryNotFoundException ex)
  1064. {
  1065. ModBase.Log(ex, string.Format("疑似为孤立符号链接,尝试直接删除({0})", Path), ModBase.LogLevel.Developer, "出现错误");
  1066. Directory.Delete(Path);
  1067. return 0;
  1068. }
  1069. foreach (string text in files)
  1070. {
  1071. bool flag = false;
  1072. for (;;)
  1073. {
  1074. try
  1075. {
  1076. File.Delete(text);
  1077. num++;
  1078. break;
  1079. }
  1080. catch (Exception ex2)
  1081. {
  1082. if (!flag)
  1083. {
  1084. flag = true;
  1085. ModBase.Log(ex2, string.Format("删除文件失败,将在 0.3s 后重试({0})", text), ModBase.LogLevel.Debug, "出现错误");
  1086. Thread.Sleep(300);
  1087. }
  1088. else
  1089. {
  1090. if (!IgnoreIssue)
  1091. {
  1092. throw;
  1093. }
  1094. ModBase.Log(ex2, "删除单个文件可忽略地失败", ModBase.LogLevel.Debug, "出现错误");
  1095. break;
  1096. }
  1097. }
  1098. }
  1099. }
  1100. string[] directories = Directory.GetDirectories(Path);
  1101. for (int j = 0; j < directories.Length; j++)
  1102. {
  1103. ModBase.DeleteDirectory(directories[j], IgnoreIssue);
  1104. }
  1105. bool flag2 = false;
  1106. for (;;)
  1107. {
  1108. try
  1109. {
  1110. Directory.Delete(Path, true);
  1111. break;
  1112. }
  1113. catch (Exception ex3)
  1114. {
  1115. if (!flag2)
  1116. {
  1117. flag2 = true;
  1118. ModBase.Log(ex3, string.Format("删除文件夹失败,将在 0.3s 后重试({0})", Path), ModBase.LogLevel.Debug, "出现错误");
  1119. Thread.Sleep(300);
  1120. }
  1121. else
  1122. {
  1123. if (!IgnoreIssue)
  1124. {
  1125. throw;
  1126. }
  1127. ModBase.Log(ex3, "删除单个文件夹可忽略地失败", ModBase.LogLevel.Debug, "出现错误");
  1128. break;
  1129. }
  1130. }
  1131. }
  1132. result = num;
  1133. }
  1134. return result;
  1135. }
  1136. }
  1137. // Token: 0x060017CF RID: 6095 RVA: 0x0009C31C File Offset: 0x0009A51C
  1138. public static void CopyDirectory(string FromPath, string ToPath, Action<double> ProgressIncrementHandler = null)
  1139. {
  1140. FromPath = FromPath.Replace("/", "\\");
  1141. if (!FromPath.EndsWithF("\\", false))
  1142. {
  1143. FromPath += "\\";
  1144. }
  1145. ToPath = ToPath.Replace("/", "\\");
  1146. if (!ToPath.EndsWithF("\\", false))
  1147. {
  1148. ToPath += "\\";
  1149. }
  1150. List<FileInfo> list = Enumerable.ToList<FileInfo>(ModBase.EnumerateFiles(FromPath));
  1151. int count = list.Count;
  1152. try
  1153. {
  1154. foreach (FileInfo fileInfo in list)
  1155. {
  1156. ModBase.CopyFile(fileInfo.FullName, fileInfo.FullName.Replace(FromPath, ToPath));
  1157. if (ProgressIncrementHandler != null)
  1158. {
  1159. ProgressIncrementHandler(1.0 / (double)count);
  1160. }
  1161. }
  1162. }
  1163. finally
  1164. {
  1165. List<FileInfo>.Enumerator enumerator;
  1166. ((IDisposable)enumerator).Dispose();
  1167. }
  1168. }
  1169. // Token: 0x060017D0 RID: 6096 RVA: 0x0009C400 File Offset: 0x0009A600
  1170. public static IEnumerable<FileInfo> EnumerateFiles(string Directory)
  1171. {
  1172. DirectoryInfo directoryInfo = new DirectoryInfo(Directory);
  1173. IEnumerable<FileInfo> result;
  1174. if (!directoryInfo.Exists)
  1175. {
  1176. result = new List<FileInfo>();
  1177. }
  1178. else
  1179. {
  1180. result = directoryInfo.EnumerateFiles("*", SearchOption.AllDirectories);
  1181. }
  1182. return result;
  1183. }
  1184. // Token: 0x060017D1 RID: 6097 RVA: 0x0009C434 File Offset: 0x0009A634
  1185. public static string GetExceptionDetail(Exception Ex, bool ShowAllTrace = false)
  1186. {
  1187. ModBase._Closure$__75-0 CS$<>8__locals1 = new ModBase._Closure$__75-0(CS$<>8__locals1);
  1188. string result;
  1189. if (Ex == null)
  1190. {
  1191. result = "无可用错误信息!";
  1192. }
  1193. else
  1194. {
  1195. Exception ex = Ex;
  1196. while (ex.InnerException != null)
  1197. {
  1198. ex = ex.InnerException;
  1199. }
  1200. List<string> list = new List<string>();
  1201. List<string> list2 = new List<string>();
  1202. while (Ex != null)
  1203. {
  1204. list.Add(Ex.Message.Replace("\r\n", "\r").Replace("\n", "\r").Replace("\r\r", "\r").Replace("\r", "\r\n"));
  1205. if (Ex.StackTrace != null)
  1206. {
  1207. foreach (string text in Ex.StackTrace.Split("\r\n"))
  1208. {
  1209. if (ShowAllTrace || text.ToLower().Contains("pcl"))
  1210. {
  1211. list2.Add(text.Replace("\r", string.Empty).Replace("\n", string.Empty));
  1212. }
  1213. }
  1214. }
  1215. Ex = Ex.InnerException;
  1216. }
  1217. list = Enumerable.ToList<string>(Enumerable.Distinct<string>(list));
  1218. CS$<>8__locals1.$VB$Local_Desc = list.Join("\r\n→ ");
  1219. string text2 = Enumerable.Any<string>(list2) ? ("\r\n" + list2.Join("\r\n")) : "";
  1220. string text3 = null;
  1221. if (!(ex is TypeLoadException) && !(ex is BadImageFormatException) && !(ex is MissingMethodException) && !(ex is NotImplementedException) && !(ex is TypeInitializationException))
  1222. {
  1223. if (ex is UnauthorizedAccessException)
  1224. {
  1225. text3 = "PCL 的权限不足。请尝试右键 PCL,选择以管理员身份运行。";
  1226. }
  1227. else if (ex is OutOfMemoryException)
  1228. {
  1229. text3 = "你的电脑运行内存不足,导致 PCL 无法继续运行。请在关闭一部分不需要的程序后再试。";
  1230. }
  1231. else if (ex is COMException)
  1232. {
  1233. text3 = "由于操作系统或显卡存在问题,导致出现错误。请尝试重启 PCL。";
  1234. }
  1235. else if (Enumerable.Any<string>(new string[]
  1236. {
  1237. "远程主机强迫关闭了",
  1238. "远程方已关闭传输流",
  1239. "未能解析此远程名称",
  1240. "由于目标计算机积极拒绝",
  1241. "操作已超时",
  1242. "操作超时",
  1243. "服务器超时",
  1244. "连接超时"
  1245. }, (string s) => CS$<>8__locals1.$VB$Local_Desc.Contains(s)))
  1246. {
  1247. text3 = "你的网络环境不佳,导致难以连接到服务器。请检查网络,多重试几次,或尝试使用 VPN。";
  1248. }
  1249. }
  1250. else
  1251. {
  1252. text3 = "PCL 的运行环境存在问题。请尝试重新安装 .NET Framework 4.6.2 然后再试。若无法安装,请先卸载较新版本的 .NET Framework,然后再尝试安装。";
  1253. }
  1254. string text4 = (Operators.CompareString(ex.GetType().FullName, "System.Exception", false) == 0) ? "" : ("\r\n错误类型:" + ex.GetType().FullName);
  1255. if (text3 == null)
  1256. {
  1257. result = CS$<>8__locals1.$VB$Local_Desc + text2 + text4;
  1258. }
  1259. else
  1260. {
  1261. string str = text3 + "\r\n" + Enumerable.First<string>(list) + "\r\n————————————\r\n";
  1262. list[0] = "详细错误信息:";
  1263. result = str + list.Join("\r\n→ ") + text2 + text4;
  1264. }
  1265. }
  1266. return result;
  1267. }
  1268. // Token: 0x060017D2 RID: 6098 RVA: 0x0009C6E8 File Offset: 0x0009A8E8
  1269. public static string GetExceptionSummary(Exception Ex)
  1270. {
  1271. ModBase._Closure$__76-0 CS$<>8__locals1 = new ModBase._Closure$__76-0(CS$<>8__locals1);
  1272. string result;
  1273. if (Ex == null)
  1274. {
  1275. result = "无可用错误信息!";
  1276. }
  1277. else
  1278. {
  1279. Exception ex = Ex;
  1280. while (ex.InnerException != null)
  1281. {
  1282. ex = ex.InnerException;
  1283. }
  1284. List<string> list = new List<string>();
  1285. while (Ex != null)
  1286. {
  1287. list.Add(Ex.Message.Replace("\r\n", "\r").Replace("\n", "\r").Replace("\r\r", "\r").Replace("\r", " "));
  1288. Ex = Ex.InnerException;
  1289. }
  1290. list = Enumerable.ToList<string>(Enumerable.Distinct<string>(list));
  1291. CS$<>8__locals1.$VB$Local_Desc = list.Join("\r\n→ ");
  1292. string text = null;
  1293. if (!(ex is TypeLoadException) && !(ex is BadImageFormatException) && !(ex is MissingMethodException) && !(ex is NotImplementedException) && !(ex is TypeInitializationException))
  1294. {
  1295. if (ex is UnauthorizedAccessException)
  1296. {
  1297. text = "PCL 的权限不足。请尝试右键 PCL,选择以管理员身份运行。";
  1298. }
  1299. else if (ex is OutOfMemoryException)
  1300. {
  1301. text = "你的电脑运行内存不足,导致 PCL 无法继续运行。请在关闭一部分不需要的程序后再试。";
  1302. }
  1303. else if (ex is COMException)
  1304. {
  1305. text = "由于操作系统或显卡存在问题,导致出现错误。请尝试重启 PCL。";
  1306. }
  1307. else if (Enumerable.Any<string>(new string[]
  1308. {
  1309. "远程主机强迫关闭了",
  1310. "远程方已关闭传输流",
  1311. "未能解析此远程名称",
  1312. "由于目标计算机积极拒绝",
  1313. "操作已超时",
  1314. "操作超时",
  1315. "服务器超时",
  1316. "连接超时"
  1317. }, (string s) => CS$<>8__locals1.$VB$Local_Desc.Contains(s)))
  1318. {
  1319. text = "你的网络环境不佳,导致难以连接到服务器。请检查网络,多重试几次,或尝试使用 VPN。";
  1320. }
  1321. }
  1322. else
  1323. {
  1324. text = "PCL 的运行环境存在问题。请尝试重新安装 .NET Framework 4.6.2 然后再试。若无法安装,请先卸载较新版本的 .NET Framework,然后再尝试安装。";
  1325. }
  1326. if (text != null)
  1327. {
  1328. result = text + "详细错误:" + Enumerable.First<string>(list);
  1329. }
  1330. else
  1331. {
  1332. list.Reverse();
  1333. result = list.Join(" → ");
  1334. }
  1335. }
  1336. return result;
  1337. }
  1338. // Token: 0x060017D3 RID: 6099 RVA: 0x0000D4B2 File Offset: 0x0000B6B2
  1339. public static string GetStringFromEnum(Enum EnumData)
  1340. {
  1341. return Enum.GetName(EnumData.GetType(), EnumData);
  1342. }
  1343. // Token: 0x060017D4 RID: 6100 RVA: 0x0009C89C File Offset: 0x0009AA9C
  1344. public static string GetString(long FileSize)
  1345. {
  1346. checked
  1347. {
  1348. bool flag;
  1349. if (flag = (FileSize < 0L))
  1350. {
  1351. FileSize *= -1L;
  1352. }
  1353. string result;
  1354. if (FileSize < 1000L)
  1355. {
  1356. result = (flag ? "-" : "") + Conversions.ToString(FileSize) + " B";
  1357. }
  1358. else if (FileSize < 1024000L)
  1359. {
  1360. string text = Conversions.ToString(Math.Round((double)FileSize / 1024.0));
  1361. result = (flag ? "-" : "") + Conversions.ToString(Math.Round((double)FileSize / 1024.0, (int)Math.Round(ModBase.MathClamp((double)(3 - text.Length), 0.0, 2.0)))) + " K";
  1362. }
  1363. else if (FileSize < 1048576000L)
  1364. {
  1365. string text2 = Conversions.ToString(Math.Round((double)FileSize / 1024.0 / 1024.0));
  1366. result = (flag ? "-" : "") + Conversions.ToString(Math.Round((double)FileSize / 1024.0 / 1024.0, (int)Math.Round(ModBase.MathClamp((double)(3 - text2.Length), 0.0, 2.0)))) + " M";
  1367. }
  1368. else
  1369. {
  1370. string text3 = Conversions.ToString(Math.Round((double)FileSize / 1024.0 / 1024.0 / 1024.0));
  1371. result = (flag ? "-" : "") + Conversions.ToString(Math.Round((double)FileSize / 1024.0 / 1024.0 / 1024.0, (int)Math.Round(ModBase.MathClamp((double)(3 - text3.Length), 0.0, 2.0)))) + " G";
  1372. }
  1373. return result;
  1374. }
  1375. }
  1376. // Token: 0x060017D5 RID: 6101 RVA: 0x0009CAA4 File Offset: 0x0009ACA4
  1377. public static object GetJson(string Data)
  1378. {
  1379. object result;
  1380. try
  1381. {
  1382. result = JsonConvert.DeserializeObject(Data, new JsonSerializerSettings
  1383. {
  1384. DateTimeZoneHandling = 0
  1385. });
  1386. }
  1387. catch (Exception ex)
  1388. {
  1389. int length = (Data ?? "").Length;
  1390. throw new Exception("格式化 JSON 失败:" + ((length > 2000) ? (Data.Substring(0, 500) + string.Format("...(全长 {0} 个字符)...", length) + Strings.Right(Data, 500)) : Data));
  1391. }
  1392. return result;
  1393. }
  1394. // Token: 0x060017D6 RID: 6102 RVA: 0x0009CB38 File Offset: 0x0009AD38
  1395. public static string Capitalize(this string word)
  1396. {
  1397. string result;
  1398. if (string.IsNullOrEmpty(word))
  1399. {
  1400. result = word;
  1401. }
  1402. else
  1403. {
  1404. result = word.Substring(0, 1).ToUpperInvariant() + word.Substring(1).ToLowerInvariant();
  1405. }
  1406. return result;
  1407. }
  1408. // Token: 0x060017D7 RID: 6103 RVA: 0x0009CB74 File Offset: 0x0009AD74
  1409. public static string StrFill(string Str, string Code, byte Length)
  1410. {
  1411. string result;
  1412. if (Str.Length > (int)Length)
  1413. {
  1414. result = Strings.Mid(Str, 1, (int)Length);
  1415. }
  1416. else
  1417. {
  1418. result = Strings.Mid(Str.PadRight((int)Length, Conversions.ToChar(Code)), checked(Str.Length + 1)) + Str;
  1419. }
  1420. return result;
  1421. }
  1422. // Token: 0x060017D8 RID: 6104 RVA: 0x0009CBB8 File Offset: 0x0009ADB8
  1423. public static string StrFillNum(double Num, int Length)
  1424. {
  1425. Num = Math.Round(Num, Length, MidpointRounding.AwayFromZero);
  1426. string text = Conversions.ToString(Num);
  1427. checked
  1428. {
  1429. if (!text.Contains("."))
  1430. {
  1431. text = (text + ".").PadRight(text.Length + 1 + Length, '0');
  1432. }
  1433. else
  1434. {
  1435. text = text.PadRight(text.Split(".")[0].Length + 1 + Length, '0');
  1436. }
  1437. return text;
  1438. }
  1439. }
  1440. // Token: 0x060017D9 RID: 6105 RVA: 0x0009CC24 File Offset: 0x0009AE24
  1441. public static object StrTrim(string Str, bool RemoveQuote = true)
  1442. {
  1443. if (RemoveQuote)
  1444. {
  1445. Str = Str.Split("(")[0].Split(":")[0].Split("(")[0].Split(":")[0];
  1446. }
  1447. return Str.Trim(new char[]
  1448. {
  1449. '.',
  1450. '。',
  1451. '!',
  1452. ' ',
  1453. '!',
  1454. '?',
  1455. '?',
  1456. '\r',
  1457. '\n'
  1458. });
  1459. }
  1460. // Token: 0x060017DA RID: 6106 RVA: 0x0009CC80 File Offset: 0x0009AE80
  1461. public static string Join(this IEnumerable List, string Split)
  1462. {
  1463. StringBuilder stringBuilder = new StringBuilder();
  1464. bool flag = true;
  1465. try
  1466. {
  1467. foreach (object obj in List)
  1468. {
  1469. object objectValue = RuntimeHelpers.GetObjectValue(obj);
  1470. if (flag)
  1471. {
  1472. flag = false;
  1473. }
  1474. else
  1475. {
  1476. stringBuilder.Append(Split);
  1477. }
  1478. if (objectValue != null)
  1479. {
  1480. stringBuilder.Append(RuntimeHelpers.GetObjectValue(objectValue));
  1481. }
  1482. }
  1483. }
  1484. finally
  1485. {
  1486. IEnumerator enumerator;
  1487. if (enumerator is IDisposable)
  1488. {
  1489. (enumerator as IDisposable).Dispose();
  1490. }
  1491. }
  1492. return stringBuilder.ToString();
  1493. }
  1494. // Token: 0x060017DB RID: 6107 RVA: 0x0009CD00 File Offset: 0x0009AF00
  1495. public static string[] Split(this string FullStr, string SplitStr)
  1496. {
  1497. string[] result;
  1498. if (SplitStr.Length == 1)
  1499. {
  1500. result = FullStr.Split(new char[]
  1501. {
  1502. SplitStr[0]
  1503. });
  1504. }
  1505. else
  1506. {
  1507. result = FullStr.Split(new string[]
  1508. {
  1509. SplitStr
  1510. }, StringSplitOptions.None);
  1511. }
  1512. return result;
  1513. }
  1514. // Token: 0x060017DC RID: 6108 RVA: 0x0009CD44 File Offset: 0x0009AF44
  1515. public static ulong GetHash(string Str)
  1516. {
  1517. ulong num = 5381UL;
  1518. checked
  1519. {
  1520. int num2 = Str.Length - 1;
  1521. for (int i = 0; i <= num2; i++)
  1522. {
  1523. num = (num << 5 ^ num ^ (ulong)Str[i]);
  1524. }
  1525. return num ^ 12218072394304324399UL;
  1526. }
  1527. }
  1528. // Token: 0x060017DD RID: 6109 RVA: 0x0009CD8C File Offset: 0x0009AF8C
  1529. public static string GetStringMD5(string Str)
  1530. {
  1531. byte[] array = new MD5CryptoServiceProvider().ComputeHash(Encoding.GetEncoding("gb2312").GetBytes(Str));
  1532. StringBuilder stringBuilder = new StringBuilder();
  1533. foreach (byte b in array)
  1534. {
  1535. stringBuilder.Append(b.ToString("x2"));
  1536. }
  1537. return stringBuilder.ToString();
  1538. }
  1539. // Token: 0x060017DE RID: 6110 RVA: 0x0000D4C0 File Offset: 0x0000B6C0
  1540. public static bool IsASCII(this string Input)
  1541. {
  1542. return Enumerable.All<char>(Input, (ModBase._Closure$__.$I88-0 == null) ? (ModBase._Closure$__.$I88-0 = ((char c) => c < '\u0080')) : ModBase._Closure$__.$I88-0);
  1543. }
  1544. // Token: 0x060017DF RID: 6111 RVA: 0x0009CDE8 File Offset: 0x0009AFE8
  1545. public static string BeforeFirst(this string Str, string Text, bool IgnoreCase = false)
  1546. {
  1547. int num = string.IsNullOrEmpty(Text) ? -1 : Str.IndexOfF(Text, IgnoreCase);
  1548. string result;
  1549. if (num >= 0)
  1550. {
  1551. result = Str.Substring(0, num);
  1552. }
  1553. else
  1554. {
  1555. result = Str;
  1556. }
  1557. return result;
  1558. }
  1559. // Token: 0x060017E0 RID: 6112 RVA: 0x0009CE1C File Offset: 0x0009B01C
  1560. public static string BeforeLast(this string Str, string Text, bool IgnoreCase = false)
  1561. {
  1562. int num = string.IsNullOrEmpty(Text) ? -1 : Str.LastIndexOfF(Text, IgnoreCase);
  1563. string result;
  1564. if (num >= 0)
  1565. {
  1566. result = Str.Substring(0, num);
  1567. }
  1568. else
  1569. {
  1570. result = Str;
  1571. }
  1572. return result;
  1573. }
  1574. // Token: 0x060017E1 RID: 6113 RVA: 0x0009CE50 File Offset: 0x0009B050
  1575. public static string AfterFirst(this string Str, string Text, bool IgnoreCase = false)
  1576. {
  1577. int num = string.IsNullOrEmpty(Text) ? -1 : Str.IndexOfF(Text, IgnoreCase);
  1578. string result;
  1579. if (num >= 0)
  1580. {
  1581. result = Str.Substring(checked(num + Text.Length));
  1582. }
  1583. else
  1584. {
  1585. result = Str;
  1586. }
  1587. return result;
  1588. }
  1589. // Token: 0x060017E2 RID: 6114 RVA: 0x0009CE8C File Offset: 0x0009B08C
  1590. public static string AfterLast(this string Str, string Text, bool IgnoreCase = false)
  1591. {
  1592. int num = string.IsNullOrEmpty(Text) ? -1 : Str.LastIndexOfF(Text, IgnoreCase);
  1593. string result;
  1594. if (num >= 0)
  1595. {
  1596. result = Str.Substring(checked(num + Text.Length));
  1597. }
  1598. else
  1599. {
  1600. result = Str;
  1601. }
  1602. return result;
  1603. }
  1604. // Token: 0x060017E3 RID: 6115 RVA: 0x0009CEC8 File Offset: 0x0009B0C8
  1605. public static string Between(this string Str, string After, string Before, bool IgnoreCase = false)
  1606. {
  1607. int num = string.IsNullOrEmpty(After) ? -1 : Str.LastIndexOfF(After, IgnoreCase);
  1608. checked
  1609. {
  1610. if (num >= 0)
  1611. {
  1612. num += After.Length;
  1613. }
  1614. else
  1615. {
  1616. num = 0;
  1617. }
  1618. int num2 = string.IsNullOrEmpty(Before) ? -1 : Str.IndexOfF(Before, num, IgnoreCase);
  1619. string result;
  1620. if (num2 >= 0)
  1621. {
  1622. result = Str.Substring(num, num2 - num);
  1623. }
  1624. else if (num > 0)
  1625. {
  1626. result = Str.Substring(num);
  1627. }
  1628. else
  1629. {
  1630. result = Str;
  1631. }
  1632. return result;
  1633. }
  1634. }
  1635. // Token: 0x060017E4 RID: 6116 RVA: 0x0000D4EC File Offset: 0x0000B6EC
  1636. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1637. public static bool StartsWithF(this string Str, string Prefix, bool IgnoreCase = false)
  1638. {
  1639. return Str.StartsWith(Prefix, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1640. }
  1641. // Token: 0x060017E5 RID: 6117 RVA: 0x0000D4FC File Offset: 0x0000B6FC
  1642. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1643. public static bool EndsWithF(this string Str, string Suffix, bool IgnoreCase = false)
  1644. {
  1645. return Str.EndsWith(Suffix, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1646. }
  1647. // Token: 0x060017E6 RID: 6118 RVA: 0x0000D50C File Offset: 0x0000B70C
  1648. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1649. public static bool ContainsF(this string Str, string SubStr, bool IgnoreCase = false)
  1650. {
  1651. return Str.IndexOf(SubStr, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) >= 0;
  1652. }
  1653. // Token: 0x060017E7 RID: 6119 RVA: 0x0000D522 File Offset: 0x0000B722
  1654. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1655. public static int IndexOfF(this string Str, string SubStr, bool IgnoreCase = false)
  1656. {
  1657. return Str.IndexOf(SubStr, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1658. }
  1659. // Token: 0x060017E8 RID: 6120 RVA: 0x0000D532 File Offset: 0x0000B732
  1660. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1661. public static int IndexOfF(this string Str, string SubStr, int StartIndex, bool IgnoreCase = false)
  1662. {
  1663. return Str.IndexOf(SubStr, StartIndex, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1664. }
  1665. // Token: 0x060017E9 RID: 6121 RVA: 0x0000D543 File Offset: 0x0000B743
  1666. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1667. public static int LastIndexOfF(this string Str, string SubStr, bool IgnoreCase = false)
  1668. {
  1669. return Str.LastIndexOf(SubStr, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1670. }
  1671. // Token: 0x060017EA RID: 6122 RVA: 0x0000D553 File Offset: 0x0000B753
  1672. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  1673. public static int LastIndexOfF(this string Str, string SubStr, int StartIndex, bool IgnoreCase = false)
  1674. {
  1675. return Str.LastIndexOf(SubStr, StartIndex, IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
  1676. }
  1677. // Token: 0x060017EB RID: 6123 RVA: 0x0009CF34 File Offset: 0x0009B134
  1678. public static double Val(object Str)
  1679. {
  1680. double result;
  1681. try
  1682. {
  1683. result = ((!(Str is string) || !Operators.ConditionalCompareObjectEqual(Str, "&", false)) ? Conversion.Val(RuntimeHelpers.GetObjectValue(Str)) : 0.0);
  1684. }
  1685. catch (Exception ex)
  1686. {
  1687. result = 0.0;
  1688. }
  1689. return result;
  1690. }
  1691. // Token: 0x060017EC RID: 6124 RVA: 0x0009CF98 File Offset: 0x0009B198
  1692. public static string smethod_3(string Str)
  1693. {
  1694. if (Str.StartsWithF("{", false))
  1695. {
  1696. Str = "{}" + Str;
  1697. }
  1698. return Str.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("'", "&apos;").Replace("\"", "&quot;").Replace("\r\n", "&#xa;");
  1699. }
  1700. // Token: 0x060017ED RID: 6125 RVA: 0x0009D01C File Offset: 0x0009B21C
  1701. public static List<string> RegexSearch(string str, string regex, RegexOptions options = 0)
  1702. {
  1703. List<string> list;
  1704. try
  1705. {
  1706. list = new List<string>();
  1707. MatchCollection matchCollection = new Regex(regex, options).Matches(str);
  1708. if (matchCollection == null)
  1709. {
  1710. list = list;
  1711. }
  1712. else
  1713. {
  1714. try
  1715. {
  1716. foreach (object obj in matchCollection)
  1717. {
  1718. Match match = (Match)obj;
  1719. list.Add(match.Value);
  1720. }
  1721. }
  1722. finally
  1723. {
  1724. IEnumerator enumerator;
  1725. if (enumerator is IDisposable)
  1726. {
  1727. (enumerator as IDisposable).Dispose();
  1728. }
  1729. }
  1730. }
  1731. }
  1732. catch (Exception ex)
  1733. {
  1734. ModBase.Log(ex, "正则匹配全部项出错", ModBase.LogLevel.Debug, "出现错误");
  1735. list = new List<string>();
  1736. }
  1737. return list;
  1738. }
  1739. // Token: 0x060017EE RID: 6126 RVA: 0x0009D0CC File Offset: 0x0009B2CC
  1740. public static string RegexSeek(string str, string regex, RegexOptions options = 0)
  1741. {
  1742. string result;
  1743. try
  1744. {
  1745. string value = Regex.Match(str, regex, options).Value;
  1746. result = ((Operators.CompareString(value, "", false) == 0) ? null : value);
  1747. }
  1748. catch (Exception ex)
  1749. {
  1750. ModBase.Log(ex, "正则匹配第一项出错", ModBase.LogLevel.Debug, "出现错误");
  1751. result = null;
  1752. }
  1753. return result;
  1754. }
  1755. // Token: 0x060017EF RID: 6127 RVA: 0x0009D130 File Offset: 0x0009B330
  1756. public static bool RegexCheck(string str, string regex, RegexOptions options = 0)
  1757. {
  1758. bool result;
  1759. try
  1760. {
  1761. result = Regex.IsMatch(str, regex, options);
  1762. }
  1763. catch (Exception ex)
  1764. {
  1765. ModBase.Log(ex, "正则检查出错", ModBase.LogLevel.Debug, "出现错误");
  1766. result = false;
  1767. }
  1768. return result;
  1769. }
  1770. // Token: 0x060017F0 RID: 6128 RVA: 0x0000D564 File Offset: 0x0000B764
  1771. public static string RegexReplace(string Input, string Replacement, string Regex, RegexOptions options = 0)
  1772. {
  1773. return Regex.Replace(Input, Regex, Replacement, options);
  1774. }
  1775. // Token: 0x060017F1 RID: 6129 RVA: 0x0000D56F File Offset: 0x0000B76F
  1776. public static string RegexReplaceEach(string Input, MatchEvaluator Replacement, string Regex, RegexOptions options = 0)
  1777. {
  1778. return Regex.Replace(Input, Regex, Replacement, options);
  1779. }
  1780. // Token: 0x060017F2 RID: 6130 RVA: 0x0009D17C File Offset: 0x0009B37C
  1781. private static double SearchSimilarity(string Source, string Query)
  1782. {
  1783. int i = 0;
  1784. double num = 0.0;
  1785. Source = Source.ToLower().Replace(" ", "");
  1786. Query = Query.ToLower().Replace(" ", "");
  1787. int length = Source.Length;
  1788. int length2 = Query.Length;
  1789. checked
  1790. {
  1791. while (i < length2)
  1792. {
  1793. int j = 0;
  1794. int num2 = 0;
  1795. int num3 = 0;
  1796. while (j < Source.Length)
  1797. {
  1798. int num4 = 0;
  1799. while (i + num4 < length2 && j + num4 < Source.Length)
  1800. {
  1801. if (Source[j + num4] != Query[i + num4])
  1802. {
  1803. break;
  1804. }
  1805. num4++;
  1806. }
  1807. if (num4 > num2)
  1808. {
  1809. num2 = num4;
  1810. num3 = j;
  1811. }
  1812. j += Math.Max(1, num4);
  1813. }
  1814. if (num2 > 0)
  1815. {
  1816. Source = Source.Substring(0, num3) + ((Enumerable.Count<char>(Source) > num3 + num2) ? Source.Substring(num3 + num2) : string.Empty);
  1817. unchecked
  1818. {
  1819. double num5 = Math.Pow(1.4, (double)(checked(3 + num2))) - 3.6;
  1820. num5 *= 1.0 + 0.3 * (double)Math.Max(0, checked(3 - Math.Abs(i - num3)));
  1821. num += num5;
  1822. }
  1823. }
  1824. i += Math.Max(1, num2);
  1825. }
  1826. }
  1827. return num / (double)length2 * (3.0 / Math.Pow((double)(checked(length + 15)), 0.5)) * (double)((length2 <= 2) ? checked(3 - length2) : 1);
  1828. }
  1829. // Token: 0x060017F3 RID: 6131 RVA: 0x0009D304 File Offset: 0x0009B504
  1830. private static double SearchSimilarityWeighted(List<KeyValuePair<string, double>> Source, string Query)
  1831. {
  1832. double num = 0.0;
  1833. double num2 = 0.0;
  1834. try
  1835. {
  1836. foreach (KeyValuePair<string, double> keyValuePair in Source)
  1837. {
  1838. num2 += ModBase.SearchSimilarity(keyValuePair.Key, Query) * keyValuePair.Value;
  1839. num += keyValuePair.Value;
  1840. }
  1841. }
  1842. finally
  1843. {
  1844. List<KeyValuePair<string, double>>.Enumerator enumerator;
  1845. ((IDisposable)enumerator).Dispose();
  1846. }
  1847. return num2 / num;
  1848. }
  1849. // Token: 0x060017F4 RID: 6132 RVA: 0x0009D384 File Offset: 0x0009B584
  1850. public static List<ModBase.SearchEntry<T>> Search<T>(List<ModBase.SearchEntry<T>> Entries, string Query, int MaxBlurCount = 5, double MinBlurSimilarity = 0.1)
  1851. {
  1852. List<ModBase.SearchEntry<T>> list = new List<ModBase.SearchEntry<!!0>>();
  1853. checked
  1854. {
  1855. List<ModBase.SearchEntry<T>> result;
  1856. if (!Enumerable.Any<ModBase.SearchEntry<T>>(Entries))
  1857. {
  1858. result = list;
  1859. }
  1860. else
  1861. {
  1862. try
  1863. {
  1864. List<ModBase.SearchEntry<T>>.Enumerator enumerator = Entries.GetEnumerator();
  1865. while (enumerator.MoveNext())
  1866. {
  1867. ModBase._Closure$__111-0<T> CS$<>8__locals1 = new ModBase._Closure$__111-0<!!0>(CS$<>8__locals1);
  1868. CS$<>8__locals1.$VB$Local_Entry = enumerator.Current;
  1869. CS$<>8__locals1.$VB$Local_Entry.m_IssuerError = ModBase.SearchSimilarityWeighted(CS$<>8__locals1.$VB$Local_Entry.helperError, Query);
  1870. CS$<>8__locals1.$VB$Local_Entry.indexerError = Enumerable.All<string>(Query.Split(" "), delegate(string QueryPart)
  1871. {
  1872. ModBase._Closure$__111-1<$CLS0> CS$<>8__locals2 = new ModBase._Closure$__111-1<!0>(CS$<>8__locals2);
  1873. CS$<>8__locals2.$VB$Local_QueryPart = QueryPart;
  1874. return Enumerable.Any<KeyValuePair<string, double>>(CS$<>8__locals1.$VB$Local_Entry.helperError, (KeyValuePair<string, double> Source) => Source.Key.Replace(" ", "").ContainsF(CS$<>8__locals2.$VB$Local_QueryPart, true));
  1875. });
  1876. }
  1877. }
  1878. finally
  1879. {
  1880. List<ModBase.SearchEntry<T>>.Enumerator enumerator;
  1881. ((IDisposable)enumerator).Dispose();
  1882. }
  1883. Entries = Entries.Sort((ModBase._Closure$__111<!!0>.$I111-2 == null) ? (ModBase._Closure$__111<!!0>.$I111-2 = delegate(ModBase.SearchEntry<$CLS0> Left, ModBase.SearchEntry<$CLS0> Right)
  1884. {
  1885. bool result2;
  1886. if (Left.indexerError ^ Right.indexerError)
  1887. {
  1888. result2 = Left.indexerError;
  1889. }
  1890. else
  1891. {
  1892. result2 = (Left.m_IssuerError > Right.m_IssuerError);
  1893. }
  1894. return result2;
  1895. }) : ModBase._Closure$__111<!!0>.$I111-2);
  1896. int num = 0;
  1897. try
  1898. {
  1899. foreach (ModBase.SearchEntry<T> searchEntry in Entries)
  1900. {
  1901. if (searchEntry.indexerError)
  1902. {
  1903. list.Add(searchEntry);
  1904. }
  1905. else
  1906. {
  1907. if (searchEntry.m_IssuerError < MinBlurSimilarity)
  1908. {
  1909. break;
  1910. }
  1911. if (num == MaxBlurCount)
  1912. {
  1913. break;
  1914. }
  1915. list.Add(searchEntry);
  1916. num++;
  1917. }
  1918. }
  1919. }
  1920. finally
  1921. {
  1922. List<ModBase.SearchEntry<T>>.Enumerator enumerator2;
  1923. ((IDisposable)enumerator2).Dispose();
  1924. }
  1925. result = list;
  1926. }
  1927. return result;
  1928. }
  1929. }
  1930. // Token: 0x060017F5 RID: 6133 RVA: 0x0009D4D8 File Offset: 0x0009B6D8
  1931. private static string GetPureASCIIDir()
  1932. {
  1933. string result;
  1934. if ((ModBase.Path + "PCL").IsASCII())
  1935. {
  1936. result = ModBase.Path + "PCL\\";
  1937. }
  1938. else if (ModBase.m_InstanceRepository.IsASCII())
  1939. {
  1940. result = ModBase.m_InstanceRepository;
  1941. }
  1942. else if (ModBase.m_DecoratorRepository.IsASCII())
  1943. {
  1944. result = ModBase.m_DecoratorRepository;
  1945. }
  1946. else
  1947. {
  1948. result = ModBase._RefRepository + "ProgramData\\PCL\\";
  1949. }
  1950. return result;
  1951. }
  1952. // Token: 0x060017F6 RID: 6134 RVA: 0x0009D548 File Offset: 0x0009B748
  1953. public static bool IsAdmin()
  1954. {
  1955. WindowsIdentity current = WindowsIdentity.GetCurrent();
  1956. return new WindowsPrincipal(current).IsInRole(WindowsBuiltInRole.Administrator);
  1957. }
  1958. // Token: 0x060017F7 RID: 6135 RVA: 0x0000D57A File Offset: 0x0000B77A
  1959. public static int RunAsAdmin(string Argument)
  1960. {
  1961. Process process = Process.Start(new ProcessStartInfo(ModBase.interpreterRepository)
  1962. {
  1963. Verb = "runas",
  1964. Arguments = Argument
  1965. });
  1966. process.WaitForExit();
  1967. return process.ExitCode;
  1968. }
  1969. // Token: 0x060017F8 RID: 6136 RVA: 0x0000D5A8 File Offset: 0x0000B7A8
  1970. public static bool IsSystemLanguageChinese()
  1971. {
  1972. return Operators.CompareString(CultureInfo.CurrentCulture.TwoLetterISOLanguageName, "zh", false) == 0 || Operators.CompareString(CultureInfo.CurrentUICulture.TwoLetterISOLanguageName, "zh", false) == 0;
  1973. }
  1974. // Token: 0x060017F9 RID: 6137 RVA: 0x0009D56C File Offset: 0x0009B76C
  1975. public static int GetUuid()
  1976. {
  1977. if (ModBase.m_ConsumerRepository == null)
  1978. {
  1979. ModBase.m_ConsumerRepository = RuntimeHelpers.GetObjectValue(new object());
  1980. }
  1981. object consumerRepository = ModBase.m_ConsumerRepository;
  1982. ObjectFlowControl.CheckForSyncLockOnValueType(consumerRepository);
  1983. checked
  1984. {
  1985. int result;
  1986. lock (consumerRepository)
  1987. {
  1988. ModBase.taskRepository++;
  1989. result = ModBase.taskRepository;
  1990. }
  1991. return result;
  1992. }
  1993. }
  1994. // Token: 0x060017FA RID: 6138 RVA: 0x0009D5D4 File Offset: 0x0009B7D4
  1995. public static List<T> GetFullList<T>(IList data)
  1996. {
  1997. List<T> list = new List<!!0>();
  1998. checked
  1999. {
  2000. int num = data.Count - 1;
  2001. for (int i = 0; i <= num; i++)
  2002. {
  2003. if (data[i] is ICollection)
  2004. {
  2005. list.AddRange((IEnumerable<!!0>)data[i]);
  2006. }
  2007. else
  2008. {
  2009. list.Add(Conversions.ToGenericParameter<T>(data[i]));
  2010. }
  2011. }
  2012. return list;
  2013. }
  2014. }
  2015. // Token: 0x060017FB RID: 6139 RVA: 0x0009D634 File Offset: 0x0009B834
  2016. public static List<T> Distinct<T>(this ICollection<T> Arr, ModBase.CompareThreadStart<T> IsEqual)
  2017. {
  2018. List<T> list = new List<!!0>();
  2019. checked
  2020. {
  2021. int num = Arr.Count - 1;
  2022. int i = 0;
  2023. IL_56:
  2024. while (i <= num)
  2025. {
  2026. int num2 = i + 1;
  2027. int num3 = Arr.Count - 1;
  2028. for (int j = num2; j <= num3; j++)
  2029. {
  2030. if (IsEqual(Enumerable.ElementAtOrDefault<T>(Arr, i), Enumerable.ElementAtOrDefault<T>(Arr, j)))
  2031. {
  2032. IL_52:
  2033. i++;
  2034. goto IL_56;
  2035. }
  2036. }
  2037. list.Add(Enumerable.ElementAtOrDefault<T>(Arr, i));
  2038. goto IL_52;
  2039. }
  2040. return list;
  2041. }
  2042. }
  2043. // Token: 0x060017FC RID: 6140 RVA: 0x0009D69C File Offset: 0x0009B89C
  2044. public static string GetTimeNow()
  2045. {
  2046. return DateTime.Now.ToString("HH':'mm':'ss'.'fff");
  2047. }
  2048. // Token: 0x060017FD RID: 6141 RVA: 0x0000D5DB File Offset: 0x0000B7DB
  2049. public static long GetTimeTick()
  2050. {
  2051. return checked(unchecked((long)MyWpfExtension.ManageParser().Clock.TickCount) + 2147483651L);
  2052. }
  2053. // Token: 0x060017FE RID: 6142 RVA: 0x0009D6BC File Offset: 0x0009B8BC
  2054. public static string GetTimeSpanString(TimeSpan Span, bool IsShortForm)
  2055. {
  2056. string str = (Span.TotalMilliseconds > 0.0) ? "后" : "前";
  2057. if (Span.TotalMilliseconds < 0.0)
  2058. {
  2059. Span = -Span;
  2060. }
  2061. double num = Math.Floor((double)Span.Days / 30.0);
  2062. string str2;
  2063. if (IsShortForm)
  2064. {
  2065. if (num >= 12.0)
  2066. {
  2067. str2 = Conversions.ToString(Math.Floor(num / 12.0)) + " 年";
  2068. }
  2069. else if (num >= 2.0)
  2070. {
  2071. str2 = Conversions.ToString(num) + " 个月";
  2072. }
  2073. else if (Span.TotalDays >= 2.0)
  2074. {
  2075. str2 = Conversions.ToString(Span.Days) + " 天";
  2076. }
  2077. else if (Span.TotalHours >= 1.0)
  2078. {
  2079. str2 = Conversions.ToString(Span.Hours) + " 小时";
  2080. }
  2081. else if (Span.TotalMinutes >= 1.0)
  2082. {
  2083. str2 = Conversions.ToString(Span.Minutes) + " 分钟";
  2084. }
  2085. else if (Span.TotalSeconds >= 1.0)
  2086. {
  2087. str2 = Conversions.ToString(Span.Seconds) + " 秒";
  2088. }
  2089. else
  2090. {
  2091. str2 = "1 秒";
  2092. }
  2093. }
  2094. else if (num >= 61.0)
  2095. {
  2096. str2 = Conversions.ToString(Math.Floor(num / 12.0)) + " 年";
  2097. }
  2098. else if (num >= 12.0)
  2099. {
  2100. str2 = Conversions.ToString(Math.Floor(num / 12.0)) + " 年" + ((num % 12.0 > 0.0) ? (" " + Conversions.ToString(num % 12.0) + " 个月") : "");
  2101. }
  2102. else if (num >= 4.0)
  2103. {
  2104. str2 = Conversions.ToString(num) + " 个月";
  2105. }
  2106. else if (num >= 1.0)
  2107. {
  2108. str2 = Conversions.ToString(num) + " 月" + ((Span.Days % 30 > 0) ? (" " + Conversions.ToString(Span.Days % 30) + " 天") : "");
  2109. }
  2110. else if (Span.TotalDays >= 4.0)
  2111. {
  2112. str2 = Conversions.ToString(Span.Days) + " 天";
  2113. }
  2114. else if (Span.TotalDays >= 1.0)
  2115. {
  2116. str2 = Conversions.ToString(Span.Days) + " 天" + ((Span.Hours > 0) ? (" " + Conversions.ToString(Span.Hours) + " 小时") : "");
  2117. }
  2118. else if (Span.TotalHours >= 10.0)
  2119. {
  2120. str2 = Conversions.ToString(Span.Hours) + " 小时";
  2121. }
  2122. else if (Span.TotalHours >= 1.0)
  2123. {
  2124. str2 = Conversions.ToString(Span.Hours) + " 小时" + ((Span.Minutes > 0) ? (" " + Conversions.ToString(Span.Minutes) + " 分钟") : "");
  2125. }
  2126. else if (Span.TotalMinutes >= 10.0)
  2127. {
  2128. str2 = Conversions.ToString(Span.Minutes) + " 分钟";
  2129. }
  2130. else if (Span.TotalMinutes >= 1.0)
  2131. {
  2132. str2 = Conversions.ToString(Span.Minutes) + " 分" + ((Span.Seconds > 0) ? (" " + Conversions.ToString(Span.Seconds) + " 秒") : "");
  2133. }
  2134. else if (Span.TotalSeconds >= 1.0)
  2135. {
  2136. str2 = Conversions.ToString(Span.Seconds) + " 秒";
  2137. }
  2138. else
  2139. {
  2140. str2 = "1 秒";
  2141. }
  2142. return str2 + str;
  2143. }
  2144. // Token: 0x060017FF RID: 6143 RVA: 0x0009DB1C File Offset: 0x0009BD1C
  2145. public static long GetUnixTimestamp()
  2146. {
  2147. return checked((long)Math.Round((double)(DateAndTime.Now.ToUniversalTime().Ticks - 621355968000000000L) / 10000000.0));
  2148. }
  2149. // Token: 0x06001800 RID: 6144 RVA: 0x0009DB5C File Offset: 0x0009BD5C
  2150. public static void ShellOnly(string FileName, string Arguments = "")
  2151. {
  2152. using (Process process = new Process())
  2153. {
  2154. process.StartInfo.Arguments = Arguments;
  2155. process.StartInfo.FileName = FileName;
  2156. ModBase.Log("[System] 执行外部命令:" + FileName + " " + Arguments, ModBase.LogLevel.Normal, "出现错误");
  2157. process.Start();
  2158. }
  2159. }
  2160. // Token: 0x06001801 RID: 6145 RVA: 0x0009DBC8 File Offset: 0x0009BDC8
  2161. public static ModBase.Result ShellAndGetExitCode(string FileName, string Arguments = "", int Timeout = 1000000)
  2162. {
  2163. ModBase.Result result;
  2164. try
  2165. {
  2166. using (Process process = new Process())
  2167. {
  2168. process.StartInfo.Arguments = Arguments;
  2169. process.StartInfo.FileName = FileName;
  2170. ModBase.Log("[System] 执行外部命令并等待返回码:" + FileName + " " + Arguments, ModBase.LogLevel.Normal, "出现错误");
  2171. process.Start();
  2172. if (process.WaitForExit(Timeout))
  2173. {
  2174. result = (ModBase.Result)process.ExitCode;
  2175. }
  2176. else
  2177. {
  2178. result = ModBase.Result.Timeout;
  2179. }
  2180. }
  2181. }
  2182. catch (Exception ex)
  2183. {
  2184. ModBase.Log(ex, "执行命令失败:" + FileName, ModBase.LogLevel.Msgbox, "出现错误");
  2185. result = ModBase.Result.Fail;
  2186. }
  2187. return result;
  2188. }
  2189. // Token: 0x06001802 RID: 6146 RVA: 0x0009DC7C File Offset: 0x0009BE7C
  2190. public static string ShellAndGetOutput(string FileName, string Arguments = "", int Timeout = 1000000, string WorkingDirectory = null)
  2191. {
  2192. ProcessStartInfo processStartInfo = new ProcessStartInfo
  2193. {
  2194. Arguments = Arguments,
  2195. FileName = FileName,
  2196. UseShellExecute = false,
  2197. CreateNoWindow = true,
  2198. RedirectStandardError = true,
  2199. RedirectStandardOutput = true,
  2200. WorkingDirectory = (WorkingDirectory ?? ModBase.Path.TrimEnd(new char[]
  2201. {
  2202. '\\'
  2203. }))
  2204. };
  2205. if (WorkingDirectory != null)
  2206. {
  2207. if (processStartInfo.EnvironmentVariables.ContainsKey("appdata"))
  2208. {
  2209. processStartInfo.EnvironmentVariables["appdata"] = WorkingDirectory;
  2210. }
  2211. else
  2212. {
  2213. processStartInfo.EnvironmentVariables.Add("appdata", WorkingDirectory);
  2214. }
  2215. }
  2216. ModBase.Log("[System] 执行外部命令并等待返回结果:" + FileName + " " + Arguments, ModBase.LogLevel.Normal, "出现错误");
  2217. string result;
  2218. using (Process process = new Process
  2219. {
  2220. StartInfo = processStartInfo
  2221. })
  2222. {
  2223. process.Start();
  2224. string text = process.StandardOutput.ReadToEnd() + process.StandardError.ReadToEnd();
  2225. process.WaitForExit(Timeout);
  2226. if (!process.HasExited)
  2227. {
  2228. process.Kill();
  2229. }
  2230. result = text;
  2231. }
  2232. return result;
  2233. }
  2234. // Token: 0x06001803 RID: 6147 RVA: 0x0009DD94 File Offset: 0x0009BF94
  2235. public static Thread RunInNewThread(Action Action, string Name = null, ThreadPriority Priority = ThreadPriority.Normal)
  2236. {
  2237. Thread thread = new Thread(delegate()
  2238. {
  2239. try
  2240. {
  2241. Action();
  2242. }
  2243. catch (ThreadInterruptedException ex)
  2244. {
  2245. ModBase.Log(Name + ":线程已中止", ModBase.LogLevel.Normal, "出现错误");
  2246. }
  2247. catch (Exception ex2)
  2248. {
  2249. ModBase.Log(ex2, Name + ":线程执行失败", ModBase.LogLevel.Feedback, "出现错误");
  2250. }
  2251. });
  2252. thread.Name = (Name ?? ("Runtime New Invoke " + Conversions.ToString(ModBase.GetUuid()) + "#"));
  2253. thread.Priority = Priority;
  2254. thread.Start();
  2255. return thread;
  2256. }
  2257. // Token: 0x06001804 RID: 6148 RVA: 0x0009DDFC File Offset: 0x0009BFFC
  2258. public static Output RunInUiWait<Output>(Func<Output> Action)
  2259. {
  2260. Output result;
  2261. if (ModBase.RunInUi())
  2262. {
  2263. result = Action();
  2264. }
  2265. else
  2266. {
  2267. result = System.Windows.Application.Current.Dispatcher.Invoke<Output>(Action);
  2268. }
  2269. return result;
  2270. }
  2271. // Token: 0x06001805 RID: 6149 RVA: 0x0000D5F7 File Offset: 0x0000B7F7
  2272. public static void RunInUiWait(Action Action)
  2273. {
  2274. if (ModBase.RunInUi())
  2275. {
  2276. Action();
  2277. return;
  2278. }
  2279. System.Windows.Application.Current.Dispatcher.Invoke(Action);
  2280. }
  2281. // Token: 0x06001806 RID: 6150 RVA: 0x0000D617 File Offset: 0x0000B817
  2282. public static void RunInUi(Action Action, bool ForceWaitUntilLoaded = false)
  2283. {
  2284. if (ForceWaitUntilLoaded)
  2285. {
  2286. System.Windows.Application.Current.Dispatcher.InvokeAsync(Action, DispatcherPriority.Loaded);
  2287. return;
  2288. }
  2289. if (ModBase.RunInUi())
  2290. {
  2291. Action();
  2292. return;
  2293. }
  2294. System.Windows.Application.Current.Dispatcher.InvokeAsync(Action);
  2295. }
  2296. // Token: 0x06001807 RID: 6151 RVA: 0x0000D64E File Offset: 0x0000B84E
  2297. public static void RunInThread(Action Action)
  2298. {
  2299. if (ModBase.RunInUi())
  2300. {
  2301. ModBase.RunInNewThread(Action, "Runtime Invoke " + Conversions.ToString(ModBase.GetUuid()) + "#", ThreadPriority.Normal);
  2302. return;
  2303. }
  2304. Action();
  2305. }
  2306. // Token: 0x06001808 RID: 6152 RVA: 0x0009DE2C File Offset: 0x0009C02C
  2307. public static List<T> Sort<T>(this IList<T> List, ModBase.CompareThreadStart<T> SortRule)
  2308. {
  2309. List<T> list = new List<!!0>();
  2310. checked
  2311. {
  2312. while (Enumerable.Any<T>(List))
  2313. {
  2314. T t = List[0];
  2315. int num = List.Count - 1;
  2316. for (int i = 1; i <= num; i++)
  2317. {
  2318. if (SortRule(List[i], t))
  2319. {
  2320. t = List[i];
  2321. }
  2322. }
  2323. List.Remove(t);
  2324. list.Add(t);
  2325. }
  2326. return list;
  2327. }
  2328. }
  2329. // Token: 0x06001809 RID: 6153 RVA: 0x0000D67F File Offset: 0x0000B87F
  2330. public static IList<T> Clone<T>(this IList<T> list)
  2331. {
  2332. return new List<!!0>(list);
  2333. }
  2334. // Token: 0x0600180A RID: 6154 RVA: 0x0009DE90 File Offset: 0x0009C090
  2335. public static object GetProgramArgument(string Name, object DefaultValue = "")
  2336. {
  2337. string[] array = Interaction.Command().Split(" ");
  2338. checked
  2339. {
  2340. int num = array.Length - 1;
  2341. for (int i = 0; i <= num; i++)
  2342. {
  2343. if (Operators.CompareString(array[i], "-" + Name, false) == 0)
  2344. {
  2345. object result;
  2346. if (array.Length != i + 1 && !array[i + 1].StartsWithF("-", false))
  2347. {
  2348. result = array[i + 1];
  2349. }
  2350. else
  2351. {
  2352. result = true;
  2353. }
  2354. return result;
  2355. }
  2356. }
  2357. return DefaultValue;
  2358. }
  2359. }
  2360. // Token: 0x0600180B RID: 6155 RVA: 0x0009DF04 File Offset: 0x0009C104
  2361. public static DateTime GetDate(int timeStamp)
  2362. {
  2363. DateTime dateTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc));
  2364. long ticks = checked(unchecked((long)timeStamp) * 10000000L);
  2365. return dateTime.Add(new TimeSpan(ticks));
  2366. }
  2367. // Token: 0x0600180C RID: 6156 RVA: 0x0009DF48 File Offset: 0x0009C148
  2368. public static DateTime GetLocalTime(DateTime UtcDate)
  2369. {
  2370. return DateTime.SpecifyKind(UtcDate, DateTimeKind.Utc).ToLocalTime();
  2371. }
  2372. // Token: 0x0600180D RID: 6157 RVA: 0x0009DF64 File Offset: 0x0009C164
  2373. public static void OpenWebsite(string Url)
  2374. {
  2375. try
  2376. {
  2377. if (!Url.StartsWithF("http", true) && !Url.StartsWithF("minecraft://", true))
  2378. {
  2379. throw new Exception(Url + " 不是一个有效的网址,它必须以 http 开头!");
  2380. }
  2381. ModBase.Log("[System] 正在打开网页:" + Url, ModBase.LogLevel.Normal, "出现错误");
  2382. Process.Start(Url);
  2383. }
  2384. catch (Exception ex)
  2385. {
  2386. ModBase.Log(ex, "无法打开网页(" + Url + ")", ModBase.LogLevel.Debug, "出现错误");
  2387. ModBase.ClipboardSet(Url, false);
  2388. ModMain.MyMsgBox("可能由于浏览器未正确配置,PCL 无法为你打开网页。\r\n网址已经复制到剪贴板,若有需要可以手动粘贴访问。\r\n" + string.Format("网址:{0}", Url), "无法打开网页", "确定", "", "", false, true, false, null, null, null);
  2389. }
  2390. }
  2391. // Token: 0x0600180E RID: 6158 RVA: 0x0009E034 File Offset: 0x0009C234
  2392. public static void OpenExplorer(string Argument)
  2393. {
  2394. try
  2395. {
  2396. ModBase.ShellOnly("explorer.exe", Argument);
  2397. }
  2398. catch (Exception ex)
  2399. {
  2400. ModBase.Log(ex, "打开资源管理器失败,请尝试关闭安全软件(如 360 安全卫士)", ModBase.LogLevel.Msgbox, "出现错误");
  2401. }
  2402. }
  2403. // Token: 0x0600180F RID: 6159 RVA: 0x0009E080 File Offset: 0x0009C280
  2404. public static void ClipboardSet(string Text, bool ShowSuccessHint = true)
  2405. {
  2406. ModBase._Closure$__146-0 CS$<>8__locals1 = new ModBase._Closure$__146-0(CS$<>8__locals1);
  2407. CS$<>8__locals1.$VB$Local_Text = Text;
  2408. CS$<>8__locals1.$VB$Local_ShowSuccessHint = ShowSuccessHint;
  2409. ModBase.RunInThread(checked(delegate
  2410. {
  2411. int num = 0;
  2412. for (;;)
  2413. {
  2414. try
  2415. {
  2416. ModBase.RunInUi((CS$<>8__locals1.$I1 == null) ? (CS$<>8__locals1.$I1 = delegate()
  2417. {
  2418. MyWpfExtension.ManageParser().Clipboard.Clear();
  2419. MyWpfExtension.ManageParser().Clipboard.SetText(CS$<>8__locals1.$VB$Local_Text);
  2420. }) : CS$<>8__locals1.$I1, false);
  2421. break;
  2422. }
  2423. catch (Exception ex)
  2424. {
  2425. num++;
  2426. if (num > 5)
  2427. {
  2428. ModBase.Log(ex, "可能由于剪贴板被其他程序占用,文本复制失败", ModBase.LogLevel.Hint, "出现错误");
  2429. break;
  2430. }
  2431. Thread.Sleep(20);
  2432. }
  2433. }
  2434. if (CS$<>8__locals1.$VB$Local_ShowSuccessHint)
  2435. {
  2436. ModMain.Hint("已成功复制!", ModMain.HintType.Finish, true);
  2437. }
  2438. }));
  2439. }
  2440. // Token: 0x06001810 RID: 6160 RVA: 0x0000D687 File Offset: 0x0000B887
  2441. public static byte[] GetResources(string ResourceName)
  2442. {
  2443. ModBase.Log("[System] 获取资源:" + ResourceName, ModBase.LogLevel.Normal, "出现错误");
  2444. return (byte[])Resources.CloneParser.GetObject(ResourceName);
  2445. }
  2446. // Token: 0x06001811 RID: 6161 RVA: 0x0009E0B4 File Offset: 0x0009C2B4
  2447. public static void DeltaLeft(FrameworkElement control, double newValue)
  2448. {
  2449. ModBase.DebugAssert(!double.IsNaN(newValue));
  2450. ModBase.DebugAssert(!double.IsInfinity(newValue));
  2451. if (control is Window)
  2452. {
  2453. Window window;
  2454. (window = (Window)control).Left = window.Left + newValue;
  2455. return;
  2456. }
  2457. switch (control.HorizontalAlignment)
  2458. {
  2459. case System.Windows.HorizontalAlignment.Left:
  2460. case System.Windows.HorizontalAlignment.Stretch:
  2461. control.Margin = new Thickness(control.Margin.Left + newValue, control.Margin.Top, control.Margin.Right, control.Margin.Bottom);
  2462. return;
  2463. default:
  2464. ModBase.DebugAssert(false);
  2465. return;
  2466. case System.Windows.HorizontalAlignment.Right:
  2467. control.Margin = new Thickness(control.Margin.Left, control.Margin.Top, control.Margin.Right - newValue, control.Margin.Bottom);
  2468. return;
  2469. }
  2470. }
  2471. // Token: 0x06001812 RID: 6162 RVA: 0x0009E1AC File Offset: 0x0009C3AC
  2472. public static void SetLeft(FrameworkElement control, double newValue)
  2473. {
  2474. ModBase.DebugAssert(control.HorizontalAlignment == System.Windows.HorizontalAlignment.Left);
  2475. control.Margin = new Thickness(newValue, control.Margin.Top, control.Margin.Right, control.Margin.Bottom);
  2476. }
  2477. // Token: 0x06001813 RID: 6163 RVA: 0x0009E200 File Offset: 0x0009C400
  2478. public static void DeltaTop(FrameworkElement control, double newValue)
  2479. {
  2480. ModBase.DebugAssert(!double.IsNaN(newValue));
  2481. ModBase.DebugAssert(!double.IsInfinity(newValue));
  2482. if (control is Window)
  2483. {
  2484. Window window;
  2485. (window = (Window)control).Top = window.Top + newValue;
  2486. return;
  2487. }
  2488. VerticalAlignment verticalAlignment = control.VerticalAlignment;
  2489. if (verticalAlignment == VerticalAlignment.Top)
  2490. {
  2491. control.Margin = new Thickness(control.Margin.Left, control.Margin.Top + newValue, control.Margin.Right, control.Margin.Bottom);
  2492. return;
  2493. }
  2494. if (verticalAlignment != VerticalAlignment.Bottom)
  2495. {
  2496. ModBase.DebugAssert(false);
  2497. return;
  2498. }
  2499. control.Margin = new Thickness(control.Margin.Left, control.Margin.Top, control.Margin.Right, control.Margin.Bottom - newValue);
  2500. }
  2501. // Token: 0x06001814 RID: 6164 RVA: 0x0009E2E8 File Offset: 0x0009C4E8
  2502. public static void SetTop(FrameworkElement control, double newValue)
  2503. {
  2504. ModBase.DebugAssert(control.VerticalAlignment == VerticalAlignment.Top);
  2505. control.Margin = new Thickness(control.Margin.Left, newValue, control.Margin.Right, control.Margin.Bottom);
  2506. }
  2507. // Token: 0x06001815 RID: 6165 RVA: 0x0000D6AF File Offset: 0x0000B8AF
  2508. public static double GetPixelSize(double WPFSize)
  2509. {
  2510. return WPFSize / 96.0 * (double)ModBase._ConfigurationRepository;
  2511. }
  2512. // Token: 0x06001816 RID: 6166 RVA: 0x0000D6C3 File Offset: 0x0000B8C3
  2513. public static double smethod_4(double PixelSize)
  2514. {
  2515. return PixelSize * 96.0 / (double)ModBase._ConfigurationRepository;
  2516. }
  2517. // Token: 0x06001817 RID: 6167 RVA: 0x0009E33C File Offset: 0x0009C53C
  2518. public static ImageBrush ControlBrush(FrameworkElement UI)
  2519. {
  2520. double actualWidth = UI.ActualWidth;
  2521. double actualHeight = UI.ActualHeight;
  2522. ImageBrush result;
  2523. if (actualWidth >= 1.0 && actualHeight >= 1.0)
  2524. {
  2525. RenderTargetBitmap renderTargetBitmap = checked(new RenderTargetBitmap((int)Math.Round(ModBase.GetPixelSize(actualWidth)), (int)Math.Round(ModBase.GetPixelSize(actualHeight)), (double)ModBase._ConfigurationRepository, (double)ModBase._ConfigurationRepository, PixelFormats.Pbgra32));
  2526. renderTargetBitmap.Render(UI);
  2527. result = new ImageBrush(renderTargetBitmap);
  2528. }
  2529. else
  2530. {
  2531. result = new ImageBrush();
  2532. }
  2533. return result;
  2534. }
  2535. // Token: 0x06001818 RID: 6168 RVA: 0x0009E3B8 File Offset: 0x0009C5B8
  2536. public static ImageBrush ControlBrush(FrameworkElement UI, double Width, double Height, double Left = 0.0, double Top = 0.0)
  2537. {
  2538. UI.Measure(new System.Windows.Size(Width, Height));
  2539. UI.Arrange(new Rect(0.0, 0.0, Width, Height));
  2540. RenderTargetBitmap renderTargetBitmap = checked(new RenderTargetBitmap((int)Math.Round(ModBase.GetPixelSize(Width)), (int)Math.Round(ModBase.GetPixelSize(Height)), (double)ModBase._ConfigurationRepository, (double)ModBase._ConfigurationRepository, PixelFormats.Default));
  2541. renderTargetBitmap.Render(UI);
  2542. if (Left != 0.0 || Top != 0.0)
  2543. {
  2544. UI.Arrange(new Rect(Left, Top, Width, Height));
  2545. }
  2546. return new ImageBrush(renderTargetBitmap);
  2547. }
  2548. // Token: 0x06001819 RID: 6169 RVA: 0x0000D6D7 File Offset: 0x0000B8D7
  2549. public static void ControlFreeze(System.Windows.Controls.Panel UI)
  2550. {
  2551. UI.Background = ModBase.ControlBrush(UI);
  2552. UI.Children.Clear();
  2553. }
  2554. // Token: 0x0600181A RID: 6170 RVA: 0x0000D6F0 File Offset: 0x0000B8F0
  2555. public static void ControlFreeze(Border UI)
  2556. {
  2557. UI.Background = ModBase.ControlBrush(UI);
  2558. UI.Child = null;
  2559. }
  2560. // Token: 0x0600181B RID: 6171 RVA: 0x0000D705 File Offset: 0x0000B905
  2561. public static object GetObjectFromXML(XElement Str)
  2562. {
  2563. return ModBase.GetObjectFromXML(Str.ToString());
  2564. }
  2565. // Token: 0x0600181C RID: 6172 RVA: 0x0009E458 File Offset: 0x0009C658
  2566. public static object GetObjectFromXML(string Str)
  2567. {
  2568. object result;
  2569. using (MemoryStream memoryStream = new MemoryStream())
  2570. {
  2571. using (StreamWriter streamWriter = new StreamWriter(memoryStream))
  2572. {
  2573. streamWriter.Write(Str);
  2574. streamWriter.Flush();
  2575. memoryStream.Position = 0L;
  2576. result = XamlReader.Load(memoryStream);
  2577. }
  2578. }
  2579. return result;
  2580. }
  2581. // Token: 0x0600181D RID: 6173 RVA: 0x0000D712 File Offset: 0x0000B912
  2582. public static bool RunInUi()
  2583. {
  2584. return Thread.CurrentThread.ManagedThreadId == ModBase._GetterRepository;
  2585. }
  2586. // Token: 0x0600181E RID: 6174 RVA: 0x0009E4C8 File Offset: 0x0009C6C8
  2587. public static bool IsVisibleInForm(this FrameworkElement element)
  2588. {
  2589. bool result;
  2590. if (!element.IsVisible)
  2591. {
  2592. result = false;
  2593. }
  2594. else
  2595. {
  2596. Rect rect = element.TransformToAncestor(ModMain._ProcessIterator).TransformBounds(new Rect(0.0, 0.0, element.ActualWidth, element.ActualHeight));
  2597. Rect rect2 = new Rect(0.0, 0.0, ModMain._ProcessIterator.ActualWidth, ModMain._ProcessIterator.ActualHeight);
  2598. result = (rect2.Contains(rect.TopLeft) || rect2.Contains(rect.BottomRight));
  2599. }
  2600. return result;
  2601. }
  2602. // Token: 0x0600181F RID: 6175 RVA: 0x0009E568 File Offset: 0x0009C768
  2603. public static bool IsTextTrimmed(this TextBlock Control)
  2604. {
  2605. Control.Measure(new System.Windows.Size(double.MaxValue, double.MaxValue));
  2606. return Control.DesiredSize.Width > Control.ActualWidth;
  2607. }
  2608. // Token: 0x06001820 RID: 6176 RVA: 0x0000D725 File Offset: 0x0000B925
  2609. public static void LogStart()
  2610. {
  2611. ModBase.RunInNewThread((ModBase._Closure$__.$I169-0 == null) ? (ModBase._Closure$__.$I169-0 = checked(delegate()
  2612. {
  2613. bool flag = true;
  2614. try
  2615. {
  2616. int num = 4;
  2617. do
  2618. {
  2619. if (File.Exists(ModBase.Path + "PCL\\Log" + Conversions.ToString(num) + ".txt"))
  2620. {
  2621. if (File.Exists(ModBase.Path + "PCL\\Log" + Conversions.ToString(num + 1) + ".txt"))
  2622. {
  2623. File.Delete(ModBase.Path + "PCL\\Log" + Conversions.ToString(num + 1) + ".txt");
  2624. }
  2625. ModBase.CopyFile(ModBase.Path + "PCL\\Log" + Conversions.ToString(num) + ".txt", ModBase.Path + "PCL\\Log" + Conversions.ToString(num + 1) + ".txt");
  2626. }
  2627. num += -1;
  2628. }
  2629. while (num >= 1);
  2630. File.Create(ModBase.Path + "PCL\\Log1.txt").Dispose();
  2631. }
  2632. catch (IOException ex)
  2633. {
  2634. flag = false;
  2635. ModMain.Hint("可能同时开启了多个 PCL,程序可能会出现未知问题!", ModMain.HintType.Critical, true);
  2636. ModBase.Log(ex, "日志初始化失败(疑似文件占用问题)", ModBase.LogLevel.Debug, "出现错误");
  2637. }
  2638. catch (Exception ex2)
  2639. {
  2640. flag = false;
  2641. ModBase.Log(ex2, "日志初始化失败", ModBase.LogLevel.Hint, "出现错误");
  2642. }
  2643. try
  2644. {
  2645. ModBase.m_WriterRepository = new StreamWriter(ModBase.Path + "PCL\\Log1.txt", true)
  2646. {
  2647. AutoFlush = true
  2648. };
  2649. goto IL_196;
  2650. }
  2651. catch (Exception ex3)
  2652. {
  2653. ModBase.m_WriterRepository = null;
  2654. ModBase.Log(ex3, "日志写入失败", ModBase.LogLevel.Hint, "出现错误");
  2655. goto IL_196;
  2656. }
  2657. IL_17C:
  2658. ModBase.expressionRepository = new StringBuilder();
  2659. IL_186:
  2660. Thread.Sleep(50);
  2661. IL_196:
  2662. if (flag)
  2663. {
  2664. ModBase.LogFlush();
  2665. goto IL_186;
  2666. }
  2667. goto IL_17C;
  2668. })) : ModBase._Closure$__.$I169-0, "Log Writer", ThreadPriority.Lowest);
  2669. }
  2670. // Token: 0x06001821 RID: 6177 RVA: 0x0009E5A8 File Offset: 0x0009C7A8
  2671. public static void LogFlush()
  2672. {
  2673. int num;
  2674. int num4;
  2675. object obj;
  2676. try
  2677. {
  2678. IL_00:
  2679. ProjectData.ClearProjectError();
  2680. num = 1;
  2681. IL_07:
  2682. int num2 = 2;
  2683. if (ModBase.m_WriterRepository == null)
  2684. {
  2685. goto IL_72;
  2686. }
  2687. IL_10:
  2688. num2 = 4;
  2689. string text = null;
  2690. IL_14:
  2691. num2 = 5;
  2692. object registryRepository = ModBase._RegistryRepository;
  2693. ObjectFlowControl.CheckForSyncLockOnValueType(registryRepository);
  2694. lock (registryRepository)
  2695. {
  2696. if (ModBase.expressionRepository.Length > 0)
  2697. {
  2698. StringBuilder stringBuilder = ModBase.expressionRepository;
  2699. ModBase.expressionRepository = new StringBuilder();
  2700. text = stringBuilder.ToString();
  2701. }
  2702. }
  2703. IL_60:
  2704. num2 = 6;
  2705. if (text == null)
  2706. {
  2707. goto IL_72;
  2708. }
  2709. IL_65:
  2710. num2 = 7;
  2711. ModBase.m_WriterRepository.Write(text);
  2712. IL_72:
  2713. goto IL_E1;
  2714. IL_74:
  2715. int num3 = num4 + 1;
  2716. num4 = 0;
  2717. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  2718. IL_A2:
  2719. goto IL_D6;
  2720. IL_A4:
  2721. num4 = num2;
  2722. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
  2723. IL_B4:;
  2724. }
  2725. catch when (endfilter(obj is Exception & num != 0 & num4 == 0))
  2726. {
  2727. Exception ex = (Exception)obj2;
  2728. goto IL_A4;
  2729. }
  2730. IL_D6:
  2731. throw ProjectData.CreateProjectError(-2146828237);
  2732. IL_E1:
  2733. if (num4 != 0)
  2734. {
  2735. ProjectData.ClearProjectError();
  2736. }
  2737. }
  2738. // Token: 0x06001822 RID: 6178 RVA: 0x0009E6BC File Offset: 0x0009C8BC
  2739. public static void Log(string Text, ModBase.LogLevel Level = ModBase.LogLevel.Normal, string Title = "出现错误")
  2740. {
  2741. int num;
  2742. int num4;
  2743. object obj;
  2744. try
  2745. {
  2746. IL_00:
  2747. ProjectData.ClearProjectError();
  2748. num = 1;
  2749. IL_07:
  2750. int num2 = 2;
  2751. string value = string.Concat(new string[]
  2752. {
  2753. "[",
  2754. ModBase.GetTimeNow(),
  2755. "] ",
  2756. Text,
  2757. "\r\n"
  2758. });
  2759. IL_39:
  2760. num2 = 3;
  2761. if (!ModBase._TokenRepository)
  2762. {
  2763. goto IL_78;
  2764. }
  2765. IL_42:
  2766. num2 = 4;
  2767. object ruleRepository = ModBase._RuleRepository;
  2768. ObjectFlowControl.CheckForSyncLockOnValueType(ruleRepository);
  2769. lock (ruleRepository)
  2770. {
  2771. ModBase.expressionRepository.Append(value);
  2772. goto IL_86;
  2773. }
  2774. IL_78:
  2775. num2 = 6;
  2776. ModBase.expressionRepository.Append(value);
  2777. IL_86:
  2778. num2 = 7;
  2779. if (ModBase._ObserverRepository || Level == ModBase.LogLevel.Normal)
  2780. {
  2781. goto IL_243;
  2782. }
  2783. IL_98:
  2784. num2 = 9;
  2785. Text = ModBase.RegexReplace(Text, "", "\\[[^\\]]+?\\] ", 0);
  2786. IL_AE:
  2787. num2 = 10;
  2788. switch (Level)
  2789. {
  2790. case ModBase.LogLevel.Debug:
  2791. IL_DB:
  2792. num2 = 13;
  2793. if (!ModBase._TokenRepository)
  2794. {
  2795. break;
  2796. }
  2797. IL_E8:
  2798. num2 = 14;
  2799. ModMain.Hint("[调试模式] " + Text, ModMain.HintType.Info, false);
  2800. break;
  2801. case ModBase.LogLevel.Hint:
  2802. IL_102:
  2803. num2 = 16;
  2804. ModMain.Hint(Text, ModMain.HintType.Critical, false);
  2805. break;
  2806. case ModBase.LogLevel.Msgbox:
  2807. IL_112:
  2808. num2 = 18;
  2809. ModMain.MyMsgBox(Text, Title, "确定", "", "", true, true, false, null, null, null);
  2810. break;
  2811. case ModBase.LogLevel.Feedback:
  2812. IL_137:
  2813. num2 = 20;
  2814. if (!ModBase.CanFeedback(false))
  2815. {
  2816. goto IL_180;
  2817. }
  2818. IL_142:
  2819. num2 = 21;
  2820. if (ModMain.MyMsgBox(Text + "\r\n\r\n是否反馈此问题?如果不反馈,这个问题可能永远无法得到解决!", Title, "反馈", "取消", "", true, true, false, null, null, null) != 1)
  2821. {
  2822. break;
  2823. }
  2824. IL_171:
  2825. num2 = 22;
  2826. ModBase.Feedback(false, true);
  2827. break;
  2828. IL_180:
  2829. num2 = 24;
  2830. ModMain.MyMsgBox(Text + "\r\n\r\n将 PCL 更新至最新版或许可以解决这个问题……", Title, "确定", "", "", true, true, false, null, null, null);
  2831. break;
  2832. case ModBase.LogLevel.Assert:
  2833. {
  2834. IL_1AF:
  2835. num2 = 26;
  2836. long timeTick = ModBase.GetTimeTick();
  2837. IL_1B9:
  2838. num2 = 27;
  2839. if (!ModBase.CanFeedback(false))
  2840. {
  2841. goto IL_1E9;
  2842. }
  2843. IL_1C4:
  2844. num2 = 28;
  2845. if (Interaction.MsgBox(Text + "\r\n\r\n是否反馈此问题?如果不反馈,这个问题可能永远无法得到解决!", MsgBoxStyle.YesNo | MsgBoxStyle.Critical, Title) != MsgBoxResult.Yes)
  2846. {
  2847. goto IL_200;
  2848. }
  2849. IL_1DD:
  2850. num2 = 29;
  2851. ModBase.Feedback(false, true);
  2852. goto IL_200;
  2853. IL_1E9:
  2854. num2 = 31;
  2855. Interaction.MsgBox(Text + "\r\n\r\n将 PCL 更新至最新版或许可以解决这个问题……", MsgBoxStyle.Critical, Title);
  2856. IL_200:
  2857. num2 = 32;
  2858. if (checked(ModBase.GetTimeTick() - timeTick) >= 1500L)
  2859. {
  2860. goto IL_23A;
  2861. }
  2862. IL_216:
  2863. num2 = 33;
  2864. ModBase.Log("[System] PCL 已崩溃:\r\n" + Text, ModBase.LogLevel.Normal, "出现错误");
  2865. IL_22F:
  2866. num2 = 34;
  2867. FormMain.EndProgramForce(ModBase.Result.Exception);
  2868. break;
  2869. IL_23A:
  2870. num2 = 36;
  2871. FormMain.EndProgramForce(ModBase.Result.Fail);
  2872. break;
  2873. }
  2874. }
  2875. IL_243:
  2876. goto IL_32D;
  2877. IL_248:
  2878. int num3 = num4 + 1;
  2879. num4 = 0;
  2880. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  2881. IL_2EE:
  2882. goto IL_322;
  2883. IL_2F0:
  2884. num4 = num2;
  2885. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
  2886. IL_300:;
  2887. }
  2888. catch when (endfilter(obj is Exception & num != 0 & num4 == 0))
  2889. {
  2890. Exception ex = (Exception)obj2;
  2891. goto IL_2F0;
  2892. }
  2893. IL_322:
  2894. throw ProjectData.CreateProjectError(-2146828237);
  2895. IL_32D:
  2896. if (num4 != 0)
  2897. {
  2898. ProjectData.ClearProjectError();
  2899. }
  2900. }
  2901. // Token: 0x06001823 RID: 6179 RVA: 0x0009EA34 File Offset: 0x0009CC34
  2902. public static void Log(Exception Ex, string Desc, ModBase.LogLevel Level = ModBase.LogLevel.Debug, string Title = "出现错误")
  2903. {
  2904. int num;
  2905. int num4;
  2906. object obj;
  2907. try
  2908. {
  2909. IL_00:
  2910. ProjectData.ClearProjectError();
  2911. num = 1;
  2912. IL_07:
  2913. int num2 = 2;
  2914. if (Ex is ThreadInterruptedException)
  2915. {
  2916. goto IL_290;
  2917. }
  2918. IL_14:
  2919. num2 = 4;
  2920. string text = Desc + ":" + ModBase.GetExceptionDetail(Ex, false);
  2921. IL_29:
  2922. num2 = 5;
  2923. string value = string.Concat(new string[]
  2924. {
  2925. "[",
  2926. ModBase.GetTimeNow(),
  2927. "] ",
  2928. Desc,
  2929. ":",
  2930. ModBase.GetExceptionDetail(Ex, true),
  2931. "\r\n"
  2932. });
  2933. IL_6E:
  2934. num2 = 6;
  2935. if (!ModBase._TokenRepository)
  2936. {
  2937. goto IL_AE;
  2938. }
  2939. IL_77:
  2940. num2 = 7;
  2941. object ruleRepository = ModBase._RuleRepository;
  2942. ObjectFlowControl.CheckForSyncLockOnValueType(ruleRepository);
  2943. lock (ruleRepository)
  2944. {
  2945. ModBase.expressionRepository.Append(value);
  2946. goto IL_BE;
  2947. }
  2948. IL_AE:
  2949. num2 = 9;
  2950. ModBase.expressionRepository.Append(value);
  2951. IL_BE:
  2952. num2 = 10;
  2953. if (ModBase._ObserverRepository)
  2954. {
  2955. goto IL_290;
  2956. }
  2957. IL_CB:
  2958. num2 = 12;
  2959. switch (Level)
  2960. {
  2961. case ModBase.LogLevel.Debug:
  2962. {
  2963. IL_FA:
  2964. num2 = 16;
  2965. string str = Desc + ":" + ModBase.GetExceptionSummary(Ex);
  2966. IL_110:
  2967. num2 = 17;
  2968. if (!ModBase._TokenRepository)
  2969. {
  2970. break;
  2971. }
  2972. IL_11D:
  2973. num2 = 18;
  2974. ModMain.Hint("[调试模式] " + str, ModMain.HintType.Info, false);
  2975. break;
  2976. }
  2977. case ModBase.LogLevel.Hint:
  2978. {
  2979. IL_138:
  2980. num2 = 20;
  2981. string text2 = Desc + ":" + ModBase.GetExceptionSummary(Ex);
  2982. IL_14E:
  2983. num2 = 21;
  2984. ModMain.Hint(text2, ModMain.HintType.Critical, false);
  2985. break;
  2986. }
  2987. case ModBase.LogLevel.Msgbox:
  2988. IL_15F:
  2989. num2 = 23;
  2990. ModMain.MyMsgBox(text, Title, "确定", "", "", true, true, false, null, null, null);
  2991. break;
  2992. case ModBase.LogLevel.Feedback:
  2993. IL_184:
  2994. num2 = 25;
  2995. if (!ModBase.CanFeedback(false))
  2996. {
  2997. goto IL_1CD;
  2998. }
  2999. IL_18F:
  3000. num2 = 26;
  3001. if (ModMain.MyMsgBox(text + "\r\n\r\n是否反馈此问题?如果不反馈,这个问题可能永远无法得到解决!", Title, "反馈", "取消", "", true, true, false, null, null, null) != 1)
  3002. {
  3003. break;
  3004. }
  3005. IL_1BE:
  3006. num2 = 27;
  3007. ModBase.Feedback(false, true);
  3008. break;
  3009. IL_1CD:
  3010. num2 = 29;
  3011. ModMain.MyMsgBox(text + "\r\n\r\n将 PCL 更新至最新版或许可以解决这个问题……", Title, "确定", "", "", true, true, false, null, null, null);
  3012. break;
  3013. case ModBase.LogLevel.Assert:
  3014. {
  3015. IL_1FC:
  3016. num2 = 31;
  3017. long timeTick = ModBase.GetTimeTick();
  3018. IL_206:
  3019. num2 = 32;
  3020. if (!ModBase.CanFeedback(false))
  3021. {
  3022. goto IL_236;
  3023. }
  3024. IL_211:
  3025. num2 = 33;
  3026. if (Interaction.MsgBox(text + "\r\n\r\n是否反馈此问题?如果不反馈,这个问题可能永远无法得到解决!", MsgBoxStyle.YesNo | MsgBoxStyle.Critical, Title) != MsgBoxResult.Yes)
  3027. {
  3028. goto IL_24D;
  3029. }
  3030. IL_22A:
  3031. num2 = 34;
  3032. ModBase.Feedback(false, true);
  3033. goto IL_24D;
  3034. IL_236:
  3035. num2 = 36;
  3036. Interaction.MsgBox(text + "\r\n\r\n将 PCL 更新至最新版或许可以解决这个问题……", MsgBoxStyle.Critical, Title);
  3037. IL_24D:
  3038. num2 = 37;
  3039. if (checked(ModBase.GetTimeTick() - timeTick) >= 1500L)
  3040. {
  3041. goto IL_287;
  3042. }
  3043. IL_263:
  3044. num2 = 38;
  3045. ModBase.Log("[System] PCL 已崩溃:\r\n" + text, ModBase.LogLevel.Normal, "出现错误");
  3046. IL_27C:
  3047. num2 = 39;
  3048. FormMain.EndProgramForce(ModBase.Result.Exception);
  3049. break;
  3050. IL_287:
  3051. num2 = 41;
  3052. FormMain.EndProgramForce(ModBase.Result.Fail);
  3053. break;
  3054. }
  3055. }
  3056. IL_290:
  3057. goto IL_38E;
  3058. IL_295:
  3059. int num3 = num4 + 1;
  3060. num4 = 0;
  3061. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  3062. IL_34F:
  3063. goto IL_383;
  3064. IL_351:
  3065. num4 = num2;
  3066. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
  3067. IL_361:;
  3068. }
  3069. catch when (endfilter(obj is Exception & num != 0 & num4 == 0))
  3070. {
  3071. Exception ex = (Exception)obj2;
  3072. goto IL_351;
  3073. }
  3074. IL_383:
  3075. throw ProjectData.CreateProjectError(-2146828237);
  3076. IL_38E:
  3077. if (num4 != 0)
  3078. {
  3079. ProjectData.ClearProjectError();
  3080. }
  3081. }
  3082. // Token: 0x06001824 RID: 6180 RVA: 0x0009EE0C File Offset: 0x0009D00C
  3083. public static void Feedback(bool ShowMsgbox = true, bool ForceOpenLog = false)
  3084. {
  3085. int num;
  3086. int num4;
  3087. object obj;
  3088. try
  3089. {
  3090. IL_00:
  3091. ProjectData.ClearProjectError();
  3092. num = 1;
  3093. IL_07:
  3094. int num2 = 2;
  3095. ModBase.FeedbackInfo();
  3096. IL_0E:
  3097. num2 = 3;
  3098. if (!ForceOpenLog && (!ShowMsgbox || ModMain.MyMsgBox("若你在汇报一个 Bug,请点击 打开文件夹 按钮,并上传 Log(1~5).txt 中包含错误信息的文件。\r\n游戏崩溃一般与启动器无关,请不要因为游戏崩溃而提交反馈。", "反馈提交提醒", "打开文件夹", "不需要", "", false, true, false, null, null, null) != 1))
  3099. {
  3100. goto IL_58;
  3101. }
  3102. IL_3D:
  3103. num2 = 4;
  3104. ModBase.OpenExplorer("\"" + ModBase.Path + "PCL\\\"");
  3105. IL_58:
  3106. num2 = 5;
  3107. ModBase.OpenWebsite("https://github.com/Hex-Dragon/PCL2/issues/");
  3108. IL_64:
  3109. goto IL_CB;
  3110. IL_66:
  3111. int num3 = num4 + 1;
  3112. num4 = 0;
  3113. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  3114. IL_8C:
  3115. goto IL_C0;
  3116. IL_8E:
  3117. num4 = num2;
  3118. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
  3119. IL_9E:;
  3120. }
  3121. catch when (endfilter(obj is Exception & num != 0 & num4 == 0))
  3122. {
  3123. Exception ex = (Exception)obj2;
  3124. goto IL_8E;
  3125. }
  3126. IL_C0:
  3127. throw ProjectData.CreateProjectError(-2146828237);
  3128. IL_CB:
  3129. if (num4 != 0)
  3130. {
  3131. ProjectData.ClearProjectError();
  3132. }
  3133. }
  3134. // Token: 0x06001825 RID: 6181 RVA: 0x0009EEFC File Offset: 0x0009D0FC
  3135. public static bool CanFeedback(bool ShowHint)
  3136. {
  3137. bool result;
  3138. if (false.Equals(PageSetupSystem.IsLauncherNewest()))
  3139. {
  3140. if (ShowHint && ModMain.MyMsgBox(string.Format("你的 PCL 不是最新版,因此无法提交反馈。{0}请在更新后,确认该问题在最新版中依然存在,然后再提交反馈。", "\r\n"), "无法提交反馈", "更新", "取消", "", false, true, false, null, null, null) == 1)
  3141. {
  3142. ModSecret.UpdateCheckByButton();
  3143. }
  3144. result = false;
  3145. }
  3146. else
  3147. {
  3148. result = true;
  3149. }
  3150. return result;
  3151. }
  3152. // Token: 0x06001826 RID: 6182 RVA: 0x0009EF60 File Offset: 0x0009D160
  3153. public static void FeedbackInfo()
  3154. {
  3155. int num;
  3156. int num4;
  3157. object obj;
  3158. try
  3159. {
  3160. IL_00:
  3161. ProjectData.ClearProjectError();
  3162. num = 1;
  3163. IL_07:
  3164. int num2 = 2;
  3165. ModBase.Log(string.Concat(new string[]
  3166. {
  3167. "[System] 诊断信息:\r\n操作系统:",
  3168. MyWpfExtension.ManageParser().Info.OSFullName,
  3169. "(32 位:",
  3170. Conversions.ToString(ModBase.m_StubRepository),
  3171. ")\r\n剩余内存:",
  3172. Conversions.ToString(Conversion.Int(MyWpfExtension.ManageParser().Info.AvailablePhysicalMemory / 1024.0 / 1024.0)),
  3173. " M / ",
  3174. Conversions.ToString(Conversion.Int(MyWpfExtension.ManageParser().Info.TotalPhysicalMemory / 1024.0 / 1024.0)),
  3175. " M\r\nDPI:",
  3176. Conversions.ToString(ModBase._ConfigurationRepository),
  3177. "(",
  3178. Conversions.ToString(Math.Round((double)ModBase._ConfigurationRepository / 96.0, 2) * 100.0),
  3179. "%)\r\nMC 文件夹:",
  3180. ModMinecraft.m_ProxyTests ?? "Nothing",
  3181. "\r\n文件位置:",
  3182. ModBase.Path
  3183. }), ModBase.LogLevel.Normal, "出现错误");
  3184. IL_138:
  3185. goto IL_193;
  3186. IL_13A:
  3187. int num3 = num4 + 1;
  3188. num4 = 0;
  3189. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  3190. IL_154:
  3191. goto IL_188;
  3192. IL_156:
  3193. num4 = num2;
  3194. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num);
  3195. IL_166:;
  3196. }
  3197. catch when (endfilter(obj is Exception & num != 0 & num4 == 0))
  3198. {
  3199. Exception ex = (Exception)obj2;
  3200. goto IL_156;
  3201. }
  3202. IL_188:
  3203. throw ProjectData.CreateProjectError(-2146828237);
  3204. IL_193:
  3205. if (num4 != 0)
  3206. {
  3207. ProjectData.ClearProjectError();
  3208. }
  3209. }
  3210. // Token: 0x06001827 RID: 6183 RVA: 0x0000D757 File Offset: 0x0000B957
  3211. public static void DebugAssert(bool Exp)
  3212. {
  3213. if (!Exp)
  3214. {
  3215. throw new Exception("断言命中");
  3216. }
  3217. }
  3218. // Token: 0x06001828 RID: 6184 RVA: 0x0009F124 File Offset: 0x0009D324
  3219. public static string GetStackTrace()
  3220. {
  3221. return Enumerable.ToList<string>(Enumerable.Select<MethodBase, string>(Enumerable.Select<StackFrame, MethodBase>(Enumerable.Skip<StackFrame>(new StackTrace().GetFrames(), 1), (ModBase._Closure$__.$I179-0 == null) ? (ModBase._Closure$__.$I179-0 = ((StackFrame f) => f.GetMethod())) : ModBase._Closure$__.$I179-0), (ModBase._Closure$__.$I179-1 == null) ? (ModBase._Closure$__.$I179-1 = ((MethodBase f) => string.Concat(new string[]
  3222. {
  3223. f.Name,
  3224. "(",
  3225. Enumerable.ToList<string>(Enumerable.Select<ParameterInfo, string>(f.GetParameters(), (ModBase._Closure$__.$I179-2 == null) ? (ModBase._Closure$__.$I179-2 = ((ParameterInfo p) => p.ToString())) : ModBase._Closure$__.$I179-2)).Join(", "),
  3226. ") - ",
  3227. f.Module.ToString()
  3228. }))) : ModBase._Closure$__.$I179-1)).Join("\r\n").Replace("\r\n\r\n", "\r\n");
  3229. }
  3230. // Token: 0x06001829 RID: 6185 RVA: 0x0000D767 File Offset: 0x0000B967
  3231. public static T RandomOne<T>(ICollection<T> objects)
  3232. {
  3233. return Enumerable.ElementAtOrDefault<T>(objects, ModBase.RandomInteger(0, checked(objects.Count - 1)));
  3234. }
  3235. // Token: 0x0600182A RID: 6186 RVA: 0x0000D77D File Offset: 0x0000B97D
  3236. public static int RandomInteger(int min, int max)
  3237. {
  3238. return checked((int)Math.Round(unchecked(Math.Floor((double)(checked(max - min + 1)) * ModBase._ProccesorRepository.NextDouble()) + (double)min)));
  3239. }
  3240. // Token: 0x0600182B RID: 6187 RVA: 0x0009F1B4 File Offset: 0x0009D3B4
  3241. public static IList<T> Shuffle<T>(IList<T> array)
  3242. {
  3243. IList<T> list = new List<!!0>();
  3244. while (Enumerable.Any<T>(array))
  3245. {
  3246. int index = ModBase.RandomInteger(0, checked(array.Count - 1));
  3247. list.Add(array[index]);
  3248. array.RemoveAt(index);
  3249. }
  3250. return list;
  3251. }
  3252. // Token: 0x04000C51 RID: 3153
  3253. public static IntPtr m_IndexerRepository;
  3254. // Token: 0x04000C52 RID: 3154
  3255. public static string Path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
  3256. // Token: 0x04000C53 RID: 3155
  3257. public static string interpreterRepository = ModBase.Path + AppDomain.CurrentDomain.SetupInformation.ApplicationName;
  3258. // Token: 0x04000C54 RID: 3156
  3259. public static string m_SerializerRepository = "pack://application:,,,/Plain Craft Launcher 2;component/Images/";
  3260. // Token: 0x04000C55 RID: 3157
  3261. public static string watcherRepository = "zh_CN";
  3262. // Token: 0x04000C56 RID: 3158
  3263. public static ModSetup m_IdentifierRepository = new ModSetup();
  3264. // Token: 0x04000C57 RID: 3159
  3265. public static long _SystemRepository = ModBase.GetTimeTick();
  3266. // Token: 0x04000C58 RID: 3160
  3267. public static DateTime paramRepository = DateTime.Now;
  3268. // Token: 0x04000C59 RID: 3161
  3269. public static string _TagRepository = ModSecret.SecretGetUniqueAddress();
  3270. // Token: 0x04000C5A RID: 3162
  3271. public static bool _ObserverRepository = false;
  3272. // Token: 0x04000C5B RID: 3163
  3273. public static bool m_StubRepository = !Environment.Is64BitOperatingSystem;
  3274. // Token: 0x04000C5C RID: 3164
  3275. public static bool rulesRepository = Encoding.Default.CodePage == 936;
  3276. // Token: 0x04000C5D RID: 3165
  3277. public static string _RefRepository = Conversions.ToString(Enumerable.First<char>(Enumerable.First<string>(Enumerable.Where<string>(Environment.GetLogicalDrives(), (string p) => Directory.Exists(p))).ToUpper())) + ":\\";
  3278. // Token: 0x04000C5E RID: 3166
  3279. public static string m_DecoratorRepository = (Operators.ConditionalCompareObjectEqual(ModBase.m_IdentifierRepository.Get("SystemSystemCache", null), "", false) ? (System.IO.Path.GetTempPath() + "PCL\\") : ModBase.m_IdentifierRepository.Get("SystemSystemCache", null)).ToString().Replace("/", "\\").TrimEnd(new char[]
  3280. {
  3281. '\\'
  3282. }) + "\\";
  3283. // Token: 0x04000C5F RID: 3167
  3284. public static string m_InstanceRepository = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\PCL\\";
  3285. // Token: 0x04000C60 RID: 3168
  3286. private static readonly Dictionary<string, Dictionary<string, string>> stateRepository = new Dictionary<string, Dictionary<string, string>>();
  3287. // Token: 0x04000C61 RID: 3169
  3288. public static char callbackRepository = Convert.ToChar(8220);
  3289. // Token: 0x04000C62 RID: 3170
  3290. public static char m_TemplateRepository = Convert.ToChar(8221);
  3291. // Token: 0x04000C63 RID: 3171
  3292. public static string _MethodRepository = ModBase.GetPureASCIIDir();
  3293. // Token: 0x04000C64 RID: 3172
  3294. private static int taskRepository = 1;
  3295. // Token: 0x04000C65 RID: 3173
  3296. private static object m_ConsumerRepository;
  3297. // Token: 0x04000C66 RID: 3174
  3298. public static readonly int _ConfigurationRepository = checked((int)Math.Round((double)Graphics.FromHwnd(IntPtr.Zero).DpiX));
  3299. // Token: 0x04000C67 RID: 3175
  3300. private static readonly int _GetterRepository = Thread.CurrentThread.ManagedThreadId;
  3301. // Token: 0x04000C68 RID: 3176
  3302. public static bool _TokenRepository = false;
  3303. // Token: 0x04000C69 RID: 3177
  3304. private static StringBuilder expressionRepository = new StringBuilder();
  3305. // Token: 0x04000C6A RID: 3178
  3306. private static StreamWriter m_WriterRepository;
  3307. // Token: 0x04000C6B RID: 3179
  3308. private static readonly object _RegistryRepository = RuntimeHelpers.GetObjectValue(new object());
  3309. // Token: 0x04000C6C RID: 3180
  3310. private static readonly object _RuleRepository = RuntimeHelpers.GetObjectValue(new object());
  3311. // Token: 0x04000C6D RID: 3181
  3312. private static readonly Random _ProccesorRepository = new Random();
  3313. // Token: 0x020001FE RID: 510
  3314. public class Logo
  3315. {
  3316. }
  3317. // Token: 0x020001FF RID: 511
  3318. public class MyColor
  3319. {
  3320. // Token: 0x0600182E RID: 6190 RVA: 0x0000D79E File Offset: 0x0000B99E
  3321. public static implicit operator ModBase.MyColor(string str)
  3322. {
  3323. return new ModBase.MyColor(str);
  3324. }
  3325. // Token: 0x0600182F RID: 6191 RVA: 0x0000D7A6 File Offset: 0x0000B9A6
  3326. public static implicit operator ModBase.MyColor(System.Windows.Media.Color col)
  3327. {
  3328. return new ModBase.MyColor(col);
  3329. }
  3330. // Token: 0x06001830 RID: 6192 RVA: 0x0000D7AE File Offset: 0x0000B9AE
  3331. public static implicit operator System.Windows.Media.Color(ModBase.MyColor conv)
  3332. {
  3333. return System.Windows.Media.Color.FromArgb(ModBase.MathByte(conv.mapperError), ModBase.MathByte(conv.m_ThreadError), ModBase.MathByte(conv._PropertyError), ModBase.MathByte(conv.composerError));
  3334. }
  3335. // Token: 0x06001831 RID: 6193 RVA: 0x0000D7E1 File Offset: 0x0000B9E1
  3336. public static implicit operator System.Drawing.Color(ModBase.MyColor conv)
  3337. {
  3338. return System.Drawing.Color.FromArgb((int)ModBase.MathByte(conv.mapperError), (int)ModBase.MathByte(conv.m_ThreadError), (int)ModBase.MathByte(conv._PropertyError), (int)ModBase.MathByte(conv.composerError));
  3339. }
  3340. // Token: 0x06001832 RID: 6194 RVA: 0x0000D814 File Offset: 0x0000BA14
  3341. public static implicit operator ModBase.MyColor(SolidColorBrush bru)
  3342. {
  3343. return new ModBase.MyColor(bru.Color);
  3344. }
  3345. // Token: 0x06001833 RID: 6195 RVA: 0x0000D821 File Offset: 0x0000BA21
  3346. public static implicit operator SolidColorBrush(ModBase.MyColor conv)
  3347. {
  3348. return new SolidColorBrush(System.Windows.Media.Color.FromArgb(ModBase.MathByte(conv.mapperError), ModBase.MathByte(conv.m_ThreadError), ModBase.MathByte(conv._PropertyError), ModBase.MathByte(conv.composerError)));
  3349. }
  3350. // Token: 0x06001834 RID: 6196 RVA: 0x0000D859 File Offset: 0x0000BA59
  3351. public static implicit operator ModBase.MyColor(System.Windows.Media.Brush bru)
  3352. {
  3353. return new ModBase.MyColor(bru);
  3354. }
  3355. // Token: 0x06001835 RID: 6197 RVA: 0x0000D821 File Offset: 0x0000BA21
  3356. public static implicit operator System.Windows.Media.Brush(ModBase.MyColor conv)
  3357. {
  3358. return new SolidColorBrush(System.Windows.Media.Color.FromArgb(ModBase.MathByte(conv.mapperError), ModBase.MathByte(conv.m_ThreadError), ModBase.MathByte(conv._PropertyError), ModBase.MathByte(conv.composerError)));
  3359. }
  3360. // Token: 0x06001836 RID: 6198 RVA: 0x0009F1F8 File Offset: 0x0009D3F8
  3361. public static ModBase.MyColor operator +(ModBase.MyColor a, ModBase.MyColor b)
  3362. {
  3363. return new ModBase.MyColor
  3364. {
  3365. mapperError = a.mapperError + b.mapperError,
  3366. composerError = a.composerError + b.composerError,
  3367. _PropertyError = a._PropertyError + b._PropertyError,
  3368. m_ThreadError = a.m_ThreadError + b.m_ThreadError
  3369. };
  3370. }
  3371. // Token: 0x06001837 RID: 6199 RVA: 0x0009F258 File Offset: 0x0009D458
  3372. public static ModBase.MyColor operator -(ModBase.MyColor a, ModBase.MyColor b)
  3373. {
  3374. return new ModBase.MyColor
  3375. {
  3376. mapperError = a.mapperError - b.mapperError,
  3377. composerError = a.composerError - b.composerError,
  3378. _PropertyError = a._PropertyError - b._PropertyError,
  3379. m_ThreadError = a.m_ThreadError - b.m_ThreadError
  3380. };
  3381. }
  3382. // Token: 0x06001838 RID: 6200 RVA: 0x0000D861 File Offset: 0x0000BA61
  3383. public static ModBase.MyColor operator *(ModBase.MyColor a, double b)
  3384. {
  3385. return new ModBase.MyColor
  3386. {
  3387. mapperError = a.mapperError * b,
  3388. composerError = a.composerError * b,
  3389. _PropertyError = a._PropertyError * b,
  3390. m_ThreadError = a.m_ThreadError * b
  3391. };
  3392. }
  3393. // Token: 0x06001839 RID: 6201 RVA: 0x0000D8A0 File Offset: 0x0000BAA0
  3394. public static ModBase.MyColor operator /(ModBase.MyColor a, double b)
  3395. {
  3396. return new ModBase.MyColor
  3397. {
  3398. mapperError = a.mapperError / b,
  3399. composerError = a.composerError / b,
  3400. _PropertyError = a._PropertyError / b,
  3401. m_ThreadError = a.m_ThreadError / b
  3402. };
  3403. }
  3404. // Token: 0x0600183A RID: 6202 RVA: 0x0009F2B8 File Offset: 0x0009D4B8
  3405. public static bool operator ==(ModBase.MyColor a, ModBase.MyColor b)
  3406. {
  3407. return (Information.IsNothing(a) && Information.IsNothing(b)) || (!Information.IsNothing(a) && !Information.IsNothing(b) && (a.mapperError == b.mapperError && a.m_ThreadError == b.m_ThreadError && a._PropertyError == b._PropertyError) && a.composerError == b.composerError);
  3408. }
  3409. // Token: 0x0600183B RID: 6203 RVA: 0x0009F32C File Offset: 0x0009D52C
  3410. public static bool operator !=(ModBase.MyColor a, ModBase.MyColor b)
  3411. {
  3412. return (!Information.IsNothing(a) || !Information.IsNothing(b)) && (Information.IsNothing(a) || Information.IsNothing(b) || a.mapperError != b.mapperError || a.m_ThreadError != b.m_ThreadError || a._PropertyError != b._PropertyError || a.composerError != b.composerError);
  3413. }
  3414. // Token: 0x0600183C RID: 6204 RVA: 0x0009F3A4 File Offset: 0x0009D5A4
  3415. public MyColor()
  3416. {
  3417. this.mapperError = 255.0;
  3418. this.m_ThreadError = 0.0;
  3419. this._PropertyError = 0.0;
  3420. this.composerError = 0.0;
  3421. }
  3422. // Token: 0x0600183D RID: 6205 RVA: 0x0009F3F4 File Offset: 0x0009D5F4
  3423. public MyColor(System.Windows.Media.Color col)
  3424. {
  3425. this.mapperError = 255.0;
  3426. this.m_ThreadError = 0.0;
  3427. this._PropertyError = 0.0;
  3428. this.composerError = 0.0;
  3429. this.mapperError = (double)col.A;
  3430. this.m_ThreadError = (double)col.R;
  3431. this._PropertyError = (double)col.G;
  3432. this.composerError = (double)col.B;
  3433. }
  3434. // Token: 0x0600183E RID: 6206 RVA: 0x0009F47C File Offset: 0x0009D67C
  3435. public MyColor(string HexString)
  3436. {
  3437. this.mapperError = 255.0;
  3438. this.m_ThreadError = 0.0;
  3439. this._PropertyError = 0.0;
  3440. this.composerError = 0.0;
  3441. object obj = System.Windows.Media.ColorConverter.ConvertFromString(HexString);
  3442. System.Windows.Media.Color color = (obj != null) ? ((System.Windows.Media.Color)obj) : default(System.Windows.Media.Color);
  3443. this.mapperError = (double)color.A;
  3444. this.m_ThreadError = (double)color.R;
  3445. this._PropertyError = (double)color.G;
  3446. this.composerError = (double)color.B;
  3447. }
  3448. // Token: 0x0600183F RID: 6207 RVA: 0x0009F520 File Offset: 0x0009D720
  3449. public MyColor(double newA, ModBase.MyColor col)
  3450. {
  3451. this.mapperError = 255.0;
  3452. this.m_ThreadError = 0.0;
  3453. this._PropertyError = 0.0;
  3454. this.composerError = 0.0;
  3455. this.mapperError = newA;
  3456. this.m_ThreadError = col.m_ThreadError;
  3457. this._PropertyError = col._PropertyError;
  3458. this.composerError = col.composerError;
  3459. }
  3460. // Token: 0x06001840 RID: 6208 RVA: 0x0009F59C File Offset: 0x0009D79C
  3461. public MyColor(double newR, double newG, double newB)
  3462. {
  3463. this.mapperError = 255.0;
  3464. this.m_ThreadError = 0.0;
  3465. this._PropertyError = 0.0;
  3466. this.composerError = 0.0;
  3467. this.mapperError = 255.0;
  3468. this.m_ThreadError = newR;
  3469. this._PropertyError = newG;
  3470. this.composerError = newB;
  3471. }
  3472. // Token: 0x06001841 RID: 6209 RVA: 0x0009F610 File Offset: 0x0009D810
  3473. public MyColor(double newA, double newR, double newG, double newB)
  3474. {
  3475. this.mapperError = 255.0;
  3476. this.m_ThreadError = 0.0;
  3477. this._PropertyError = 0.0;
  3478. this.composerError = 0.0;
  3479. this.mapperError = newA;
  3480. this.m_ThreadError = newR;
  3481. this._PropertyError = newG;
  3482. this.composerError = newB;
  3483. }
  3484. // Token: 0x06001842 RID: 6210 RVA: 0x0009F680 File Offset: 0x0009D880
  3485. public MyColor(System.Windows.Media.Brush brush)
  3486. {
  3487. this.mapperError = 255.0;
  3488. this.m_ThreadError = 0.0;
  3489. this._PropertyError = 0.0;
  3490. this.composerError = 0.0;
  3491. System.Windows.Media.Color color = ((SolidColorBrush)brush).Color;
  3492. this.mapperError = (double)color.A;
  3493. this.m_ThreadError = (double)color.R;
  3494. this._PropertyError = (double)color.G;
  3495. this.composerError = (double)color.B;
  3496. }
  3497. // Token: 0x06001843 RID: 6211 RVA: 0x0009F714 File Offset: 0x0009D914
  3498. public MyColor(SolidColorBrush brush)
  3499. {
  3500. this.mapperError = 255.0;
  3501. this.m_ThreadError = 0.0;
  3502. this._PropertyError = 0.0;
  3503. this.composerError = 0.0;
  3504. System.Windows.Media.Color color = brush.Color;
  3505. this.mapperError = (double)color.A;
  3506. this.m_ThreadError = (double)color.R;
  3507. this._PropertyError = (double)color.G;
  3508. this.composerError = (double)color.B;
  3509. }
  3510. // Token: 0x06001844 RID: 6212 RVA: 0x0009F7A4 File Offset: 0x0009D9A4
  3511. public MyColor(object obj)
  3512. {
  3513. this.mapperError = 255.0;
  3514. this.m_ThreadError = 0.0;
  3515. this._PropertyError = 0.0;
  3516. this.composerError = 0.0;
  3517. if (obj == null)
  3518. {
  3519. this.mapperError = 255.0;
  3520. this.m_ThreadError = 255.0;
  3521. this._PropertyError = 255.0;
  3522. this.composerError = 255.0;
  3523. return;
  3524. }
  3525. if (obj is SolidColorBrush)
  3526. {
  3527. System.Windows.Media.Color color = ((SolidColorBrush)obj).Color;
  3528. this.mapperError = (double)color.A;
  3529. this.m_ThreadError = (double)color.R;
  3530. this._PropertyError = (double)color.G;
  3531. this.composerError = (double)color.B;
  3532. return;
  3533. }
  3534. this.mapperError = Conversions.ToDouble(NewLateBinding.LateGet(obj, null, "A", new object[0], null, null, null));
  3535. this.m_ThreadError = Conversions.ToDouble(NewLateBinding.LateGet(obj, null, "R", new object[0], null, null, null));
  3536. this._PropertyError = Conversions.ToDouble(NewLateBinding.LateGet(obj, null, "G", new object[0], null, null, null));
  3537. this.composerError = Conversions.ToDouble(NewLateBinding.LateGet(obj, null, "B", new object[0], null, null, null));
  3538. }
  3539. // Token: 0x06001845 RID: 6213 RVA: 0x0009F904 File Offset: 0x0009DB04
  3540. public double Hue(double v1, double v2, double vH)
  3541. {
  3542. if (vH < 0.0)
  3543. {
  3544. vH += 1.0;
  3545. }
  3546. if (vH > 1.0)
  3547. {
  3548. vH -= 1.0;
  3549. }
  3550. double result;
  3551. if (vH < 0.16667)
  3552. {
  3553. result = v1 + (v2 - v1) * 6.0 * vH;
  3554. }
  3555. else if (vH < 0.5)
  3556. {
  3557. result = v2;
  3558. }
  3559. else if (vH < 0.66667)
  3560. {
  3561. result = v1 + (v2 - v1) * (4.0 - vH * 6.0);
  3562. }
  3563. else
  3564. {
  3565. result = v1;
  3566. }
  3567. return result;
  3568. }
  3569. // Token: 0x06001846 RID: 6214 RVA: 0x0009F9A0 File Offset: 0x0009DBA0
  3570. public ModBase.MyColor FromHSL(double sH, double sS, double sL)
  3571. {
  3572. if (sS == 0.0)
  3573. {
  3574. this.m_ThreadError = sL * 2.55;
  3575. this._PropertyError = this.m_ThreadError;
  3576. this.composerError = this.m_ThreadError;
  3577. }
  3578. else
  3579. {
  3580. double num = sH / 360.0;
  3581. double num2 = sS / 100.0;
  3582. double num3 = sL / 100.0;
  3583. num2 = ((num3 < 0.5) ? (num2 * num3 + num3) : (num2 * (1.0 - num3) + num3));
  3584. num3 = 2.0 * num3 - num2;
  3585. this.m_ThreadError = 255.0 * this.Hue(num3, num2, num + 0.3333333333333333);
  3586. this._PropertyError = 255.0 * this.Hue(num3, num2, num);
  3587. this.composerError = 255.0 * this.Hue(num3, num2, num - 0.3333333333333333);
  3588. }
  3589. this.mapperError = 255.0;
  3590. return this;
  3591. }
  3592. // Token: 0x06001847 RID: 6215 RVA: 0x0009FAAC File Offset: 0x0009DCAC
  3593. public ModBase.MyColor FromHSL2(double sH, double sS, double sL)
  3594. {
  3595. if (sS == 0.0)
  3596. {
  3597. this.m_ThreadError = sL * 2.55;
  3598. this._PropertyError = this.m_ThreadError;
  3599. this.composerError = this.m_ThreadError;
  3600. }
  3601. else
  3602. {
  3603. sH = (sH + 3600000.0) % 360.0;
  3604. double[] array = new double[]
  3605. {
  3606. 0.1,
  3607. -0.06,
  3608. -0.3,
  3609. -0.19,
  3610. -0.15,
  3611. -0.24,
  3612. -0.32,
  3613. -0.09,
  3614. 0.18,
  3615. 0.05,
  3616. -0.12,
  3617. -0.02,
  3618. 0.1,
  3619. -0.06
  3620. };
  3621. double num = sH / 30.0;
  3622. int num2 = checked((int)Math.Floor(num));
  3623. num = 50.0 - ((1.0 - num + (double)num2) * array[num2] + (num - (double)num2) * array[checked(num2 + 1)]) * sS;
  3624. sL = ((sL < num) ? (sL / num) : (1.0 + (sL - num) / (100.0 - num))) * 50.0;
  3625. this.FromHSL(sH, sS, sL);
  3626. }
  3627. this.mapperError = 255.0;
  3628. return this;
  3629. }
  3630. // Token: 0x06001848 RID: 6216 RVA: 0x0009FBA4 File Offset: 0x0009DDA4
  3631. public override string ToString()
  3632. {
  3633. return string.Concat(new string[]
  3634. {
  3635. "(",
  3636. Conversions.ToString(this.mapperError),
  3637. ",",
  3638. Conversions.ToString(this.m_ThreadError),
  3639. ",",
  3640. Conversions.ToString(this._PropertyError),
  3641. ",",
  3642. Conversions.ToString(this.composerError),
  3643. ")"
  3644. });
  3645. }
  3646. // Token: 0x06001849 RID: 6217 RVA: 0x0000D8DF File Offset: 0x0000BADF
  3647. public override bool Equals(object obj)
  3648. {
  3649. return this == (ModBase.MyColor)obj;
  3650. }
  3651. // Token: 0x04000C6E RID: 3182
  3652. public double mapperError;
  3653. // Token: 0x04000C6F RID: 3183
  3654. public double m_ThreadError;
  3655. // Token: 0x04000C70 RID: 3184
  3656. public double _PropertyError;
  3657. // Token: 0x04000C71 RID: 3185
  3658. public double composerError;
  3659. }
  3660. // Token: 0x02000200 RID: 512
  3661. public class MyRect
  3662. {
  3663. // Token: 0x17000407 RID: 1031
  3664. // (get) Token: 0x0600184B RID: 6219 RVA: 0x0000D8ED File Offset: 0x0000BAED
  3665. // (set) Token: 0x0600184C RID: 6220 RVA: 0x0000D8F5 File Offset: 0x0000BAF5
  3666. public double Width { get; set; }
  3667. // Token: 0x17000408 RID: 1032
  3668. // (get) Token: 0x0600184D RID: 6221 RVA: 0x0000D8FE File Offset: 0x0000BAFE
  3669. // (set) Token: 0x0600184E RID: 6222 RVA: 0x0000D906 File Offset: 0x0000BB06
  3670. public double Height { get; set; }
  3671. // Token: 0x17000409 RID: 1033
  3672. // (get) Token: 0x0600184F RID: 6223 RVA: 0x0000D90F File Offset: 0x0000BB0F
  3673. // (set) Token: 0x06001850 RID: 6224 RVA: 0x0000D917 File Offset: 0x0000BB17
  3674. public double Left { get; set; }
  3675. // Token: 0x1700040A RID: 1034
  3676. // (get) Token: 0x06001851 RID: 6225 RVA: 0x0000D920 File Offset: 0x0000BB20
  3677. // (set) Token: 0x06001852 RID: 6226 RVA: 0x0000D928 File Offset: 0x0000BB28
  3678. public double Top { get; set; }
  3679. // Token: 0x06001853 RID: 6227 RVA: 0x0009FC20 File Offset: 0x0009DE20
  3680. public MyRect()
  3681. {
  3682. this.Width = 0.0;
  3683. this.Height = 0.0;
  3684. this.Left = 0.0;
  3685. this.Top = 0.0;
  3686. }
  3687. // Token: 0x06001854 RID: 6228 RVA: 0x0009FC70 File Offset: 0x0009DE70
  3688. public MyRect(double left, double top, double width, double height)
  3689. {
  3690. this.Width = 0.0;
  3691. this.Height = 0.0;
  3692. this.Left = 0.0;
  3693. this.Top = 0.0;
  3694. this.Left = left;
  3695. this.Top = top;
  3696. this.Width = width;
  3697. this.Height = height;
  3698. }
  3699. // Token: 0x04000C72 RID: 3186
  3700. [CompilerGenerated]
  3701. private double m_IteratorError;
  3702. // Token: 0x04000C73 RID: 3187
  3703. [CompilerGenerated]
  3704. private double _RepositoryError;
  3705. // Token: 0x04000C74 RID: 3188
  3706. [CompilerGenerated]
  3707. private double m_TestError;
  3708. // Token: 0x04000C75 RID: 3189
  3709. [CompilerGenerated]
  3710. private double m_MapError;
  3711. }
  3712. // Token: 0x02000201 RID: 513
  3713. public enum LoadState
  3714. {
  3715. // Token: 0x04000C77 RID: 3191
  3716. Waiting,
  3717. // Token: 0x04000C78 RID: 3192
  3718. Loading,
  3719. // Token: 0x04000C79 RID: 3193
  3720. Finished,
  3721. // Token: 0x04000C7A RID: 3194
  3722. Failed,
  3723. // Token: 0x04000C7B RID: 3195
  3724. Aborted
  3725. }
  3726. // Token: 0x02000202 RID: 514
  3727. public enum Result
  3728. {
  3729. // Token: 0x04000C7D RID: 3197
  3730. Aborted = -1,
  3731. // Token: 0x04000C7E RID: 3198
  3732. Success,
  3733. // Token: 0x04000C7F RID: 3199
  3734. Fail,
  3735. // Token: 0x04000C80 RID: 3200
  3736. Exception,
  3737. // Token: 0x04000C81 RID: 3201
  3738. Timeout,
  3739. // Token: 0x04000C82 RID: 3202
  3740. Cancel
  3741. }
  3742. // Token: 0x02000203 RID: 515
  3743. public class EqualableList<T> : List<!0>
  3744. {
  3745. // Token: 0x06001857 RID: 6231 RVA: 0x0009FCE0 File Offset: 0x0009DEE0
  3746. public override bool Equals(object obj)
  3747. {
  3748. checked
  3749. {
  3750. bool result;
  3751. if (!(obj is List<!0>))
  3752. {
  3753. result = false;
  3754. }
  3755. else
  3756. {
  3757. List<T> list = (List<!0>)obj;
  3758. if (list.Count != base.Count)
  3759. {
  3760. result = false;
  3761. }
  3762. else
  3763. {
  3764. int num = list.Count - 1;
  3765. for (int i = 0; i <= num; i++)
  3766. {
  3767. T t = list[i];
  3768. if (!t.Equals(base[i]))
  3769. {
  3770. return false;
  3771. }
  3772. }
  3773. result = true;
  3774. }
  3775. }
  3776. return result;
  3777. }
  3778. }
  3779. // Token: 0x06001858 RID: 6232 RVA: 0x0000D93A File Offset: 0x0000BB3A
  3780. public static bool operator ==(ModBase.EqualableList<T> left, ModBase.EqualableList<T> right)
  3781. {
  3782. return EqualityComparer<ModBase.EqualableList<!0>>.Default.Equals(left, right);
  3783. }
  3784. // Token: 0x06001859 RID: 6233 RVA: 0x0000D948 File Offset: 0x0000BB48
  3785. public static bool operator !=(ModBase.EqualableList<T> left, ModBase.EqualableList<T> right)
  3786. {
  3787. return !(left == right);
  3788. }
  3789. }
  3790. // Token: 0x02000204 RID: 516
  3791. public class FileChecker
  3792. {
  3793. // Token: 0x0600185B RID: 6235 RVA: 0x0009FD54 File Offset: 0x0009DF54
  3794. public FileChecker(long MinSize = -1L, long ActualSize = -1L, string Hash = null, bool CanUseExistsFile = true, bool IsJson = false)
  3795. {
  3796. this._ErrorError = -1L;
  3797. this.m_ContextError = -1L;
  3798. this.specificationError = null;
  3799. this.m_MockError = true;
  3800. this.m_RequestError = false;
  3801. this._ErrorError = ActualSize;
  3802. this.m_ContextError = MinSize;
  3803. this.specificationError = Hash;
  3804. this.m_MockError = CanUseExistsFile;
  3805. this.m_RequestError = IsJson;
  3806. }
  3807. // Token: 0x0600185C RID: 6236 RVA: 0x0009FDC0 File Offset: 0x0009DFC0
  3808. public string Check(string LocalPath)
  3809. {
  3810. string result;
  3811. try
  3812. {
  3813. FileInfo fileInfo = new FileInfo(LocalPath);
  3814. if (!fileInfo.Exists)
  3815. {
  3816. result = "文件不存在:" + LocalPath;
  3817. }
  3818. else
  3819. {
  3820. long length = fileInfo.Length;
  3821. if (this._ErrorError >= 0L && this._ErrorError != length)
  3822. {
  3823. result = string.Concat(new string[]
  3824. {
  3825. "文件大小应为 ",
  3826. Conversions.ToString(this._ErrorError),
  3827. " B,实际为 ",
  3828. Conversions.ToString(length),
  3829. " B"
  3830. });
  3831. }
  3832. else if (this.m_ContextError >= 0L && this.m_ContextError > length)
  3833. {
  3834. result = string.Concat(new string[]
  3835. {
  3836. "文件大小应大于 ",
  3837. Conversions.ToString(this.m_ContextError),
  3838. " B,实际为 ",
  3839. Conversions.ToString(length),
  3840. " B"
  3841. });
  3842. }
  3843. else
  3844. {
  3845. if (!string.IsNullOrEmpty(this.specificationError))
  3846. {
  3847. if (this.specificationError.Length < 35)
  3848. {
  3849. if (Operators.CompareString(this.specificationError.ToLowerInvariant(), ModBase.smethod_0(LocalPath), false) != 0)
  3850. {
  3851. return "文件 MD5 应为 " + this.specificationError + ",实际为 " + ModBase.smethod_0(LocalPath);
  3852. }
  3853. }
  3854. else if (this.specificationError.Length == 64)
  3855. {
  3856. if (Operators.CompareString(this.specificationError.ToLowerInvariant(), ModBase.GetFileSHA256(LocalPath), false) != 0)
  3857. {
  3858. return "文件 SHA256 应为 " + this.specificationError + ",实际为 " + ModBase.GetFileSHA256(LocalPath);
  3859. }
  3860. }
  3861. else if (Operators.CompareString(this.specificationError.ToLowerInvariant(), ModBase.smethod_1(LocalPath), false) != 0)
  3862. {
  3863. return "文件 SHA1 应为 " + this.specificationError + ",实际为 " + ModBase.smethod_1(LocalPath);
  3864. }
  3865. }
  3866. if (this.m_RequestError)
  3867. {
  3868. string text = ModBase.ReadFile(LocalPath, null);
  3869. if (Operators.CompareString(text, "", false) == 0)
  3870. {
  3871. throw new Exception("读取到的文件为空");
  3872. }
  3873. try
  3874. {
  3875. ModBase.GetJson(text);
  3876. }
  3877. catch (Exception innerException)
  3878. {
  3879. throw new Exception("不是有效的 json 文件", innerException);
  3880. }
  3881. }
  3882. result = null;
  3883. }
  3884. }
  3885. }
  3886. catch (Exception ex)
  3887. {
  3888. ModBase.Log(ex, "检查文件出错", ModBase.LogLevel.Debug, "出现错误");
  3889. result = ModBase.GetExceptionSummary(ex);
  3890. }
  3891. return result;
  3892. }
  3893. // Token: 0x04000C83 RID: 3203
  3894. public long _ErrorError;
  3895. // Token: 0x04000C84 RID: 3204
  3896. public long m_ContextError;
  3897. // Token: 0x04000C85 RID: 3205
  3898. public string specificationError;
  3899. // Token: 0x04000C86 RID: 3206
  3900. public bool m_MockError;
  3901. // Token: 0x04000C87 RID: 3207
  3902. public bool m_RequestError;
  3903. }
  3904. // Token: 0x02000205 RID: 517
  3905. public class SearchEntry<T>
  3906. {
  3907. // Token: 0x04000C88 RID: 3208
  3908. public T m_DicError;
  3909. // Token: 0x04000C89 RID: 3209
  3910. public List<KeyValuePair<string, double>> helperError;
  3911. // Token: 0x04000C8A RID: 3210
  3912. public double m_IssuerError;
  3913. // Token: 0x04000C8B RID: 3211
  3914. public bool indexerError;
  3915. }
  3916. // Token: 0x02000206 RID: 518
  3917. public class SafeList<T> : SynchronizedCollection<T>, IEnumerable, IEnumerable<!0>
  3918. {
  3919. // Token: 0x06001860 RID: 6240 RVA: 0x0000D954 File Offset: 0x0000BB54
  3920. public SafeList()
  3921. {
  3922. }
  3923. // Token: 0x06001861 RID: 6241 RVA: 0x0000D95D File Offset: 0x0000BB5D
  3924. public SafeList(IEnumerable<T> Data) : base(RuntimeHelpers.GetObjectValue(new object()), Data)
  3925. {
  3926. }
  3927. // Token: 0x06001862 RID: 6242 RVA: 0x0000D971 File Offset: 0x0000BB71
  3928. public static implicit operator ModBase.SafeList<T>(List<T> Data)
  3929. {
  3930. return new ModBase.SafeList<!0>(Data);
  3931. }
  3932. // Token: 0x06001863 RID: 6243 RVA: 0x0000D979 File Offset: 0x0000BB79
  3933. public static implicit operator List<T>(ModBase.SafeList<T> Data)
  3934. {
  3935. return new List<!0>(Data);
  3936. }
  3937. // Token: 0x06001864 RID: 6244 RVA: 0x000A0030 File Offset: 0x0009E230
  3938. public new IEnumerator<T> GetEnumerator()
  3939. {
  3940. object syncRoot = base.SyncRoot;
  3941. ObjectFlowControl.CheckForSyncLockOnValueType(syncRoot);
  3942. IEnumerator<T> result;
  3943. lock (syncRoot)
  3944. {
  3945. result = (IEnumerator<!0>)Enumerable.ToList<T>(base.Items).GetEnumerator();
  3946. }
  3947. return result;
  3948. }
  3949. // Token: 0x06001865 RID: 6245 RVA: 0x000A008C File Offset: 0x0009E28C
  3950. IEnumerator IEnumerable.GetEnumeratorGeneral()
  3951. {
  3952. object syncRoot = base.SyncRoot;
  3953. ObjectFlowControl.CheckForSyncLockOnValueType(syncRoot);
  3954. IEnumerator result;
  3955. lock (syncRoot)
  3956. {
  3957. result = (IEnumerator)Enumerable.ToList<T>(base.Items).GetEnumerator();
  3958. }
  3959. return result;
  3960. }
  3961. }
  3962. // Token: 0x02000207 RID: 519
  3963. public class RestartException : Exception
  3964. {
  3965. }
  3966. // Token: 0x02000208 RID: 520
  3967. public class CancelledException : Exception
  3968. {
  3969. }
  3970. // Token: 0x02000209 RID: 521
  3971. public sealed class RouteEventArgs : EventArgs
  3972. {
  3973. // Token: 0x0600186B RID: 6251 RVA: 0x0000D981 File Offset: 0x0000BB81
  3974. public RouteEventArgs(bool RaiseByMouse = false)
  3975. {
  3976. this.m_SerializerError = false;
  3977. this.interpreterError = RaiseByMouse;
  3978. }
  3979. // Token: 0x04000C8C RID: 3212
  3980. public bool interpreterError;
  3981. // Token: 0x04000C8D RID: 3213
  3982. public bool m_SerializerError;
  3983. }
  3984. // Token: 0x0200020A RID: 522
  3985. // (Invoke) Token: 0x06001870 RID: 6256
  3986. public delegate bool CompareThreadStart<T>(T Left, T Right);
  3987. // Token: 0x0200020B RID: 523
  3988. public enum LogLevel
  3989. {
  3990. // Token: 0x04000C8F RID: 3215
  3991. Normal,
  3992. // Token: 0x04000C90 RID: 3216
  3993. Developer,
  3994. // Token: 0x04000C91 RID: 3217
  3995. Debug,
  3996. // Token: 0x04000C92 RID: 3218
  3997. Hint,
  3998. // Token: 0x04000C93 RID: 3219
  3999. Msgbox,
  4000. // Token: 0x04000C94 RID: 3220
  4001. Feedback,
  4002. // Token: 0x04000C95 RID: 3221
  4003. Assert
  4004. }
  4005. }
  4006. }