Globals.cs 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace System.Runtime.Serialization
  5. {
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Reflection;
  11. using System.Security;
  12. using System.Security.Permissions;
  13. using System.Xml;
  14. using System.Xml.Schema;
  15. using System.Xml.Serialization;
  16. [Fx.Tag.SecurityNote(Critical = "Class holds static instances used in serializer. "
  17. + "Static fields are marked SecurityCritical or readonly to prevent "
  18. + "data from being modified or leaked to other components in appdomain.",
  19. Safe = "All get-only properties marked safe since they only need to be protected for write.")]
  20. static class Globals
  21. {
  22. [Fx.Tag.SecurityNote(Miscellaneous = "RequiresReview - Changes to const could affect code generation logic; any changes should be reviewed.")]
  23. internal const BindingFlags ScanAllMembers = BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
  24. [SecurityCritical]
  25. static XmlQualifiedName idQualifiedName;
  26. internal static XmlQualifiedName IdQualifiedName
  27. {
  28. [SecuritySafeCritical]
  29. get
  30. {
  31. if (idQualifiedName == null)
  32. idQualifiedName = new XmlQualifiedName(Globals.IdLocalName, Globals.SerializationNamespace);
  33. return idQualifiedName;
  34. }
  35. }
  36. [SecurityCritical]
  37. static XmlQualifiedName refQualifiedName;
  38. internal static XmlQualifiedName RefQualifiedName
  39. {
  40. [SecuritySafeCritical]
  41. get
  42. {
  43. if (refQualifiedName == null)
  44. refQualifiedName = new XmlQualifiedName(Globals.RefLocalName, Globals.SerializationNamespace);
  45. return refQualifiedName;
  46. }
  47. }
  48. [SecurityCritical]
  49. static Type typeOfObject;
  50. internal static Type TypeOfObject
  51. {
  52. [SecuritySafeCritical]
  53. get
  54. {
  55. if (typeOfObject == null)
  56. typeOfObject = typeof(object);
  57. return typeOfObject;
  58. }
  59. }
  60. [SecurityCritical]
  61. static Type typeOfValueType;
  62. internal static Type TypeOfValueType
  63. {
  64. [SecuritySafeCritical]
  65. get
  66. {
  67. if (typeOfValueType == null)
  68. typeOfValueType = typeof(ValueType);
  69. return typeOfValueType;
  70. }
  71. }
  72. [SecurityCritical]
  73. static Type typeOfArray;
  74. internal static Type TypeOfArray
  75. {
  76. [SecuritySafeCritical]
  77. get
  78. {
  79. if (typeOfArray == null)
  80. typeOfArray = typeof(Array);
  81. return typeOfArray;
  82. }
  83. }
  84. [SecurityCritical]
  85. static Type typeOfString;
  86. internal static Type TypeOfString
  87. {
  88. [SecuritySafeCritical]
  89. get
  90. {
  91. if (typeOfString == null)
  92. typeOfString = typeof(string);
  93. return typeOfString;
  94. }
  95. }
  96. [SecurityCritical]
  97. static Type typeOfInt;
  98. internal static Type TypeOfInt
  99. {
  100. [SecuritySafeCritical]
  101. get
  102. {
  103. if (typeOfInt == null)
  104. typeOfInt = typeof(int);
  105. return typeOfInt;
  106. }
  107. }
  108. [SecurityCritical]
  109. static Type typeOfULong;
  110. internal static Type TypeOfULong
  111. {
  112. [SecuritySafeCritical]
  113. get
  114. {
  115. if (typeOfULong == null)
  116. typeOfULong = typeof(ulong);
  117. return typeOfULong;
  118. }
  119. }
  120. [SecurityCritical]
  121. static Type typeOfVoid;
  122. internal static Type TypeOfVoid
  123. {
  124. [SecuritySafeCritical]
  125. get
  126. {
  127. if (typeOfVoid == null)
  128. typeOfVoid = typeof(void);
  129. return typeOfVoid;
  130. }
  131. }
  132. [SecurityCritical]
  133. static Type typeOfByteArray;
  134. internal static Type TypeOfByteArray
  135. {
  136. [SecuritySafeCritical]
  137. get
  138. {
  139. if (typeOfByteArray == null)
  140. typeOfByteArray = typeof(byte[]);
  141. return typeOfByteArray;
  142. }
  143. }
  144. [SecurityCritical]
  145. static Type typeOfTimeSpan;
  146. internal static Type TypeOfTimeSpan
  147. {
  148. [SecuritySafeCritical]
  149. get
  150. {
  151. if (typeOfTimeSpan == null)
  152. typeOfTimeSpan = typeof(TimeSpan);
  153. return typeOfTimeSpan;
  154. }
  155. }
  156. [SecurityCritical]
  157. static Type typeOfGuid;
  158. internal static Type TypeOfGuid
  159. {
  160. [SecuritySafeCritical]
  161. get
  162. {
  163. if (typeOfGuid == null)
  164. typeOfGuid = typeof(Guid);
  165. return typeOfGuid;
  166. }
  167. }
  168. [SecurityCritical]
  169. static Type typeOfDateTimeOffset;
  170. internal static Type TypeOfDateTimeOffset
  171. {
  172. [SecuritySafeCritical]
  173. get
  174. {
  175. if (typeOfDateTimeOffset == null)
  176. typeOfDateTimeOffset = typeof(DateTimeOffset);
  177. return typeOfDateTimeOffset;
  178. }
  179. }
  180. [SecurityCritical]
  181. static Type typeOfDateTimeOffsetAdapter;
  182. internal static Type TypeOfDateTimeOffsetAdapter
  183. {
  184. [SecuritySafeCritical]
  185. get
  186. {
  187. if (typeOfDateTimeOffsetAdapter == null)
  188. typeOfDateTimeOffsetAdapter = typeof(DateTimeOffsetAdapter);
  189. return typeOfDateTimeOffsetAdapter;
  190. }
  191. }
  192. [SecurityCritical]
  193. static Type typeOfUri;
  194. internal static Type TypeOfUri
  195. {
  196. [SecuritySafeCritical]
  197. get
  198. {
  199. if (typeOfUri == null)
  200. typeOfUri = typeof(Uri);
  201. return typeOfUri;
  202. }
  203. }
  204. [SecurityCritical]
  205. static Type typeOfTypeEnumerable;
  206. internal static Type TypeOfTypeEnumerable
  207. {
  208. [SecuritySafeCritical]
  209. get
  210. {
  211. if (typeOfTypeEnumerable == null)
  212. typeOfTypeEnumerable = typeof(IEnumerable<Type>);
  213. return typeOfTypeEnumerable;
  214. }
  215. }
  216. [SecurityCritical]
  217. static Type typeOfStreamingContext;
  218. internal static Type TypeOfStreamingContext
  219. {
  220. [SecuritySafeCritical]
  221. get
  222. {
  223. if (typeOfStreamingContext == null)
  224. typeOfStreamingContext = typeof(StreamingContext);
  225. return typeOfStreamingContext;
  226. }
  227. }
  228. [SecurityCritical]
  229. static Type typeOfISerializable;
  230. internal static Type TypeOfISerializable
  231. {
  232. [SecuritySafeCritical]
  233. get
  234. {
  235. if (typeOfISerializable == null)
  236. typeOfISerializable = typeof(ISerializable);
  237. return typeOfISerializable;
  238. }
  239. }
  240. [SecurityCritical]
  241. static Type typeOfIDeserializationCallback;
  242. internal static Type TypeOfIDeserializationCallback
  243. {
  244. [SecuritySafeCritical]
  245. get
  246. {
  247. if (typeOfIDeserializationCallback == null)
  248. typeOfIDeserializationCallback = typeof(IDeserializationCallback);
  249. return typeOfIDeserializationCallback;
  250. }
  251. }
  252. [SecurityCritical]
  253. static Type typeOfIObjectReference;
  254. internal static Type TypeOfIObjectReference
  255. {
  256. [SecuritySafeCritical]
  257. get
  258. {
  259. if (typeOfIObjectReference == null)
  260. typeOfIObjectReference = typeof(IObjectReference);
  261. return typeOfIObjectReference;
  262. }
  263. }
  264. [SecurityCritical]
  265. static Type typeOfXmlFormatClassWriterDelegate;
  266. internal static Type TypeOfXmlFormatClassWriterDelegate
  267. {
  268. [SecuritySafeCritical]
  269. get
  270. {
  271. if (typeOfXmlFormatClassWriterDelegate == null)
  272. typeOfXmlFormatClassWriterDelegate = typeof(XmlFormatClassWriterDelegate);
  273. return typeOfXmlFormatClassWriterDelegate;
  274. }
  275. }
  276. [SecurityCritical]
  277. static Type typeOfXmlFormatCollectionWriterDelegate;
  278. internal static Type TypeOfXmlFormatCollectionWriterDelegate
  279. {
  280. [SecuritySafeCritical]
  281. get
  282. {
  283. if (typeOfXmlFormatCollectionWriterDelegate == null)
  284. typeOfXmlFormatCollectionWriterDelegate = typeof(XmlFormatCollectionWriterDelegate);
  285. return typeOfXmlFormatCollectionWriterDelegate;
  286. }
  287. }
  288. [SecurityCritical]
  289. static Type typeOfXmlFormatClassReaderDelegate;
  290. internal static Type TypeOfXmlFormatClassReaderDelegate
  291. {
  292. [SecuritySafeCritical]
  293. get
  294. {
  295. if (typeOfXmlFormatClassReaderDelegate == null)
  296. typeOfXmlFormatClassReaderDelegate = typeof(XmlFormatClassReaderDelegate);
  297. return typeOfXmlFormatClassReaderDelegate;
  298. }
  299. }
  300. [SecurityCritical]
  301. static Type typeOfXmlFormatCollectionReaderDelegate;
  302. internal static Type TypeOfXmlFormatCollectionReaderDelegate
  303. {
  304. [SecuritySafeCritical]
  305. get
  306. {
  307. if (typeOfXmlFormatCollectionReaderDelegate == null)
  308. typeOfXmlFormatCollectionReaderDelegate = typeof(XmlFormatCollectionReaderDelegate);
  309. return typeOfXmlFormatCollectionReaderDelegate;
  310. }
  311. }
  312. [SecurityCritical]
  313. static Type typeOfXmlFormatGetOnlyCollectionReaderDelegate;
  314. internal static Type TypeOfXmlFormatGetOnlyCollectionReaderDelegate
  315. {
  316. [SecuritySafeCritical]
  317. get
  318. {
  319. if (typeOfXmlFormatGetOnlyCollectionReaderDelegate == null)
  320. typeOfXmlFormatGetOnlyCollectionReaderDelegate = typeof(XmlFormatGetOnlyCollectionReaderDelegate);
  321. return typeOfXmlFormatGetOnlyCollectionReaderDelegate;
  322. }
  323. }
  324. [SecurityCritical]
  325. static Type typeOfKnownTypeAttribute;
  326. internal static Type TypeOfKnownTypeAttribute
  327. {
  328. [SecuritySafeCritical]
  329. get
  330. {
  331. if (typeOfKnownTypeAttribute == null)
  332. typeOfKnownTypeAttribute = typeof(KnownTypeAttribute);
  333. return typeOfKnownTypeAttribute;
  334. }
  335. }
  336. [Fx.Tag.SecurityNote(Critical = "Attribute type used in security decision.")]
  337. [SecurityCritical]
  338. static Type typeOfDataContractAttribute;
  339. internal static Type TypeOfDataContractAttribute
  340. {
  341. [Fx.Tag.SecurityNote(Critical = "Accesses critical field for attribute type.",
  342. Safe = "Controls inputs and logic.")]
  343. [SecuritySafeCritical]
  344. get
  345. {
  346. if (typeOfDataContractAttribute == null)
  347. typeOfDataContractAttribute = typeof(DataContractAttribute);
  348. return typeOfDataContractAttribute;
  349. }
  350. }
  351. [SecurityCritical]
  352. static Type typeOfContractNamespaceAttribute;
  353. internal static Type TypeOfContractNamespaceAttribute
  354. {
  355. [SecuritySafeCritical]
  356. get
  357. {
  358. if (typeOfContractNamespaceAttribute == null)
  359. typeOfContractNamespaceAttribute = typeof(ContractNamespaceAttribute);
  360. return typeOfContractNamespaceAttribute;
  361. }
  362. }
  363. [SecurityCritical]
  364. static Type typeOfDataMemberAttribute;
  365. internal static Type TypeOfDataMemberAttribute
  366. {
  367. [SecuritySafeCritical]
  368. get
  369. {
  370. if (typeOfDataMemberAttribute == null)
  371. typeOfDataMemberAttribute = typeof(DataMemberAttribute);
  372. return typeOfDataMemberAttribute;
  373. }
  374. }
  375. [SecurityCritical]
  376. static Type typeOfEnumMemberAttribute;
  377. internal static Type TypeOfEnumMemberAttribute
  378. {
  379. [SecuritySafeCritical]
  380. get
  381. {
  382. if (typeOfEnumMemberAttribute == null)
  383. typeOfEnumMemberAttribute = typeof(EnumMemberAttribute);
  384. return typeOfEnumMemberAttribute;
  385. }
  386. }
  387. [SecurityCritical]
  388. static Type typeOfCollectionDataContractAttribute;
  389. internal static Type TypeOfCollectionDataContractAttribute
  390. {
  391. [SecuritySafeCritical]
  392. get
  393. {
  394. if (typeOfCollectionDataContractAttribute == null)
  395. typeOfCollectionDataContractAttribute = typeof(CollectionDataContractAttribute);
  396. return typeOfCollectionDataContractAttribute;
  397. }
  398. }
  399. [SecurityCritical]
  400. static Type typeOfOptionalFieldAttribute;
  401. internal static Type TypeOfOptionalFieldAttribute
  402. {
  403. [SecuritySafeCritical]
  404. get
  405. {
  406. if (typeOfOptionalFieldAttribute == null)
  407. typeOfOptionalFieldAttribute = typeof(OptionalFieldAttribute);
  408. return typeOfOptionalFieldAttribute;
  409. }
  410. }
  411. [SecurityCritical]
  412. static Type typeOfObjectArray;
  413. internal static Type TypeOfObjectArray
  414. {
  415. [SecuritySafeCritical]
  416. get
  417. {
  418. if (typeOfObjectArray == null)
  419. typeOfObjectArray = typeof(object[]);
  420. return typeOfObjectArray;
  421. }
  422. }
  423. [SecurityCritical]
  424. static Type typeOfOnSerializingAttribute;
  425. internal static Type TypeOfOnSerializingAttribute
  426. {
  427. [SecuritySafeCritical]
  428. get
  429. {
  430. if (typeOfOnSerializingAttribute == null)
  431. typeOfOnSerializingAttribute = typeof(OnSerializingAttribute);
  432. return typeOfOnSerializingAttribute;
  433. }
  434. }
  435. [SecurityCritical]
  436. static Type typeOfOnSerializedAttribute;
  437. internal static Type TypeOfOnSerializedAttribute
  438. {
  439. [SecuritySafeCritical]
  440. get
  441. {
  442. if (typeOfOnSerializedAttribute == null)
  443. typeOfOnSerializedAttribute = typeof(OnSerializedAttribute);
  444. return typeOfOnSerializedAttribute;
  445. }
  446. }
  447. [SecurityCritical]
  448. static Type typeOfOnDeserializingAttribute;
  449. internal static Type TypeOfOnDeserializingAttribute
  450. {
  451. [SecuritySafeCritical]
  452. get
  453. {
  454. if (typeOfOnDeserializingAttribute == null)
  455. typeOfOnDeserializingAttribute = typeof(OnDeserializingAttribute);
  456. return typeOfOnDeserializingAttribute;
  457. }
  458. }
  459. [SecurityCritical]
  460. static Type typeOfOnDeserializedAttribute;
  461. internal static Type TypeOfOnDeserializedAttribute
  462. {
  463. [SecuritySafeCritical]
  464. get
  465. {
  466. if (typeOfOnDeserializedAttribute == null)
  467. typeOfOnDeserializedAttribute = typeof(OnDeserializedAttribute);
  468. return typeOfOnDeserializedAttribute;
  469. }
  470. }
  471. [SecurityCritical]
  472. static Type typeOfFlagsAttribute;
  473. internal static Type TypeOfFlagsAttribute
  474. {
  475. [SecuritySafeCritical]
  476. get
  477. {
  478. if (typeOfFlagsAttribute == null)
  479. typeOfFlagsAttribute = typeof(FlagsAttribute);
  480. return typeOfFlagsAttribute;
  481. }
  482. }
  483. [SecurityCritical]
  484. static Type typeOfSerializableAttribute;
  485. internal static Type TypeOfSerializableAttribute
  486. {
  487. [SecuritySafeCritical]
  488. get
  489. {
  490. if (typeOfSerializableAttribute == null)
  491. typeOfSerializableAttribute = typeof(SerializableAttribute);
  492. return typeOfSerializableAttribute;
  493. }
  494. }
  495. [SecurityCritical]
  496. static Type typeOfNonSerializedAttribute;
  497. internal static Type TypeOfNonSerializedAttribute
  498. {
  499. [SecuritySafeCritical]
  500. get
  501. {
  502. if (typeOfNonSerializedAttribute == null)
  503. typeOfNonSerializedAttribute = typeof(NonSerializedAttribute);
  504. return typeOfNonSerializedAttribute;
  505. }
  506. }
  507. [SecurityCritical]
  508. static Type typeOfSerializationInfo;
  509. internal static Type TypeOfSerializationInfo
  510. {
  511. [SecuritySafeCritical]
  512. get
  513. {
  514. if (typeOfSerializationInfo == null)
  515. typeOfSerializationInfo = typeof(SerializationInfo);
  516. return typeOfSerializationInfo;
  517. }
  518. }
  519. [SecurityCritical]
  520. static Type typeOfSerializationInfoEnumerator;
  521. internal static Type TypeOfSerializationInfoEnumerator
  522. {
  523. [SecuritySafeCritical]
  524. get
  525. {
  526. if (typeOfSerializationInfoEnumerator == null)
  527. typeOfSerializationInfoEnumerator = typeof(SerializationInfoEnumerator);
  528. return typeOfSerializationInfoEnumerator;
  529. }
  530. }
  531. [SecurityCritical]
  532. static Type typeOfSerializationEntry;
  533. internal static Type TypeOfSerializationEntry
  534. {
  535. [SecuritySafeCritical]
  536. get
  537. {
  538. if (typeOfSerializationEntry == null)
  539. typeOfSerializationEntry = typeof(SerializationEntry);
  540. return typeOfSerializationEntry;
  541. }
  542. }
  543. [SecurityCritical]
  544. static Type typeOfIXmlSerializable;
  545. internal static Type TypeOfIXmlSerializable
  546. {
  547. [SecuritySafeCritical]
  548. get
  549. {
  550. if (typeOfIXmlSerializable == null)
  551. typeOfIXmlSerializable = typeof(IXmlSerializable);
  552. return typeOfIXmlSerializable;
  553. }
  554. }
  555. [SecurityCritical]
  556. static Type typeOfXmlSchemaProviderAttribute;
  557. internal static Type TypeOfXmlSchemaProviderAttribute
  558. {
  559. [SecuritySafeCritical]
  560. get
  561. {
  562. if (typeOfXmlSchemaProviderAttribute == null)
  563. typeOfXmlSchemaProviderAttribute = typeof(XmlSchemaProviderAttribute);
  564. return typeOfXmlSchemaProviderAttribute;
  565. }
  566. }
  567. [SecurityCritical]
  568. static Type typeOfXmlRootAttribute;
  569. internal static Type TypeOfXmlRootAttribute
  570. {
  571. [SecuritySafeCritical]
  572. get
  573. {
  574. if (typeOfXmlRootAttribute == null)
  575. typeOfXmlRootAttribute = typeof(XmlRootAttribute);
  576. return typeOfXmlRootAttribute;
  577. }
  578. }
  579. [SecurityCritical]
  580. static Type typeOfXmlQualifiedName;
  581. internal static Type TypeOfXmlQualifiedName
  582. {
  583. [SecuritySafeCritical]
  584. get
  585. {
  586. if (typeOfXmlQualifiedName == null)
  587. typeOfXmlQualifiedName = typeof(XmlQualifiedName);
  588. return typeOfXmlQualifiedName;
  589. }
  590. }
  591. [SecurityCritical]
  592. static Type typeOfXmlSchemaType;
  593. internal static Type TypeOfXmlSchemaType
  594. {
  595. [SecuritySafeCritical]
  596. get
  597. {
  598. if (typeOfXmlSchemaType == null)
  599. typeOfXmlSchemaType = typeof(XmlSchemaType);
  600. return typeOfXmlSchemaType;
  601. }
  602. }
  603. [SecurityCritical]
  604. static Type typeOfXmlSerializableServices;
  605. internal static Type TypeOfXmlSerializableServices
  606. {
  607. [SecuritySafeCritical]
  608. get
  609. {
  610. if (typeOfXmlSerializableServices == null)
  611. typeOfXmlSerializableServices = typeof(XmlSerializableServices);
  612. return typeOfXmlSerializableServices;
  613. }
  614. }
  615. [SecurityCritical]
  616. static Type typeOfXmlNodeArray;
  617. internal static Type TypeOfXmlNodeArray
  618. {
  619. [SecuritySafeCritical]
  620. get
  621. {
  622. if (typeOfXmlNodeArray == null)
  623. typeOfXmlNodeArray = typeof(XmlNode[]);
  624. return typeOfXmlNodeArray;
  625. }
  626. }
  627. [SecurityCritical]
  628. static Type typeOfXmlSchemaSet;
  629. internal static Type TypeOfXmlSchemaSet
  630. {
  631. [SecuritySafeCritical]
  632. get
  633. {
  634. if (typeOfXmlSchemaSet == null)
  635. typeOfXmlSchemaSet = typeof(XmlSchemaSet);
  636. return typeOfXmlSchemaSet;
  637. }
  638. }
  639. [SecurityCritical]
  640. static object[] emptyObjectArray;
  641. internal static object[] EmptyObjectArray
  642. {
  643. [SecuritySafeCritical]
  644. get
  645. {
  646. if (emptyObjectArray == null)
  647. emptyObjectArray = new object[0];
  648. return emptyObjectArray;
  649. }
  650. }
  651. [SecurityCritical]
  652. static Type[] emptyTypeArray;
  653. internal static Type[] EmptyTypeArray
  654. {
  655. [SecuritySafeCritical]
  656. get
  657. {
  658. if (emptyTypeArray == null)
  659. emptyTypeArray = new Type[0];
  660. return emptyTypeArray;
  661. }
  662. }
  663. [SecurityCritical]
  664. static Type typeOfIPropertyChange;
  665. internal static Type TypeOfIPropertyChange
  666. {
  667. [SecuritySafeCritical]
  668. get
  669. {
  670. if (typeOfIPropertyChange == null)
  671. typeOfIPropertyChange = typeof(INotifyPropertyChanged);
  672. return typeOfIPropertyChange;
  673. }
  674. }
  675. [SecurityCritical]
  676. static Type typeOfIExtensibleDataObject;
  677. internal static Type TypeOfIExtensibleDataObject
  678. {
  679. [SecuritySafeCritical]
  680. get
  681. {
  682. if (typeOfIExtensibleDataObject == null)
  683. typeOfIExtensibleDataObject = typeof(IExtensibleDataObject);
  684. return typeOfIExtensibleDataObject;
  685. }
  686. }
  687. [SecurityCritical]
  688. static Type typeOfExtensionDataObject;
  689. internal static Type TypeOfExtensionDataObject
  690. {
  691. [SecuritySafeCritical]
  692. get
  693. {
  694. if (typeOfExtensionDataObject == null)
  695. typeOfExtensionDataObject = typeof(ExtensionDataObject);
  696. return typeOfExtensionDataObject;
  697. }
  698. }
  699. [SecurityCritical]
  700. static Type typeOfISerializableDataNode;
  701. internal static Type TypeOfISerializableDataNode
  702. {
  703. [SecuritySafeCritical]
  704. get
  705. {
  706. if (typeOfISerializableDataNode == null)
  707. typeOfISerializableDataNode = typeof(ISerializableDataNode);
  708. return typeOfISerializableDataNode;
  709. }
  710. }
  711. [SecurityCritical]
  712. static Type typeOfClassDataNode;
  713. internal static Type TypeOfClassDataNode
  714. {
  715. [SecuritySafeCritical]
  716. get
  717. {
  718. if (typeOfClassDataNode == null)
  719. typeOfClassDataNode = typeof(ClassDataNode);
  720. return typeOfClassDataNode;
  721. }
  722. }
  723. [SecurityCritical]
  724. static Type typeOfCollectionDataNode;
  725. internal static Type TypeOfCollectionDataNode
  726. {
  727. [SecuritySafeCritical]
  728. get
  729. {
  730. if (typeOfCollectionDataNode == null)
  731. typeOfCollectionDataNode = typeof(CollectionDataNode);
  732. return typeOfCollectionDataNode;
  733. }
  734. }
  735. [SecurityCritical]
  736. static Type typeOfXmlDataNode;
  737. internal static Type TypeOfXmlDataNode
  738. {
  739. [SecuritySafeCritical]
  740. get
  741. {
  742. if (typeOfXmlDataNode == null)
  743. typeOfXmlDataNode = typeof(XmlDataNode);
  744. return typeOfXmlDataNode;
  745. }
  746. }
  747. [SecurityCritical]
  748. static Type typeOfNullable;
  749. internal static Type TypeOfNullable
  750. {
  751. [SecuritySafeCritical]
  752. get
  753. {
  754. if (typeOfNullable == null)
  755. typeOfNullable = typeof(Nullable<>);
  756. return typeOfNullable;
  757. }
  758. }
  759. [SecurityCritical]
  760. static Type typeOfReflectionPointer;
  761. internal static Type TypeOfReflectionPointer
  762. {
  763. [SecuritySafeCritical]
  764. get
  765. {
  766. if (typeOfReflectionPointer == null)
  767. typeOfReflectionPointer = typeof(System.Reflection.Pointer);
  768. return typeOfReflectionPointer;
  769. }
  770. }
  771. [SecurityCritical]
  772. static Type typeOfIDictionaryGeneric;
  773. internal static Type TypeOfIDictionaryGeneric
  774. {
  775. [SecuritySafeCritical]
  776. get
  777. {
  778. if (typeOfIDictionaryGeneric == null)
  779. typeOfIDictionaryGeneric = typeof(IDictionary<,>);
  780. return typeOfIDictionaryGeneric;
  781. }
  782. }
  783. [SecurityCritical]
  784. static Type typeOfIDictionary;
  785. internal static Type TypeOfIDictionary
  786. {
  787. [SecuritySafeCritical]
  788. get
  789. {
  790. if (typeOfIDictionary == null)
  791. typeOfIDictionary = typeof(IDictionary);
  792. return typeOfIDictionary;
  793. }
  794. }
  795. [SecurityCritical]
  796. static Type typeOfIListGeneric;
  797. internal static Type TypeOfIListGeneric
  798. {
  799. [SecuritySafeCritical]
  800. get
  801. {
  802. if (typeOfIListGeneric == null)
  803. typeOfIListGeneric = typeof(IList<>);
  804. return typeOfIListGeneric;
  805. }
  806. }
  807. [SecurityCritical]
  808. static Type typeOfIList;
  809. internal static Type TypeOfIList
  810. {
  811. [SecuritySafeCritical]
  812. get
  813. {
  814. if (typeOfIList == null)
  815. typeOfIList = typeof(IList);
  816. return typeOfIList;
  817. }
  818. }
  819. [SecurityCritical]
  820. static Type typeOfICollectionGeneric;
  821. internal static Type TypeOfICollectionGeneric
  822. {
  823. [SecuritySafeCritical]
  824. get
  825. {
  826. if (typeOfICollectionGeneric == null)
  827. typeOfICollectionGeneric = typeof(ICollection<>);
  828. return typeOfICollectionGeneric;
  829. }
  830. }
  831. [SecurityCritical]
  832. static Type typeOfICollection;
  833. internal static Type TypeOfICollection
  834. {
  835. [SecuritySafeCritical]
  836. get
  837. {
  838. if (typeOfICollection == null)
  839. typeOfICollection = typeof(ICollection);
  840. return typeOfICollection;
  841. }
  842. }
  843. [SecurityCritical]
  844. static Type typeOfIEnumerableGeneric;
  845. internal static Type TypeOfIEnumerableGeneric
  846. {
  847. [SecuritySafeCritical]
  848. get
  849. {
  850. if (typeOfIEnumerableGeneric == null)
  851. typeOfIEnumerableGeneric = typeof(IEnumerable<>);
  852. return typeOfIEnumerableGeneric;
  853. }
  854. }
  855. [SecurityCritical]
  856. static Type typeOfIEnumerable;
  857. internal static Type TypeOfIEnumerable
  858. {
  859. [SecuritySafeCritical]
  860. get
  861. {
  862. if (typeOfIEnumerable == null)
  863. typeOfIEnumerable = typeof(IEnumerable);
  864. return typeOfIEnumerable;
  865. }
  866. }
  867. [SecurityCritical]
  868. static Type typeOfIEnumeratorGeneric;
  869. internal static Type TypeOfIEnumeratorGeneric
  870. {
  871. [SecuritySafeCritical]
  872. get
  873. {
  874. if (typeOfIEnumeratorGeneric == null)
  875. typeOfIEnumeratorGeneric = typeof(IEnumerator<>);
  876. return typeOfIEnumeratorGeneric;
  877. }
  878. }
  879. [SecurityCritical]
  880. static Type typeOfIEnumerator;
  881. internal static Type TypeOfIEnumerator
  882. {
  883. [SecuritySafeCritical]
  884. get
  885. {
  886. if (typeOfIEnumerator == null)
  887. typeOfIEnumerator = typeof(IEnumerator);
  888. return typeOfIEnumerator;
  889. }
  890. }
  891. [SecurityCritical]
  892. static Type typeOfKeyValuePair;
  893. internal static Type TypeOfKeyValuePair
  894. {
  895. [SecuritySafeCritical]
  896. get
  897. {
  898. if (typeOfKeyValuePair == null)
  899. typeOfKeyValuePair = typeof(KeyValuePair<,>);
  900. return typeOfKeyValuePair;
  901. }
  902. }
  903. [SecurityCritical]
  904. static Type typeOfKeyValue;
  905. internal static Type TypeOfKeyValue
  906. {
  907. [SecuritySafeCritical]
  908. get
  909. {
  910. if (typeOfKeyValue == null)
  911. typeOfKeyValue = typeof(KeyValue<,>);
  912. return typeOfKeyValue;
  913. }
  914. }
  915. [SecurityCritical]
  916. static Type typeOfIDictionaryEnumerator;
  917. internal static Type TypeOfIDictionaryEnumerator
  918. {
  919. [SecuritySafeCritical]
  920. get
  921. {
  922. if (typeOfIDictionaryEnumerator == null)
  923. typeOfIDictionaryEnumerator = typeof(IDictionaryEnumerator);
  924. return typeOfIDictionaryEnumerator;
  925. }
  926. }
  927. [SecurityCritical]
  928. static Type typeOfDictionaryEnumerator;
  929. internal static Type TypeOfDictionaryEnumerator
  930. {
  931. [SecuritySafeCritical]
  932. get
  933. {
  934. if (typeOfDictionaryEnumerator == null)
  935. typeOfDictionaryEnumerator = typeof(CollectionDataContract.DictionaryEnumerator);
  936. return typeOfDictionaryEnumerator;
  937. }
  938. }
  939. [SecurityCritical]
  940. static Type typeOfGenericDictionaryEnumerator;
  941. internal static Type TypeOfGenericDictionaryEnumerator
  942. {
  943. [SecuritySafeCritical]
  944. get
  945. {
  946. if (typeOfGenericDictionaryEnumerator == null)
  947. typeOfGenericDictionaryEnumerator = typeof(CollectionDataContract.GenericDictionaryEnumerator<,>);
  948. return typeOfGenericDictionaryEnumerator;
  949. }
  950. }
  951. [SecurityCritical]
  952. static Type typeOfDictionaryGeneric;
  953. internal static Type TypeOfDictionaryGeneric
  954. {
  955. [SecuritySafeCritical]
  956. get
  957. {
  958. if (typeOfDictionaryGeneric == null)
  959. typeOfDictionaryGeneric = typeof(Dictionary<,>);
  960. return typeOfDictionaryGeneric;
  961. }
  962. }
  963. [SecurityCritical]
  964. static Type typeOfHashtable;
  965. internal static Type TypeOfHashtable
  966. {
  967. [SecuritySafeCritical]
  968. get
  969. {
  970. if (typeOfHashtable == null)
  971. typeOfHashtable = typeof(Hashtable);
  972. return typeOfHashtable;
  973. }
  974. }
  975. [SecurityCritical]
  976. static Type typeOfListGeneric;
  977. internal static Type TypeOfListGeneric
  978. {
  979. [SecuritySafeCritical]
  980. get
  981. {
  982. if (typeOfListGeneric == null)
  983. typeOfListGeneric = typeof(List<>);
  984. return typeOfListGeneric;
  985. }
  986. }
  987. [SecurityCritical]
  988. static Type typeOfXmlElement;
  989. internal static Type TypeOfXmlElement
  990. {
  991. [SecuritySafeCritical]
  992. get
  993. {
  994. if (typeOfXmlElement == null)
  995. typeOfXmlElement = typeof(XmlElement);
  996. return typeOfXmlElement;
  997. }
  998. }
  999. [SecurityCritical]
  1000. static Type typeOfDBNull;
  1001. internal static Type TypeOfDBNull
  1002. {
  1003. [SecuritySafeCritical]
  1004. get
  1005. {
  1006. if (typeOfDBNull == null)
  1007. typeOfDBNull = typeof(DBNull);
  1008. return typeOfDBNull;
  1009. }
  1010. }
  1011. [SecurityCritical]
  1012. static Uri dataContractXsdBaseNamespaceUri;
  1013. internal static Uri DataContractXsdBaseNamespaceUri
  1014. {
  1015. [SecuritySafeCritical]
  1016. get
  1017. {
  1018. if (dataContractXsdBaseNamespaceUri == null)
  1019. dataContractXsdBaseNamespaceUri = new Uri(DataContractXsdBaseNamespace);
  1020. return dataContractXsdBaseNamespaceUri;
  1021. }
  1022. }
  1023. #if FEATURE_MONO_CAS
  1024. [Fx.Tag.SecurityNote(Critical = "Holds instance of SecurityPermission that we will Demand for SerializationFormatter."
  1025. + " Should not be modified to something else.")]
  1026. [SecurityCritical]
  1027. static SecurityPermission serializationFormatterPermission;
  1028. public static SecurityPermission SerializationFormatterPermission
  1029. {
  1030. [Fx.Tag.SecurityNote(Critical = "Sets and accesses instance of SecurityPermission that we will Demand for SerializationFormatter.")]
  1031. [SecurityCritical]
  1032. get
  1033. {
  1034. if (serializationFormatterPermission == null)
  1035. serializationFormatterPermission = new SecurityPermission(SecurityPermissionFlag.SerializationFormatter);
  1036. return serializationFormatterPermission;
  1037. }
  1038. }
  1039. [Fx.Tag.SecurityNote(Critical = "Holds instance of ReflectionPermission that we will Demand for MemberAccess."
  1040. + " Should not be modified to something else.")]
  1041. [SecurityCritical]
  1042. static ReflectionPermission memberAccessPermission;
  1043. public static ReflectionPermission MemberAccessPermission
  1044. {
  1045. [Fx.Tag.SecurityNote(Critical = "Sets and accesses instance of ReflectionPermission that we will Demand for MemberAccess.")]
  1046. [SecurityCritical]
  1047. get
  1048. {
  1049. if (memberAccessPermission == null)
  1050. memberAccessPermission = new ReflectionPermission(ReflectionPermissionFlag.MemberAccess);
  1051. return memberAccessPermission;
  1052. }
  1053. }
  1054. #endif
  1055. public const bool DefaultIsRequired = false;
  1056. public const bool DefaultEmitDefaultValue = true;
  1057. public const int DefaultOrder = 0;
  1058. public const bool DefaultIsReference = false;
  1059. // The value string.Empty aids comparisons (can do simple length checks
  1060. // instead of string comparison method calls in IL.)
  1061. public readonly static string NewObjectId = string.Empty;
  1062. public const string SimpleSRSInternalsVisiblePattern = @"^[\s]*System\.Runtime\.Serialization[\s]*$";
  1063. public const string FullSRSInternalsVisiblePattern = @"^[\s]*System\.Runtime\.Serialization[\s]*,[\s]*PublicKey[\s]*=[\s]*(?i:00000000000000000400000000000000)[\s]*$";
  1064. public const string NullObjectId = null;
  1065. public const string Space = " ";
  1066. public const string OpenBracket = "[";
  1067. public const string CloseBracket = "]";
  1068. public const string Comma = ",";
  1069. public const string XsiPrefix = "i";
  1070. public const string XsdPrefix = "x";
  1071. public const string SerPrefix = "z";
  1072. public const string SerPrefixForSchema = "ser";
  1073. public const string ElementPrefix = "q";
  1074. public const string DataContractXsdBaseNamespace = "http://schemas.datacontract.org/2004/07/";
  1075. public const string DataContractXmlNamespace = DataContractXsdBaseNamespace + "System.Xml";
  1076. public const string SchemaInstanceNamespace = XmlSchema.InstanceNamespace;
  1077. public const string SchemaNamespace = XmlSchema.Namespace;
  1078. public const string XsiNilLocalName = "nil";
  1079. public const string XsiTypeLocalName = "type";
  1080. public const string TnsPrefix = "tns";
  1081. public const string OccursUnbounded = "unbounded";
  1082. public const string AnyTypeLocalName = "anyType";
  1083. public const string StringLocalName = "string";
  1084. public const string IntLocalName = "int";
  1085. public const string True = "true";
  1086. public const string False = "false";
  1087. public const string ArrayPrefix = "ArrayOf";
  1088. public const string XmlnsNamespace = "http://www.w3.org/2000/xmlns/";
  1089. public const string XmlnsPrefix = "xmlns";
  1090. public const string SchemaLocalName = "schema";
  1091. public const string CollectionsNamespace = "http://schemas.microsoft.com/2003/10/Serialization/Arrays";
  1092. public const string DefaultClrNamespace = "GeneratedNamespace";
  1093. public const string DefaultTypeName = "GeneratedType";
  1094. public const string DefaultGeneratedMember = "GeneratedMember";
  1095. public const string DefaultFieldSuffix = "Field";
  1096. public const string DefaultPropertySuffix = "Property";
  1097. public const string DefaultMemberSuffix = "Member";
  1098. public const string NameProperty = "Name";
  1099. public const string NamespaceProperty = "Namespace";
  1100. public const string OrderProperty = "Order";
  1101. public const string IsReferenceProperty = "IsReference";
  1102. public const string IsRequiredProperty = "IsRequired";
  1103. public const string EmitDefaultValueProperty = "EmitDefaultValue";
  1104. public const string ClrNamespaceProperty = "ClrNamespace";
  1105. public const string ItemNameProperty = "ItemName";
  1106. public const string KeyNameProperty = "KeyName";
  1107. public const string ValueNameProperty = "ValueName";
  1108. public const string SerializationInfoPropertyName = "SerializationInfo";
  1109. public const string SerializationInfoFieldName = "info";
  1110. public const string NodeArrayPropertyName = "Nodes";
  1111. public const string NodeArrayFieldName = "nodesField";
  1112. public const string ExportSchemaMethod = "ExportSchema";
  1113. public const string IsAnyProperty = "IsAny";
  1114. public const string ContextFieldName = "context";
  1115. public const string GetObjectDataMethodName = "GetObjectData";
  1116. public const string GetEnumeratorMethodName = "GetEnumerator";
  1117. public const string MoveNextMethodName = "MoveNext";
  1118. public const string AddValueMethodName = "AddValue";
  1119. public const string CurrentPropertyName = "Current";
  1120. public const string ValueProperty = "Value";
  1121. public const string EnumeratorFieldName = "enumerator";
  1122. public const string SerializationEntryFieldName = "entry";
  1123. public const string ExtensionDataSetMethod = "set_ExtensionData";
  1124. public const string ExtensionDataSetExplicitMethod = "System.Runtime.Serialization.IExtensibleDataObject.set_ExtensionData";
  1125. public const string ExtensionDataObjectPropertyName = "ExtensionData";
  1126. public const string ExtensionDataObjectFieldName = "extensionDataField";
  1127. public const string AddMethodName = "Add";
  1128. public const string ParseMethodName = "Parse";
  1129. public const string GetCurrentMethodName = "get_Current";
  1130. // NOTE: These values are used in schema below. If you modify any value, please make the same change in the schema.
  1131. public const string SerializationNamespace = "http://schemas.microsoft.com/2003/10/Serialization/";
  1132. public const string ClrTypeLocalName = "Type";
  1133. public const string ClrAssemblyLocalName = "Assembly";
  1134. public const string IsValueTypeLocalName = "IsValueType";
  1135. public const string EnumerationValueLocalName = "EnumerationValue";
  1136. public const string SurrogateDataLocalName = "Surrogate";
  1137. public const string GenericTypeLocalName = "GenericType";
  1138. public const string GenericParameterLocalName = "GenericParameter";
  1139. public const string GenericNameAttribute = "Name";
  1140. public const string GenericNamespaceAttribute = "Namespace";
  1141. public const string GenericParameterNestedLevelAttribute = "NestedLevel";
  1142. public const string IsDictionaryLocalName = "IsDictionary";
  1143. public const string ActualTypeLocalName = "ActualType";
  1144. public const string ActualTypeNameAttribute = "Name";
  1145. public const string ActualTypeNamespaceAttribute = "Namespace";
  1146. public const string DefaultValueLocalName = "DefaultValue";
  1147. public const string EmitDefaultValueAttribute = "EmitDefaultValue";
  1148. public const string ISerializableFactoryTypeLocalName = "FactoryType";
  1149. public const string IdLocalName = "Id";
  1150. public const string RefLocalName = "Ref";
  1151. public const string ArraySizeLocalName = "Size";
  1152. public const string KeyLocalName = "Key";
  1153. public const string ValueLocalName = "Value";
  1154. public const string MscorlibAssemblyName = "0";
  1155. public const string MscorlibAssemblySimpleName = "mscorlib";
  1156. public const string MscorlibFileName = MscorlibAssemblySimpleName + ".dll";
  1157. public const string SerializationSchema = @"<?xml version='1.0' encoding='utf-8'?>
  1158. <xs:schema elementFormDefault='qualified' attributeFormDefault='qualified' xmlns:tns='http://schemas.microsoft.com/2003/10/Serialization/' targetNamespace='http://schemas.microsoft.com/2003/10/Serialization/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
  1159. <xs:element name='anyType' nillable='true' type='xs:anyType' />
  1160. <xs:element name='anyURI' nillable='true' type='xs:anyURI' />
  1161. <xs:element name='base64Binary' nillable='true' type='xs:base64Binary' />
  1162. <xs:element name='boolean' nillable='true' type='xs:boolean' />
  1163. <xs:element name='byte' nillable='true' type='xs:byte' />
  1164. <xs:element name='dateTime' nillable='true' type='xs:dateTime' />
  1165. <xs:element name='decimal' nillable='true' type='xs:decimal' />
  1166. <xs:element name='double' nillable='true' type='xs:double' />
  1167. <xs:element name='float' nillable='true' type='xs:float' />
  1168. <xs:element name='int' nillable='true' type='xs:int' />
  1169. <xs:element name='long' nillable='true' type='xs:long' />
  1170. <xs:element name='QName' nillable='true' type='xs:QName' />
  1171. <xs:element name='short' nillable='true' type='xs:short' />
  1172. <xs:element name='string' nillable='true' type='xs:string' />
  1173. <xs:element name='unsignedByte' nillable='true' type='xs:unsignedByte' />
  1174. <xs:element name='unsignedInt' nillable='true' type='xs:unsignedInt' />
  1175. <xs:element name='unsignedLong' nillable='true' type='xs:unsignedLong' />
  1176. <xs:element name='unsignedShort' nillable='true' type='xs:unsignedShort' />
  1177. <xs:element name='char' nillable='true' type='tns:char' />
  1178. <xs:simpleType name='char'>
  1179. <xs:restriction base='xs:int'/>
  1180. </xs:simpleType>
  1181. <xs:element name='duration' nillable='true' type='tns:duration' />
  1182. <xs:simpleType name='duration'>
  1183. <xs:restriction base='xs:duration'>
  1184. <xs:pattern value='\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?' />
  1185. <xs:minInclusive value='-P10675199DT2H48M5.4775808S' />
  1186. <xs:maxInclusive value='P10675199DT2H48M5.4775807S' />
  1187. </xs:restriction>
  1188. </xs:simpleType>
  1189. <xs:element name='guid' nillable='true' type='tns:guid' />
  1190. <xs:simpleType name='guid'>
  1191. <xs:restriction base='xs:string'>
  1192. <xs:pattern value='[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}' />
  1193. </xs:restriction>
  1194. </xs:simpleType>
  1195. <xs:attribute name='FactoryType' type='xs:QName' />
  1196. <xs:attribute name='Id' type='xs:ID' />
  1197. <xs:attribute name='Ref' type='xs:IDREF' />
  1198. </xs:schema>
  1199. ";
  1200. }
  1201. }