OutputDataWrapper.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. using MuchInfo.Chart.Data.Interfaces;
  2. using MuchInfo.Chart.WPF.Helpers;
  3. using MuchInfo.Chart.WPF.Primitives.Interfaces;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.Runtime.CompilerServices;
  8. using System.Threading;
  9. namespace MuchInfo.Chart.WPF.Primitives
  10. {
  11. public class OutputDataWrapper : ILineDataSetWithUid, IDeletable
  12. {
  13. private static List<WeakReference> OutputDataWrapper_503 = new List<WeakReference>();
  14. private ILineDataSet OutputDataWrapper_504;
  15. /// <summary>
  16. /// NewGuid
  17. /// </summary>
  18. private Guid OutputDataWrapper_505;
  19. private LineDataSetDataChangedEventHandler OutputDataWrapper_506;
  20. public event LineDataSetDataChangedEventHandler DataChanged
  21. {
  22. add
  23. {
  24. this.OutputDataWrapper_506 = (LineDataSetDataChangedEventHandler)Delegate.Combine(this.OutputDataWrapper_506, value);
  25. }
  26. remove
  27. {
  28. this.OutputDataWrapper_506 = (LineDataSetDataChangedEventHandler)Delegate.Remove(this.OutputDataWrapper_506, value);
  29. }
  30. }
  31. public virtual ILineDataSet mDat
  32. {
  33. get
  34. {
  35. return this.OutputDataWrapper_504;
  36. }
  37. [MethodImpl(32)]
  38. set
  39. {
  40. LineDataSetDataChangedEventHandler dataChangedEventHandler = new LineDataSetDataChangedEventHandler(this.OutputDataWrapper_2184);
  41. bool flag = this.OutputDataWrapper_504 != null;
  42. if (flag)
  43. {
  44. this.OutputDataWrapper_504.DataChanged -= (dataChangedEventHandler);
  45. }
  46. this.OutputDataWrapper_504 = value;
  47. flag = (this.OutputDataWrapper_504 != null);
  48. if (flag)
  49. {
  50. this.OutputDataWrapper_504.DataChanged += (dataChangedEventHandler);
  51. }
  52. }
  53. }
  54. internal Guid DataGUID
  55. {
  56. get
  57. {
  58. return this.OutputDataWrapper_505;
  59. }
  60. set
  61. {
  62. this.OutputDataWrapper_505 = value;
  63. }
  64. }
  65. [DebuggerNonUserCode]
  66. private static void OutputDataWrapper_2173(object value)
  67. {
  68. List<WeakReference> outputDataWrapper_ = OutputDataWrapper.OutputDataWrapper_503;
  69. Monitor.Enter(outputDataWrapper_);
  70. checked
  71. {
  72. try
  73. {
  74. bool flag = OutputDataWrapper.OutputDataWrapper_503.Count == OutputDataWrapper.OutputDataWrapper_503.Capacity;
  75. if (flag)
  76. {
  77. int num = 0;
  78. int arg_51_0 = 0;
  79. int num2 = OutputDataWrapper.OutputDataWrapper_503.Count - 1;
  80. int num3 = arg_51_0;
  81. while (true)
  82. {
  83. int arg_A2_0 = num3;
  84. int num4 = num2;
  85. if (arg_A2_0 > num4)
  86. {
  87. break;
  88. }
  89. WeakReference weakReference = OutputDataWrapper.OutputDataWrapper_503[num3];
  90. flag = weakReference.IsAlive;
  91. if (flag)
  92. {
  93. bool flag2 = num3 != num;
  94. if (flag2)
  95. {
  96. OutputDataWrapper.OutputDataWrapper_503[num] = (OutputDataWrapper.OutputDataWrapper_503[num3]);
  97. }
  98. num++;
  99. }
  100. num3++;
  101. }
  102. OutputDataWrapper.OutputDataWrapper_503.RemoveRange(num, OutputDataWrapper.OutputDataWrapper_503.Count - num);
  103. OutputDataWrapper.OutputDataWrapper_503.Capacity = (OutputDataWrapper.OutputDataWrapper_503.Count);
  104. }
  105. OutputDataWrapper.OutputDataWrapper_503.Add(new WeakReference(RuntimeHelpers.GetObjectValue(value)));
  106. }
  107. finally
  108. {
  109. Monitor.Exit(outputDataWrapper_);
  110. }
  111. }
  112. }
  113. public OutputDataWrapper()
  114. {
  115. OutputDataWrapper.OutputDataWrapper_2173(this);
  116. this.OutputDataWrapper_505 = Guid.NewGuid();
  117. }
  118. internal void OutputDataWrapper_2177(ILineDataSet dat)
  119. {
  120. this.mDat = dat;
  121. LineDataSetDataChangedEventHandler outputDataWrapper_ = this.OutputDataWrapper_506;
  122. bool flag = outputDataWrapper_ != null;
  123. if (flag)
  124. {
  125. outputDataWrapper_(null);
  126. }
  127. }
  128. /// <summary>
  129. /// 返回mDat
  130. /// </summary>
  131. /// <returns></returns>
  132. internal ILineDataSet OutputDataWrapper_2180()
  133. {
  134. return this.mDat;
  135. }
  136. public List<ILineDataPoint> Data()
  137. {
  138. bool flag = this.mDat != null;
  139. List<ILineDataPoint> result;
  140. if (flag)
  141. {
  142. result = this.mDat.DataPoints;
  143. }
  144. else
  145. {
  146. result = null;
  147. }
  148. return result;
  149. }
  150. private void OutputDataWrapper_2184(object Change)
  151. {
  152. LineDataSetDataChangedEventHandler outputDataWrapper_ = this.OutputDataWrapper_506;
  153. bool flag = outputDataWrapper_ != null;
  154. if (flag)
  155. {
  156. outputDataWrapper_(null);
  157. }
  158. }
  159. internal void OutputDataWrapper_2185()
  160. {
  161. LineDataSetDataChangedEventHandler outputDataWrapper_ = this.OutputDataWrapper_506;
  162. bool flag = outputDataWrapper_ != null;
  163. if (flag)
  164. {
  165. outputDataWrapper_(new PlotDeletingDataChange());
  166. }
  167. }
  168. public string UID()
  169. {
  170. return this.OutputDataWrapper_505.ToString();
  171. }
  172. public void OnDelete()
  173. {
  174. this.mDat = null;
  175. }
  176. string ILineDataSetWithUid.UID()
  177. {
  178. throw new NotImplementedException();
  179. }
  180. event LineDataSetDataChangedEventHandler ILineDataSet.DataChanged
  181. {
  182. add { throw new NotImplementedException(); }
  183. remove { throw new NotImplementedException(); }
  184. }
  185. List<ILineDataPoint> ILineDataSet.DataPoints
  186. {
  187. get
  188. {
  189. return Data();
  190. }
  191. set
  192. {
  193. this.mDat.DataPoints = value;
  194. }
  195. }
  196. void IDeletable.OnDelete()
  197. {
  198. throw new NotImplementedException();
  199. }
  200. }
  201. }