PageRenderTime 78ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/Tools/LinqPad/LINQPad/Util.cs

https://github.com/vishalsh-spec/TestProject
C# | 860 lines | 784 code | 75 blank | 1 comment | 108 complexity | 4e5d5f73810bf91b30fa5b22ee278c29 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.0, Apache-2.0
  1. namespace LINQPad
  2. {
  3. using LINQPad.ExecutionModel;
  4. using LINQPad.ObjectGraph;
  5. using LINQPad.ObjectGraph.Formatters;
  6. using LINQPad.ObjectModel;
  7. using LINQPad.Properties;
  8. using LINQPad.UI;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data.Linq;
  14. using System.Diagnostics;
  15. using System.IO;
  16. using System.Linq;
  17. using System.Net;
  18. using System.Reflection;
  19. using System.Runtime.CompilerServices;
  20. using System.Security;
  21. using System.Security.Permissions;
  22. using System.Security.Policy;
  23. using System.Threading;
  24. using System.Windows.Forms;
  25. using System.Xml.Linq;
  26. public static class Util
  27. {
  28. private static int? _progressPercent;
  29. internal static volatile Process CurrentExternalProcess;
  30. public static T Cache<T>(Func<T> dataFetcher)
  31. {
  32. return UserCache.CacheValue<T>(dataFetcher, null);
  33. }
  34. public static T Cache<T>(Func<T> dataFetcher, string key)
  35. {
  36. return UserCache.CacheValue<T>(dataFetcher, key);
  37. }
  38. public static void ClearResults()
  39. {
  40. Server currentServer = Server.CurrentServer;
  41. if (currentServer != null)
  42. {
  43. currentServer.ResultsWriter.Clear();
  44. }
  45. }
  46. public static string[] Cmd(string commandText)
  47. {
  48. return Cmd(commandText, false);
  49. }
  50. public static string[] Cmd(string commandText, bool quiet)
  51. {
  52. return Cmd(commandText, null, quiet);
  53. }
  54. public static string[] Cmd(string commandText, string args)
  55. {
  56. return Cmd(commandText, args, false);
  57. }
  58. public static string[] Cmd(string commandText, string args, bool quiet)
  59. {
  60. Process process;
  61. List<string> list = new List<string>();
  62. try
  63. {
  64. process = GetCmdProcess(commandText, args, false);
  65. }
  66. catch (Win32Exception)
  67. {
  68. process = GetCmdProcess(commandText, args, true);
  69. }
  70. CurrentExternalProcess = process;
  71. using (process)
  72. {
  73. try
  74. {
  75. string str2;
  76. goto Label_003C;
  77. Label_002A:
  78. if (!quiet)
  79. {
  80. Console.WriteLine(str2);
  81. }
  82. list.Add(str2);
  83. Label_003C:
  84. str2 = process.StandardOutput.ReadLine();
  85. if (str2 != null)
  86. {
  87. goto Label_002A;
  88. }
  89. string str = process.StandardError.ReadToEnd();
  90. int exitCode = process.ExitCode;
  91. if (!string.IsNullOrEmpty(str))
  92. {
  93. throw new CommandExecutionException(str, exitCode);
  94. }
  95. if (exitCode > 0)
  96. {
  97. throw new CommandExecutionException(null, exitCode);
  98. }
  99. }
  100. finally
  101. {
  102. CurrentExternalProcess = null;
  103. if (!process.HasExited)
  104. {
  105. try
  106. {
  107. process.Kill();
  108. }
  109. catch
  110. {
  111. }
  112. }
  113. }
  114. }
  115. return list.ToArray();
  116. }
  117. public static AppDomain CreateAppDomain(string friendlyName)
  118. {
  119. return CreateAppDomain(friendlyName, AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation);
  120. }
  121. public static AppDomain CreateAppDomain(string friendlyName, Evidence securityInfo)
  122. {
  123. return CreateAppDomain(friendlyName, securityInfo, AppDomain.CurrentDomain.SetupInformation);
  124. }
  125. public static AppDomain CreateAppDomain(string friendlyName, Evidence securityInfo, AppDomainSetup setup)
  126. {
  127. AppDomain domain = AppDomain.CreateDomain(friendlyName, securityInfo, setup);
  128. domain.SetData("CurrentQueryAssemblyPath", Server.CurrentQueryAssemblyPath);
  129. domain.SetData("CurrentQueryAdditionalRefs", Server.CurrentQueryAdditionalRefs);
  130. domain.AssemblyResolve += new ResolveEventHandler(Util.domain_AssemblyResolve);
  131. return domain;
  132. }
  133. public static void CreateSynchronizationContext()
  134. {
  135. CreateSynchronizationContext(true);
  136. }
  137. public static void CreateSynchronizationContext(bool detectDeadlocks)
  138. {
  139. CreateSynchronizationContext(detectDeadlocks, false);
  140. }
  141. public static void CreateSynchronizationContext(bool detectDeadlocks, bool reportActivity)
  142. {
  143. if (!(AsyncOperationManager.SynchronizationContext is LINQPadSynchronizationContext))
  144. {
  145. AsyncOperationManager.SynchronizationContext = new LINQPadSynchronizationContext(detectDeadlocks, reportActivity);
  146. if (reportActivity)
  147. {
  148. Highlight("Synchronization Context created on thread " + Thread.CurrentThread.ManagedThreadId).Dump<object>();
  149. }
  150. }
  151. }
  152. public static TextWriter CreateXhtmlWriter()
  153. {
  154. return new XhtmlWriter(false, false);
  155. }
  156. public static TextWriter CreateXhtmlWriter(bool enableExpansions)
  157. {
  158. return new XhtmlWriter(enableExpansions, false);
  159. }
  160. public static TextWriter CreateXhtmlWriter(int maxDepth)
  161. {
  162. return new XhtmlWriter(false, false) { MaxDepth = new int?(maxDepth) };
  163. }
  164. public static TextWriter CreateXhtmlWriter(bool enableExpansions, int maxDepth)
  165. {
  166. return new XhtmlWriter(enableExpansions, false) { MaxDepth = new int?(maxDepth) };
  167. }
  168. public static void DisplayWebPage(string uriOrPath)
  169. {
  170. DisplayWebPage(uriOrPath, null);
  171. }
  172. public static void DisplayWebPage(Uri uri)
  173. {
  174. DisplayWebPage(uri.ToString(), null);
  175. }
  176. public static void DisplayWebPage(string uriOrPath, string title)
  177. {
  178. WebBrowser browser;
  179. ToolStrip tools;
  180. ToolStripItem backButton;
  181. ToolStripItem forwardButton;
  182. if (!string.IsNullOrEmpty(uriOrPath))
  183. {
  184. if (string.IsNullOrEmpty(title))
  185. {
  186. title = "Web Page";
  187. try
  188. {
  189. Uri uri = new Uri(uriOrPath);
  190. if (uri.Segments.Any<string>() && (uri.Segments.Last<string>().Length > 2))
  191. {
  192. title = uri.Segments.Last<string>();
  193. }
  194. else if (uri.Host.Length > 2)
  195. {
  196. title = uri.Host;
  197. }
  198. else
  199. {
  200. title = uri.ToString();
  201. }
  202. }
  203. catch
  204. {
  205. }
  206. }
  207. Panel o = new Panel();
  208. browser = new WebBrowser {
  209. Dock = DockStyle.Fill
  210. };
  211. tools = new ToolStrip {
  212. Dock = DockStyle.Top,
  213. GripStyle = ToolStripGripStyle.Hidden,
  214. Visible = false,
  215. Padding = new Padding(0, 0, 0, 1)
  216. };
  217. backButton = tools.Items.Add("Back", Resources.Back, delegate (object sender, EventArgs e) {
  218. if (browser.CanGoBack)
  219. {
  220. browser.GoBack();
  221. }
  222. });
  223. forwardButton = tools.Items.Add("Forward", Resources.Forward, delegate (object sender, EventArgs e) {
  224. if (browser.CanGoForward)
  225. {
  226. browser.GoForward();
  227. }
  228. });
  229. backButton.Margin = new Padding(2, 0, 0, 0);
  230. EventHandler handler = delegate (object sender, EventArgs e) {
  231. backButton.Enabled = browser.CanGoBack;
  232. forwardButton.Enabled = browser.CanGoForward;
  233. tools.Visible = browser.CanGoBack || browser.CanGoForward;
  234. };
  235. browser.CanGoBackChanged += handler;
  236. browser.CanGoForwardChanged += handler;
  237. o.Controls.Add(browser);
  238. o.Controls.Add(tools);
  239. browser.Navigate(uriOrPath);
  240. o.Dump<Panel>(title);
  241. }
  242. }
  243. public static void DisplayWebPage(Uri uri, string title)
  244. {
  245. DisplayWebPage(uri.ToString(), title);
  246. }
  247. private static Assembly domain_AssemblyResolve(object sender, ResolveEventArgs args)
  248. {
  249. Func<string, bool> predicate = null;
  250. string simpleName = new AssemblyName(args.Name).Name.ToLowerInvariant();
  251. string[] data = (string[]) AppDomain.CurrentDomain.GetData("CurrentQueryAdditionalRefs");
  252. string assemblyFile = (string) AppDomain.CurrentDomain.GetData("CurrentQueryAssemblyPath");
  253. if (data != null)
  254. {
  255. if (predicate == null)
  256. {
  257. predicate = r => Path.GetFileNameWithoutExtension(r).ToLowerInvariant() == simpleName;
  258. }
  259. string str2 = data.FirstOrDefault<string>(predicate);
  260. if (str2 != null)
  261. {
  262. return Assembly.LoadFrom(str2);
  263. }
  264. }
  265. if ((assemblyFile != null) && assemblyFile.ToLowerInvariant().Contains(simpleName))
  266. {
  267. return Assembly.LoadFrom(assemblyFile);
  268. }
  269. return null;
  270. }
  271. internal static IEnumerable<T> Flatten<T>(T element, Func<T, IEnumerable<T>> childSelector)
  272. {
  273. return new T[] { element }.Concat<T>((from child in childSelector(element) select Flatten<T>(child, childSelector)));
  274. }
  275. internal static IEnumerable<T> Flatten<T>(T element, Func<T, T> childSelector)
  276. {
  277. return new T[] { element }.Concat<T>((from child in new T[] { childSelector(element) } select Flatten<T>(child, childSelector)));
  278. }
  279. private static Process GetCmdProcess(string cmdText, string args, bool useCmdExec)
  280. {
  281. cmdText = cmdText.Trim();
  282. ProcessStartInfo startInfo = new ProcessStartInfo {
  283. RedirectStandardOutput = true,
  284. RedirectStandardError = true,
  285. RedirectStandardInput = true,
  286. UseShellExecute = false,
  287. CreateNoWindow = true
  288. };
  289. if (useCmdExec)
  290. {
  291. startInfo.FileName = "cmd.exe";
  292. string source = cmdText;
  293. if (source.Contains<char>(' '))
  294. {
  295. source = '"' + source + '"';
  296. }
  297. startInfo.Arguments = "/c " + source;
  298. if (!string.IsNullOrEmpty(args))
  299. {
  300. startInfo.Arguments = startInfo.Arguments + " " + args;
  301. }
  302. }
  303. else
  304. {
  305. startInfo.FileName = cmdText;
  306. startInfo.Arguments = args;
  307. if ((string.IsNullOrEmpty(args) && cmdText.Contains<char>(' ')) && !File.Exists(cmdText))
  308. {
  309. string[] strArray = cmdText.Split(" ".ToCharArray(), 2, StringSplitOptions.RemoveEmptyEntries);
  310. if (File.Exists(strArray[0]))
  311. {
  312. startInfo.FileName = strArray[0];
  313. startInfo.Arguments = strArray[1];
  314. }
  315. }
  316. try
  317. {
  318. if (Path.IsPathRooted(startInfo.FileName))
  319. {
  320. string directoryName = Path.GetDirectoryName(startInfo.FileName);
  321. if (Directory.Exists(directoryName))
  322. {
  323. startInfo.WorkingDirectory = directoryName;
  324. }
  325. }
  326. }
  327. catch (ArgumentException)
  328. {
  329. }
  330. }
  331. return Process.Start(startInfo);
  332. }
  333. public static IEnumerable<Query> GetMyQueries()
  334. {
  335. return FileQuery.GetMyQueries();
  336. }
  337. public static string GetPassword(string name)
  338. {
  339. return GetPassword(name, false);
  340. }
  341. public static string GetPassword(string name, bool noDefaultSave)
  342. {
  343. string password = PasswordManager.GetPassword(name);
  344. if (password == null)
  345. {
  346. using (SavePasswordForm form = new SavePasswordForm("Password for " + name, !noDefaultSave))
  347. {
  348. if (form.ShowDialog() != DialogResult.OK)
  349. {
  350. return null;
  351. }
  352. password = form.Password;
  353. if (form.SavePassword)
  354. {
  355. PasswordManager.SetPassword(name, password);
  356. }
  357. }
  358. }
  359. return password;
  360. }
  361. public static IDisposable GetQueryLifeExtensionToken()
  362. {
  363. Server server = Server.CurrentServer;
  364. if (server != null)
  365. {
  366. server.QueryCompletionCountdown.Increment();
  367. }
  368. return new LifeExtensionToken(delegate {
  369. try
  370. {
  371. if (server != null)
  372. {
  373. server.QueryCompletionCountdown.Decrement();
  374. }
  375. }
  376. catch
  377. {
  378. }
  379. });
  380. }
  381. internal static PermissionSet GetQueryPermissions()
  382. {
  383. return GetQueryPermissions(false);
  384. }
  385. internal static PermissionSet GetQueryPermissions(bool userQuery)
  386. {
  387. return new PermissionSet(PermissionState.Unrestricted);
  388. }
  389. public static string GetSampleFilePath(string sampleLibraryName, string fileName)
  390. {
  391. if (string.IsNullOrEmpty(sampleLibraryName))
  392. {
  393. throw new ArgumentException("You must specify a sample library name", "sampleLibraryName");
  394. }
  395. if (string.IsNullOrEmpty(fileName))
  396. {
  397. throw new ArgumentException("You must specify a filename", "fileName");
  398. }
  399. return Path.Combine(GetSamplesFolder(sampleLibraryName), fileName);
  400. }
  401. public static IEnumerable<Query> GetSamples()
  402. {
  403. return Query.GetSamples();
  404. }
  405. public static string GetSamplesFolder()
  406. {
  407. return GetSamplesFolder(null);
  408. }
  409. public static string GetSamplesFolder(string sampleLibraryName)
  410. {
  411. if (string.IsNullOrEmpty(sampleLibraryName))
  412. {
  413. return Path.Combine(Program.UserDataFolder, "Samples");
  414. }
  415. return Path.Combine(Program.UserDataFolder, @"Samples\" + sampleLibraryName);
  416. }
  417. public static WebProxy GetWebProxy()
  418. {
  419. return ProxyOptions.Instance.GetWebProxy();
  420. }
  421. public static object Highlight(object data)
  422. {
  423. return new LINQPad.ObjectGraph.Highlight(data);
  424. }
  425. public static object HighlightIf<T>(T data, Func<T, bool> predicate)
  426. {
  427. if (predicate(data))
  428. {
  429. return new LINQPad.ObjectGraph.Highlight(data);
  430. }
  431. return data;
  432. }
  433. public static object HorizontalRun(bool withGaps, params object[] elements)
  434. {
  435. return new LINQPad.ObjectGraph.HorizontalRun(withGaps, elements);
  436. }
  437. public static object HorizontalRun(bool withGaps, IEnumerable elements)
  438. {
  439. return new LINQPad.ObjectGraph.HorizontalRun(withGaps, elements);
  440. }
  441. public static object Image(Binary imageData)
  442. {
  443. if (imageData == null)
  444. {
  445. return null;
  446. }
  447. byte[] data = imageData.ToArray();
  448. if ((data == null) || (data.Length == 0))
  449. {
  450. return null;
  451. }
  452. return new ImageBlob(data);
  453. }
  454. public static object Image(byte[] imageData)
  455. {
  456. return new ImageBlob(imageData);
  457. }
  458. public static object Image(string pathOrUri)
  459. {
  460. if (string.IsNullOrEmpty(pathOrUri))
  461. {
  462. return null;
  463. }
  464. return Image(new Uri(pathOrUri));
  465. }
  466. public static object Image(Uri uri)
  467. {
  468. if (uri == null)
  469. {
  470. return null;
  471. }
  472. return new ImageRef(uri);
  473. }
  474. internal static bool IsMetaGraphNode(object x)
  475. {
  476. if (x == null)
  477. {
  478. return false;
  479. }
  480. return (x.GetType().GetCustomAttributes(typeof(MetaGraphNodeAttribute), true).Length > 0);
  481. }
  482. public static object Metatext(string text)
  483. {
  484. return new LINQPad.ObjectGraph.Metatext(text);
  485. }
  486. public static object RawHtml(string xhtml)
  487. {
  488. object obj2;
  489. try
  490. {
  491. obj2 = RawHtml(XElement.Parse(xhtml));
  492. }
  493. catch
  494. {
  495. try
  496. {
  497. obj2 = RawHtml(XElement.Parse("<div>" + xhtml + "</div>"));
  498. }
  499. catch (Exception exception)
  500. {
  501. obj2 = RawHtml(new XElement("i", "Cannot parse custom HTML: '" + xhtml + "' - '" + exception.Message));
  502. }
  503. }
  504. return obj2;
  505. }
  506. public static object RawHtml(XElement xhtmlNode)
  507. {
  508. return new LINQPad.ObjectGraph.RawHtml(xhtmlNode);
  509. }
  510. public static TResult ReadLine<TResult>()
  511. {
  512. return ReadLine<TResult>(null);
  513. }
  514. public static string ReadLine()
  515. {
  516. return ReadLine(null, null);
  517. }
  518. public static TResult ReadLine<TResult>(string prompt)
  519. {
  520. return TryReadLine<TResult>(prompt, false, default(TResult), null);
  521. }
  522. public static string ReadLine(string prompt)
  523. {
  524. return ReadLine(prompt, null);
  525. }
  526. public static TResult ReadLine<TResult>(string prompt, TResult defaultValue)
  527. {
  528. return TryReadLine<TResult>(prompt, true, defaultValue, null);
  529. }
  530. public static string ReadLine(string prompt, string defaultValue)
  531. {
  532. return ReadLine(prompt, defaultValue, null);
  533. }
  534. public static TResult ReadLine<TResult>(string prompt, TResult defaultValue, IEnumerable<TResult> suggestions)
  535. {
  536. return TryReadLine<TResult>(prompt, true, defaultValue, suggestions);
  537. }
  538. public static string ReadLine(string prompt, string defaultValue, IEnumerable<string> suggestions)
  539. {
  540. if (Server.CurrentServer == null)
  541. {
  542. return Console.ReadLine();
  543. }
  544. return Server.CurrentServer.ReadLine(prompt, defaultValue, suggestions);
  545. }
  546. public static string ReadSampleTextFile(string sampleLibraryName, string fileName)
  547. {
  548. return File.ReadAllText(GetSampleFilePath(sampleLibraryName, fileName));
  549. }
  550. public static void SetPassword(string name, string password)
  551. {
  552. PasswordManager.SetPassword(name, password);
  553. }
  554. private static TResult TryReadLine<TResult>(string prompt, bool hasDefault, TResult defaultValue, IEnumerable<TResult> suggestions)
  555. {
  556. // This item is obfuscated and can not be translated.
  557. Func<string, TResult> func2;
  558. string str2;
  559. Func<string, TResult> func = null;
  560. Func<TResult, string> toString;
  561. bool flag = false;
  562. Type t = typeof(TResult);
  563. if (flag = t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(Nullable<>)))
  564. {
  565. t = t.GetGenericArguments()[0];
  566. }
  567. TypeConverter typeConverter = null;
  568. TypeCode typeCode = Type.GetTypeCode(t);
  569. if (t.IsEnum)
  570. {
  571. func2 = s => (TResult) Enum.Parse(t, s, true);
  572. }
  573. else if ((typeCode != TypeCode.Empty) && (typeCode != TypeCode.Object))
  574. {
  575. func2 = s => (TResult) Convert.ChangeType(s, t);
  576. }
  577. else if (t == typeof(TimeSpan))
  578. {
  579. func2 = s => (TResult) TimeSpan.Parse(s);
  580. }
  581. else if (t == typeof(DateTimeOffset))
  582. {
  583. func2 = s => (TResult) DateTimeOffset.Parse(s);
  584. }
  585. else
  586. {
  587. typeConverter = TypeDescriptor.GetConverter(t);
  588. if (!((typeConverter != null) && typeConverter.CanConvertFrom(typeof(string))))
  589. {
  590. throw new InvalidOperationException("No type converter available to convert from string to " + t.FormatTypeName() + ".");
  591. }
  592. if (func == null)
  593. {
  594. func = s => (TResult) typeConverter.ConvertFromString(s);
  595. }
  596. func2 = func;
  597. }
  598. if (typeConverter != null)
  599. {
  600. toString = x => typeConverter.ConvertToString(x);
  601. }
  602. else
  603. {
  604. toString = x => (x == null) ? null : x.ToString();
  605. }
  606. string str = null;
  607. if (hasDefault)
  608. {
  609. str = toString(defaultValue);
  610. }
  611. IEnumerable<string> names = null;
  612. if (suggestions != null)
  613. {
  614. names = (from c in suggestions
  615. select toString(c) into s
  616. where s != null
  617. select s).Distinct<string>();
  618. }
  619. else if (t.IsEnum)
  620. {
  621. names = Enum.GetNames(t);
  622. }
  623. else if (t == typeof(bool))
  624. {
  625. names = "false true".Split(new char[0]);
  626. }
  627. goto Label_02A0;
  628. Label_0241:
  629. if (1 == 0)
  630. {
  631. return default(TResult);
  632. }
  633. try
  634. {
  635. return func2(str2);
  636. }
  637. catch (Exception exception)
  638. {
  639. MessageBox.Show("Cannot convert from string to " + t.FormatTypeName() + ".\r\n" + exception.Message, "LINQPad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  640. goto Label_02A0;
  641. }
  642. Label_0283:;
  643. goto Label_0241;
  644. Label_02A0:
  645. str2 = str = ReadLine(prompt, str, names);
  646. if (!flag)
  647. {
  648. goto Label_0241;
  649. }
  650. goto Label_0283;
  651. }
  652. internal static void UnloadAppDomain(AppDomain d)
  653. {
  654. UnloadAppDomain(d, 3);
  655. }
  656. internal static void UnloadAppDomain(AppDomain d, int attempts)
  657. {
  658. for (int i = 0; i < attempts; i++)
  659. {
  660. if (i > 0)
  661. {
  662. Thread.Sleep((int) (100 * i));
  663. }
  664. try
  665. {
  666. AppDomain.Unload(d);
  667. return;
  668. }
  669. catch (AppDomainUnloadedException)
  670. {
  671. return;
  672. }
  673. catch (CannotUnloadAppDomainException)
  674. {
  675. }
  676. }
  677. Log.Write("Cannot unload app domain - terminal");
  678. }
  679. public static object VerticalRun(IEnumerable elements)
  680. {
  681. return new LINQPad.ObjectGraph.VerticalRun(elements);
  682. }
  683. public static object VerticalRun(params object[] elements)
  684. {
  685. return new LINQPad.ObjectGraph.VerticalRun(elements);
  686. }
  687. public static object WordRun(bool withGaps, params object[] elements)
  688. {
  689. return new LINQPad.ObjectGraph.WordRun(withGaps, elements);
  690. }
  691. public static object WordRun(bool withGaps, IEnumerable elements)
  692. {
  693. return new LINQPad.ObjectGraph.WordRun(withGaps, elements);
  694. }
  695. public static bool? AutoScrollResults
  696. {
  697. [CompilerGenerated]
  698. get
  699. {
  700. return <AutoScrollResults>k__BackingField;
  701. }
  702. [CompilerGenerated]
  703. set
  704. {
  705. <AutoScrollResults>k__BackingField = value;
  706. }
  707. }
  708. internal static string CurrentQueryName
  709. {
  710. [CompilerGenerated]
  711. get
  712. {
  713. return <CurrentQueryName>k__BackingField;
  714. }
  715. [CompilerGenerated]
  716. set
  717. {
  718. <CurrentQueryName>k__BackingField = value;
  719. }
  720. }
  721. public static string CurrentQueryPath
  722. {
  723. [CompilerGenerated]
  724. get
  725. {
  726. return <CurrentQueryPath>k__BackingField;
  727. }
  728. [CompilerGenerated]
  729. internal set
  730. {
  731. <CurrentQueryPath>k__BackingField = value;
  732. }
  733. }
  734. public static int? Progress
  735. {
  736. get
  737. {
  738. return _progressPercent;
  739. }
  740. set
  741. {
  742. if (_progressPercent != value)
  743. {
  744. int? nullable3 = value;
  745. if (nullable3.HasValue)
  746. {
  747. if (nullable3 < 0)
  748. {
  749. nullable3 = 0;
  750. }
  751. if (nullable3 > 100)
  752. {
  753. nullable3 = 100;
  754. }
  755. }
  756. _progressPercent = nullable3;
  757. }
  758. }
  759. }
  760. public static TextWriter SqlOutputWriter
  761. {
  762. get
  763. {
  764. return LINQPadDbController.SqlLog;
  765. }
  766. }
  767. private class LifeExtensionToken : IDisposable
  768. {
  769. private Action _onDispose;
  770. internal LifeExtensionToken(Action onDispose)
  771. {
  772. this._onDispose = onDispose;
  773. }
  774. public void Dispose()
  775. {
  776. Action action = this._onDispose;
  777. this._onDispose = null;
  778. if (action != null)
  779. {
  780. action();
  781. }
  782. }
  783. }
  784. }
  785. }