XmlSerializer.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. //
  2. // XmlSerializer.cs:
  3. //
  4. // Author:
  5. // Lluis Sanchez Gual ([email protected])
  6. //
  7. // (C) 2002, 2003 Ximian, Inc. http://www.ximian.com
  8. //
  9. //
  10. // Permission is hereby granted, free of charge, to any person obtaining
  11. // a copy of this software and associated documentation files (the
  12. // "Software"), to deal in the Software without restriction, including
  13. // without limitation the rights to use, copy, modify, merge, publish,
  14. // distribute, sublicense, and/or sell copies of the Software, and to
  15. // permit persons to whom the Software is furnished to do so, subject to
  16. // the following conditions:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  21. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  25. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  26. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  27. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28. //
  29. using System;
  30. using System.Threading;
  31. using System.Collections;
  32. using System.Globalization;
  33. using System.IO;
  34. using System.Reflection;
  35. using System.Xml;
  36. using System.Xml.Schema;
  37. using System.Text;
  38. using System.CodeDom;
  39. using System.CodeDom.Compiler;
  40. using Microsoft.CSharp;
  41. using System.Configuration;
  42. using System.Security.Policy;
  43. namespace System.Xml.Serialization
  44. {
  45. public class XmlSerializer
  46. {
  47. internal const string WsdlNamespace = "http://schemas.xmlsoap.org/wsdl/";
  48. internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
  49. static int generationThreshold;
  50. static bool backgroundGeneration = true;
  51. static bool deleteTempFiles = true;
  52. bool customSerializer;
  53. XmlMapping typeMapping;
  54. SerializerData serializerData;
  55. Type writerType;
  56. Type readerType;
  57. static Hashtable serializerTypes = new Hashtable ();
  58. internal class SerializerData
  59. {
  60. public int UsageCount;
  61. public Type ReaderType;
  62. public MethodInfo ReaderMethod;
  63. public Type WriterType;
  64. public MethodInfo WriterMethod;
  65. public GenerationBatch Batch;
  66. public IXmlSerializerImplementation Implementation;
  67. public XmlSerializationReader CreateReader () {
  68. if (ReaderType != null)
  69. return (XmlSerializationReader) Activator.CreateInstance (ReaderType);
  70. else if (Implementation != null)
  71. return Implementation.Reader;
  72. else
  73. return null;
  74. }
  75. public XmlSerializationWriter CreateWriter () {
  76. if (WriterType != null)
  77. return (XmlSerializationWriter) Activator.CreateInstance (WriterType);
  78. else if (Implementation != null)
  79. return Implementation.Writer;
  80. else
  81. return null;
  82. }
  83. }
  84. internal class GenerationBatch
  85. {
  86. public bool Done;
  87. public XmlMapping[] Maps;
  88. public SerializerData[] Datas;
  89. }
  90. static XmlSerializer ()
  91. {
  92. string db = Environment.GetEnvironmentVariable ("MONO_XMLSERIALIZER_DEBUG");
  93. deleteTempFiles = (db == null || db == "no");
  94. IDictionary table = (IDictionary) ConfigurationSettings.GetConfig("system.diagnostics");
  95. if (table != null) {
  96. table = (IDictionary) table["switches"];
  97. if (table != null) {
  98. string val = (string) table ["XmlSerialization.Compilation"];
  99. if (val == "1") deleteTempFiles = false;
  100. }
  101. }
  102. string th = Environment.GetEnvironmentVariable ("MONO_XMLSERIALIZER_THS");
  103. if (th == null) {
  104. generationThreshold = 50;
  105. backgroundGeneration = true;
  106. }
  107. else if (th.ToLower(CultureInfo.InvariantCulture) == "no")
  108. generationThreshold = -1;
  109. else {
  110. generationThreshold = int.Parse (th, CultureInfo.InvariantCulture);
  111. backgroundGeneration = (generationThreshold != 0);
  112. if (generationThreshold < 1) generationThreshold = 1;
  113. }
  114. }
  115. #region Constructors
  116. protected XmlSerializer ()
  117. {
  118. customSerializer = true;
  119. }
  120. public XmlSerializer (Type type)
  121. : this (type, null, null, null, null)
  122. {
  123. }
  124. public XmlSerializer (XmlTypeMapping xmlTypeMapping)
  125. {
  126. typeMapping = xmlTypeMapping;
  127. }
  128. internal XmlSerializer (XmlMapping mapping, SerializerData data)
  129. {
  130. typeMapping = mapping;
  131. serializerData = data;
  132. }
  133. public XmlSerializer (Type type, string defaultNamespace)
  134. : this (type, null, null, null, defaultNamespace)
  135. {
  136. }
  137. public XmlSerializer (Type type, Type[] extraTypes)
  138. : this (type, null, extraTypes, null, null)
  139. {
  140. }
  141. public XmlSerializer (Type type, XmlAttributeOverrides overrides)
  142. : this (type, overrides, null, null, null)
  143. {
  144. }
  145. public XmlSerializer (Type type, XmlRootAttribute root)
  146. : this (type, null, null, root, null)
  147. {
  148. }
  149. public XmlSerializer (Type type,
  150. XmlAttributeOverrides overrides,
  151. Type [] extraTypes,
  152. XmlRootAttribute root,
  153. string defaultNamespace)
  154. {
  155. if (type == null)
  156. throw new ArgumentNullException ("type");
  157. XmlReflectionImporter importer = new XmlReflectionImporter (overrides, defaultNamespace);
  158. if (extraTypes != null)
  159. {
  160. foreach (Type intype in extraTypes)
  161. importer.IncludeType (intype);
  162. }
  163. typeMapping = importer.ImportTypeMapping (type, root, defaultNamespace);
  164. }
  165. internal XmlMapping Mapping
  166. {
  167. get { return typeMapping; }
  168. }
  169. #if NET_2_0
  170. [MonoTODO]
  171. public XmlSerializer (Type type,
  172. XmlAttributeOverrides overrides,
  173. Type [] extraTypes,
  174. XmlRootAttribute root,
  175. string defaultNamespace,
  176. string location,
  177. Evidence evidence)
  178. {
  179. }
  180. #endif
  181. #endregion // Constructors
  182. #region Events
  183. private XmlAttributeEventHandler onUnknownAttribute;
  184. private XmlElementEventHandler onUnknownElement;
  185. private XmlNodeEventHandler onUnknownNode;
  186. private UnreferencedObjectEventHandler onUnreferencedObject;
  187. public event XmlAttributeEventHandler UnknownAttribute
  188. {
  189. add { onUnknownAttribute += value; } remove { onUnknownAttribute -= value; }
  190. }
  191. public event XmlElementEventHandler UnknownElement
  192. {
  193. add { onUnknownElement += value; } remove { onUnknownElement -= value; }
  194. }
  195. public event XmlNodeEventHandler UnknownNode
  196. {
  197. add { onUnknownNode += value; } remove { onUnknownNode -= value; }
  198. }
  199. public event UnreferencedObjectEventHandler UnreferencedObject
  200. {
  201. add { onUnreferencedObject += value; } remove { onUnreferencedObject -= value; }
  202. }
  203. internal virtual void OnUnknownAttribute (XmlAttributeEventArgs e)
  204. {
  205. if (onUnknownAttribute != null) onUnknownAttribute(this, e);
  206. }
  207. internal virtual void OnUnknownElement (XmlElementEventArgs e)
  208. {
  209. if (onUnknownElement != null) onUnknownElement(this, e);
  210. }
  211. internal virtual void OnUnknownNode (XmlNodeEventArgs e)
  212. {
  213. if (onUnknownNode != null) onUnknownNode(this, e);
  214. }
  215. internal virtual void OnUnreferencedObject (UnreferencedObjectEventArgs e)
  216. {
  217. if (onUnreferencedObject != null) onUnreferencedObject(this, e);
  218. }
  219. #endregion // Events
  220. #region Methods
  221. public virtual bool CanDeserialize (XmlReader xmlReader)
  222. {
  223. xmlReader.MoveToContent ();
  224. if (typeMapping is XmlMembersMapping)
  225. return true;
  226. else
  227. return ((XmlTypeMapping)typeMapping).ElementName == xmlReader.LocalName;
  228. }
  229. protected virtual XmlSerializationReader CreateReader ()
  230. {
  231. // Must be implemented in derived class
  232. throw new NotImplementedException ();
  233. }
  234. protected virtual XmlSerializationWriter CreateWriter ()
  235. {
  236. // Must be implemented in derived class
  237. throw new NotImplementedException ();
  238. }
  239. public object Deserialize (Stream stream)
  240. {
  241. XmlTextReader xmlReader = new XmlTextReader(stream);
  242. return Deserialize(xmlReader);
  243. }
  244. public object Deserialize (TextReader textReader)
  245. {
  246. XmlTextReader xmlReader = new XmlTextReader(textReader);
  247. return Deserialize(xmlReader);
  248. }
  249. public object Deserialize (XmlReader xmlReader)
  250. {
  251. XmlSerializationReader xsReader;
  252. if (customSerializer)
  253. xsReader = CreateReader ();
  254. else
  255. xsReader = CreateReader (typeMapping);
  256. xsReader.Initialize (xmlReader, this);
  257. return Deserialize (xsReader);
  258. }
  259. protected virtual object Deserialize (XmlSerializationReader reader)
  260. {
  261. if (customSerializer)
  262. // Must be implemented in derived class
  263. throw new NotImplementedException ();
  264. if (reader is XmlSerializationReaderInterpreter)
  265. return ((XmlSerializationReaderInterpreter)reader).ReadRoot ();
  266. else
  267. return serializerData.ReaderMethod.Invoke (reader, null);
  268. }
  269. public static XmlSerializer [] FromMappings (XmlMapping [] mappings)
  270. {
  271. XmlSerializer[] sers = new XmlSerializer [mappings.Length];
  272. SerializerData[] datas = new SerializerData [mappings.Length];
  273. GenerationBatch batch = new GenerationBatch ();
  274. batch.Maps = mappings;
  275. batch.Datas = datas;
  276. for (int n=0; n<mappings.Length; n++)
  277. {
  278. if (mappings[n] != null)
  279. {
  280. SerializerData data = new SerializerData ();
  281. data.Batch = batch;
  282. sers[n] = new XmlSerializer (mappings[n], data);
  283. datas[n] = data;
  284. }
  285. }
  286. return sers;
  287. }
  288. public static XmlSerializer [] FromTypes (Type [] mappings)
  289. {
  290. XmlSerializer [] sers = new XmlSerializer [mappings.Length];
  291. for (int n=0; n<mappings.Length; n++)
  292. sers[n] = new XmlSerializer (mappings[n]);
  293. return sers;
  294. }
  295. protected virtual void Serialize (object o, XmlSerializationWriter writer)
  296. {
  297. if (customSerializer)
  298. // Must be implemented in derived class
  299. throw new NotImplementedException ();
  300. if (writer is XmlSerializationWriterInterpreter)
  301. ((XmlSerializationWriterInterpreter)writer).WriteRoot (o);
  302. else
  303. serializerData.WriterMethod.Invoke (writer, new object[] {o});
  304. }
  305. public void Serialize (Stream stream, object o)
  306. {
  307. XmlTextWriter xmlWriter = new XmlTextWriter (stream, System.Text.Encoding.Default);
  308. xmlWriter.Formatting = Formatting.Indented;
  309. Serialize (xmlWriter, o, null);
  310. }
  311. public void Serialize (TextWriter textWriter, object o)
  312. {
  313. XmlTextWriter xmlWriter = new XmlTextWriter (textWriter);
  314. xmlWriter.Formatting = Formatting.Indented;
  315. Serialize (xmlWriter, o, null);
  316. }
  317. public void Serialize (XmlWriter xmlWriter, object o)
  318. {
  319. Serialize (xmlWriter, o, null);
  320. }
  321. public void Serialize (Stream stream, object o, XmlSerializerNamespaces namespaces)
  322. {
  323. XmlTextWriter xmlWriter = new XmlTextWriter (stream, System.Text.Encoding.Default);
  324. xmlWriter.Formatting = Formatting.Indented;
  325. Serialize (xmlWriter, o, namespaces);
  326. }
  327. public void Serialize (TextWriter textWriter, object o, XmlSerializerNamespaces namespaces)
  328. {
  329. XmlTextWriter xmlWriter = new XmlTextWriter (textWriter);
  330. xmlWriter.Formatting = Formatting.Indented;
  331. Serialize (xmlWriter, o, namespaces);
  332. xmlWriter.Flush();
  333. }
  334. public void Serialize (XmlWriter writer, object o, XmlSerializerNamespaces namespaces)
  335. {
  336. XmlSerializationWriter xsWriter;
  337. if (customSerializer)
  338. xsWriter = CreateWriter ();
  339. else
  340. xsWriter = CreateWriter (typeMapping);
  341. if (namespaces == null || namespaces.Count == 0)
  342. {
  343. namespaces = new XmlSerializerNamespaces ();
  344. namespaces.Add ("xsd", XmlSchema.Namespace);
  345. namespaces.Add ("xsi", XmlSchema.InstanceNamespace);
  346. }
  347. xsWriter.Initialize (writer, namespaces);
  348. Serialize (o, xsWriter);
  349. writer.Flush ();
  350. }
  351. #if NET_2_0
  352. [MonoTODO]
  353. public object Deserialize (XmlReader xmlReader, string encodingStyle, XmlDeserializationEvents events)
  354. {
  355. throw new NotImplementedException ();
  356. }
  357. [MonoTODO]
  358. public object Deserialize (XmlReader xmlReader, string encodingStyle)
  359. {
  360. throw new NotImplementedException ();
  361. }
  362. [MonoTODO]
  363. public object Deserialize (XmlReader xmlReader, XmlDeserializationEvents events)
  364. {
  365. throw new NotImplementedException ();
  366. }
  367. [MonoTODO]
  368. public static XmlSerializer[] FromMappings (XmlMapping[] mappings, Evidence evidence)
  369. {
  370. throw new NotImplementedException ();
  371. }
  372. [MonoTODO]
  373. public static XmlSerializer[] FromMappings (XmlMapping[] mappings, Type type)
  374. {
  375. throw new NotImplementedException ();
  376. }
  377. public static Assembly GenerateSerializer (Type[] types, XmlMapping[] mappings)
  378. {
  379. return GenerateSerializer (types, mappings, null);
  380. }
  381. [MonoTODO]
  382. public static Assembly GenerateSerializer (Type[] types, XmlMapping[] mappings, CompilerParameters parameters)
  383. {
  384. GenerationBatch batch = new GenerationBatch ();
  385. batch.Maps = mappings;
  386. batch.Datas = new SerializerData [mappings.Length];
  387. for (int n=0; n<mappings.Length; n++) {
  388. SerializerData data = new SerializerData ();
  389. data.Batch = batch;
  390. batch.Datas [n] = data;
  391. }
  392. return GenerateSerializers (batch, parameters);
  393. }
  394. [MonoTODO]
  395. public static Assembly GenerateSerializer (Type[] types,
  396. XmlMapping[] mappings,
  397. string codePath,
  398. bool debug,
  399. bool keepFiles)
  400. {
  401. throw new NotImplementedException ();
  402. }
  403. [MonoTODO]
  404. public static Assembly GenerateSerializer (Type[] types,
  405. XmlMapping[] mappings,
  406. string codePath,
  407. bool debug,
  408. bool keepFiles,
  409. string compilerOptions)
  410. {
  411. throw new NotImplementedException ();
  412. }
  413. public static string GetXmlSerializerAssemblyName (Type type)
  414. {
  415. return type.Assembly.GetName().Name + ".XmlSerializers";
  416. }
  417. public static string GetXmlSerializerAssemblyName (Type type, string defaultNamespace)
  418. {
  419. return GetXmlSerializerAssemblyName (type) + "." + defaultNamespace.GetHashCode ();
  420. }
  421. [MonoTODO]
  422. public void Serialize (XmlWriter xmlWriter, object o, XmlSerializerNamespaces namespaces, string encodingStyle)
  423. {
  424. throw new NotImplementedException ();
  425. }
  426. #endif
  427. XmlSerializationWriter CreateWriter (XmlMapping typeMapping)
  428. {
  429. XmlSerializationWriter writer;
  430. lock (this) {
  431. if (serializerData != null) {
  432. writer = serializerData.CreateWriter ();
  433. if (writer != null) return writer;
  434. }
  435. }
  436. if (!typeMapping.Source.CanBeGenerated || generationThreshold == -1)
  437. return new XmlSerializationWriterInterpreter (typeMapping);
  438. CheckGeneratedTypes (typeMapping);
  439. lock (this) {
  440. writer = serializerData.CreateWriter ();
  441. if (writer != null) return writer;
  442. }
  443. return new XmlSerializationWriterInterpreter (typeMapping);
  444. }
  445. XmlSerializationReader CreateReader (XmlMapping typeMapping)
  446. {
  447. XmlSerializationReader reader;
  448. lock (this) {
  449. if (serializerData != null) {
  450. reader = serializerData.CreateReader ();
  451. if (reader != null) return reader;
  452. }
  453. }
  454. if (!typeMapping.Source.CanBeGenerated || generationThreshold == -1)
  455. return new XmlSerializationReaderInterpreter (typeMapping);
  456. CheckGeneratedTypes (typeMapping);
  457. lock (this) {
  458. reader = serializerData.CreateReader ();
  459. if (reader != null) return reader;
  460. }
  461. return new XmlSerializationReaderInterpreter (typeMapping);
  462. }
  463. void CheckGeneratedTypes (XmlMapping typeMapping)
  464. {
  465. lock (this)
  466. {
  467. if (serializerData == null)
  468. {
  469. lock (serializerTypes)
  470. {
  471. serializerData = (SerializerData) serializerTypes [typeMapping.Source];
  472. if (serializerData == null) {
  473. serializerData = new SerializerData();
  474. serializerTypes [typeMapping.Source] = serializerData;
  475. }
  476. }
  477. }
  478. }
  479. bool generate = false;
  480. lock (serializerData)
  481. {
  482. generate = (++serializerData.UsageCount == generationThreshold);
  483. }
  484. if (generate)
  485. {
  486. if (serializerData.Batch != null)
  487. GenerateSerializersAsync (serializerData.Batch);
  488. else
  489. {
  490. GenerationBatch batch = new GenerationBatch ();
  491. batch.Maps = new XmlMapping[] {typeMapping};
  492. batch.Datas = new SerializerData[] {serializerData};
  493. GenerateSerializersAsync (batch);
  494. }
  495. }
  496. }
  497. void GenerateSerializersAsync (GenerationBatch batch)
  498. {
  499. if (batch.Maps.Length != batch.Datas.Length)
  500. throw new ArgumentException ("batch");
  501. lock (batch)
  502. {
  503. if (batch.Done) return;
  504. batch.Done = true;
  505. }
  506. if (backgroundGeneration)
  507. ThreadPool.QueueUserWorkItem (new WaitCallback (RunSerializerGeneration), batch);
  508. else
  509. RunSerializerGeneration (batch);
  510. }
  511. void RunSerializerGeneration (object obj)
  512. {
  513. try
  514. {
  515. GenerationBatch batch = (GenerationBatch) obj;
  516. batch = LoadFromSatelliteAssembly (batch);
  517. if (batch != null)
  518. GenerateSerializers (batch, null);
  519. }
  520. catch (Exception ex)
  521. {
  522. Console.WriteLine (ex);
  523. }
  524. }
  525. static Assembly GenerateSerializers (GenerationBatch batch, CompilerParameters cp)
  526. {
  527. DateTime tim = DateTime.Now;
  528. XmlMapping[] maps = batch.Maps;
  529. if (cp == null) {
  530. cp = new CompilerParameters();
  531. cp.IncludeDebugInformation = false;
  532. cp.GenerateInMemory = true;
  533. cp.TempFiles.KeepFiles = !deleteTempFiles;
  534. }
  535. string file = cp.TempFiles.AddExtension ("cs");
  536. StreamWriter sw = new StreamWriter (file);
  537. if (!deleteTempFiles)
  538. Console.WriteLine ("Generating " + file);
  539. SerializationCodeGenerator gen = new SerializationCodeGenerator (maps);
  540. try
  541. {
  542. gen.GenerateSerializers (sw);
  543. }
  544. catch (Exception ex)
  545. {
  546. Console.WriteLine ("Serializer could not be generated");
  547. Console.WriteLine (ex);
  548. cp.TempFiles.Delete ();
  549. return null;
  550. }
  551. sw.Close ();
  552. CSharpCodeProvider provider = new CSharpCodeProvider();
  553. ICodeCompiler comp = provider.CreateCompiler ();
  554. cp.GenerateExecutable = false;
  555. foreach (Type rtype in gen.ReferencedTypes)
  556. {
  557. if (!cp.ReferencedAssemblies.Contains (rtype.Assembly.Location))
  558. cp.ReferencedAssemblies.Add (rtype.Assembly.Location);
  559. }
  560. if (!cp.ReferencedAssemblies.Contains ("System.dll"))
  561. cp.ReferencedAssemblies.Add ("System.dll");
  562. if (!cp.ReferencedAssemblies.Contains ("System.Xml"))
  563. cp.ReferencedAssemblies.Add ("System.Xml");
  564. if (!cp.ReferencedAssemblies.Contains ("System.Data"))
  565. cp.ReferencedAssemblies.Add ("System.Data");
  566. CompilerResults res = comp.CompileAssemblyFromFile (cp, file);
  567. if (res.Errors.Count > 0)
  568. {
  569. Console.WriteLine ("Error while compiling generated serializer");
  570. foreach (CompilerError error in res.Errors)
  571. Console.WriteLine (error);
  572. cp.TempFiles.Delete ();
  573. return null;
  574. }
  575. GenerationResult[] results = gen.GenerationResults;
  576. for (int n=0; n<results.Length; n++)
  577. {
  578. GenerationResult gres = results[n];
  579. SerializerData sd = batch.Datas [n];
  580. lock (sd)
  581. {
  582. sd.WriterType = res.CompiledAssembly.GetType (gres.Namespace + "." + gres.WriterClassName);
  583. sd.ReaderType = res.CompiledAssembly.GetType (gres.Namespace + "." + gres.ReaderClassName);
  584. sd.WriterMethod = sd.WriterType.GetMethod (gres.WriteMethodName);
  585. sd.ReaderMethod = sd.ReaderType.GetMethod (gres.ReadMethodName);
  586. sd.Batch = null;
  587. }
  588. }
  589. cp.TempFiles.Delete ();
  590. if (!deleteTempFiles)
  591. Console.WriteLine ("Generation finished - " + (DateTime.Now - tim).TotalMilliseconds + " ms");
  592. return res.CompiledAssembly;
  593. }
  594. #if NET_2_0
  595. GenerationBatch LoadFromSatelliteAssembly (GenerationBatch batch)
  596. {
  597. }
  598. #else
  599. GenerationBatch LoadFromSatelliteAssembly (GenerationBatch batch)
  600. {
  601. return batch;
  602. }
  603. #endif
  604. #endregion // Methods
  605. }
  606. }