PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/WCFWebApi/src/Microsoft.Runtime.Serialization.Internal/Microsoft/Runtime/Serialization/XmlFormatGeneratorStatics.cs

#
C# | 97 lines | 87 code | 7 blank | 3 comment | 12 complexity | 62cc66186eaf378b1045bec694cc64c8 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Apache-2.0
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. //-----------------------------------------------------------------------------
  4. namespace Microsoft.Runtime.Serialization
  5. {
  6. using System;
  7. using System.Collections;
  8. using System.Reflection;
  9. using System.Runtime.Serialization;
  10. using System.Security;
  11. using Microsoft.Server.Common;
  12. [Fx.Tag.SecurityNote(Critical = "Class holds static instances used for code generation during serialization."
  13. + " Static fields are marked SecurityCritical or readonly to prevent data from being modified or leaked to other components in appdomain.",
  14. Safe = "All get-only properties marked safe since they only need to be protected for write.")]
  15. static class XmlFormatGeneratorStatics
  16. {
  17. [SecurityCritical]
  18. static MethodInfo extensionDataSetExplicitMethodInfo;
  19. internal static MethodInfo ExtensionDataSetExplicitMethodInfo
  20. {
  21. [SecuritySafeCritical]
  22. get
  23. {
  24. if (extensionDataSetExplicitMethodInfo == null)
  25. extensionDataSetExplicitMethodInfo = typeof(IExtensibleDataObject).GetMethod(Globals.ExtensionDataSetMethod);
  26. return extensionDataSetExplicitMethodInfo;
  27. }
  28. }
  29. [SecurityCritical]
  30. static ConstructorInfo dictionaryEnumeratorCtor;
  31. internal static ConstructorInfo DictionaryEnumeratorCtor
  32. {
  33. [SecuritySafeCritical]
  34. get
  35. {
  36. if (dictionaryEnumeratorCtor == null)
  37. dictionaryEnumeratorCtor = Globals.TypeOfDictionaryEnumerator.GetConstructor(Globals.ScanAllMembers, null, new Type[] { Globals.TypeOfIDictionaryEnumerator }, null);
  38. return dictionaryEnumeratorCtor;
  39. }
  40. }
  41. [SecurityCritical]
  42. static MethodInfo ienumeratorGetCurrentMethod;
  43. internal static MethodInfo GetCurrentMethod
  44. {
  45. [SecuritySafeCritical]
  46. get
  47. {
  48. if (ienumeratorGetCurrentMethod == null)
  49. ienumeratorGetCurrentMethod = typeof(IEnumerator).GetProperty("Current").GetGetMethod();
  50. return ienumeratorGetCurrentMethod;
  51. }
  52. }
  53. [SecurityCritical]
  54. static MethodInfo ienumeratorMoveNextMethod;
  55. internal static MethodInfo MoveNextMethod
  56. {
  57. [SecuritySafeCritical]
  58. get
  59. {
  60. if (ienumeratorMoveNextMethod == null)
  61. ienumeratorMoveNextMethod = typeof(IEnumerator).GetMethod("MoveNext");
  62. return ienumeratorMoveNextMethod;
  63. }
  64. }
  65. [SecurityCritical]
  66. static MethodInfo throwRequiredMemberMustBeEmittedMethod;
  67. internal static MethodInfo ThrowRequiredMemberMustBeEmittedMethod
  68. {
  69. [SecuritySafeCritical]
  70. get
  71. {
  72. if (throwRequiredMemberMustBeEmittedMethod == null)
  73. throwRequiredMemberMustBeEmittedMethod = typeof(XmlObjectSerializerWriteContext).GetMethod("ThrowRequiredMemberMustBeEmitted", Globals.ScanAllMembers);
  74. return throwRequiredMemberMustBeEmittedMethod;
  75. }
  76. }
  77. [SecurityCritical]
  78. static MethodInfo traceInstructionMethod;
  79. internal static MethodInfo TraceInstructionMethod
  80. {
  81. [SecuritySafeCritical]
  82. get
  83. {
  84. if (traceInstructionMethod == null)
  85. traceInstructionMethod = typeof(SerializationTrace).GetMethod("TraceInstruction", Globals.ScanAllMembers);
  86. return traceInstructionMethod;
  87. }
  88. }
  89. }
  90. }