PageRenderTime 17ms CodeModel.GetById 6ms app.highlight 7ms RepoModel.GetById 1ms 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
 1//-----------------------------------------------------------------------------
 2// Copyright (c) Microsoft Corporation.  All rights reserved.
 3//-----------------------------------------------------------------------------
 4namespace 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
13    [Fx.Tag.SecurityNote(Critical = "Class holds static instances used for code generation during serialization."
14        + " Static fields are marked SecurityCritical or readonly to prevent data from being modified or leaked to other components in appdomain.",
15        Safe = "All get-only properties marked safe since they only need to be protected for write.")]
16    static class XmlFormatGeneratorStatics
17    {
18
19        [SecurityCritical]
20        static MethodInfo extensionDataSetExplicitMethodInfo;
21        internal static MethodInfo ExtensionDataSetExplicitMethodInfo
22        {
23            [SecuritySafeCritical]
24            get
25            {
26                if (extensionDataSetExplicitMethodInfo == null)
27                    extensionDataSetExplicitMethodInfo = typeof(IExtensibleDataObject).GetMethod(Globals.ExtensionDataSetMethod);
28                return extensionDataSetExplicitMethodInfo;
29            }
30        }
31
32        [SecurityCritical]
33        static ConstructorInfo dictionaryEnumeratorCtor;
34        internal static ConstructorInfo DictionaryEnumeratorCtor
35        {
36            [SecuritySafeCritical]
37            get
38            {
39                if (dictionaryEnumeratorCtor == null)
40                    dictionaryEnumeratorCtor = Globals.TypeOfDictionaryEnumerator.GetConstructor(Globals.ScanAllMembers, null, new Type[] { Globals.TypeOfIDictionaryEnumerator }, null);
41                return dictionaryEnumeratorCtor;
42            }
43        }
44
45        [SecurityCritical]
46        static MethodInfo ienumeratorGetCurrentMethod;
47        internal static MethodInfo GetCurrentMethod
48        {
49            [SecuritySafeCritical]
50            get
51            {
52                if (ienumeratorGetCurrentMethod == null)
53                    ienumeratorGetCurrentMethod = typeof(IEnumerator).GetProperty("Current").GetGetMethod();
54                return ienumeratorGetCurrentMethod;
55            }
56        }
57
58        [SecurityCritical]
59        static MethodInfo ienumeratorMoveNextMethod;
60        internal static MethodInfo MoveNextMethod
61        {
62            [SecuritySafeCritical]
63            get
64            {
65                if (ienumeratorMoveNextMethod == null)
66                    ienumeratorMoveNextMethod = typeof(IEnumerator).GetMethod("MoveNext");
67                return ienumeratorMoveNextMethod;
68            }
69        }
70
71        [SecurityCritical]
72        static MethodInfo throwRequiredMemberMustBeEmittedMethod;
73        internal static MethodInfo ThrowRequiredMemberMustBeEmittedMethod
74        {
75            [SecuritySafeCritical]
76            get
77            {
78                if (throwRequiredMemberMustBeEmittedMethod == null)
79                    throwRequiredMemberMustBeEmittedMethod = typeof(XmlObjectSerializerWriteContext).GetMethod("ThrowRequiredMemberMustBeEmitted", Globals.ScanAllMembers);
80                return throwRequiredMemberMustBeEmittedMethod;
81            }
82        }
83
84        [SecurityCritical]
85        static MethodInfo traceInstructionMethod;
86        internal static MethodInfo TraceInstructionMethod
87        {
88            [SecuritySafeCritical]
89            get
90            {
91                if (traceInstructionMethod == null)
92                    traceInstructionMethod = typeof(SerializationTrace).GetMethod("TraceInstruction", Globals.ScanAllMembers);
93                return traceInstructionMethod;
94            }
95        }
96    }
97}