JsonFormatGeneratorStatics.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / NetFx35 / System.ServiceModel.Web / System / Runtime / Serialization / Json / JsonFormatGeneratorStatics.cs / 1 / JsonFormatGeneratorStatics.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime.Serialization
{ 
    using System;
    using System.Reflection; 
    using System.Security; 
    using System.Xml;
    using System.Collections; 
    using System.Collections.Generic;
    using System.Runtime.Serialization.Json;

    //  
    // Critical - Class holds static instances used for code generation during serialization.
    //            Static fields are marked SecurityCritical or readonly to prevent 
    //            data from being modified or leaked to other components in appdomain. 
    // Safe - All get-only properties marked safe since they only need to be protected for write.
    //  
#if USE_REFEMIT
    public static class JsonFormatGeneratorStatics
#else
    internal static class JsonFormatGeneratorStatics 
#endif
    { 
 
        [SecurityCritical]
        static MethodInfo boxPointer; 
        [SecurityCritical]
        static PropertyInfo collectionItemNameProperty;

        [SecurityCritical] 
        static ConstructorInfo extensionDataObjectCtor;
 
        [SecurityCritical] 
        static PropertyInfo extensionDataProperty;
 
        [SecurityCritical]
        static MethodInfo getItemContractMethod;

        [SecurityCritical] 
        static MethodInfo getJsonDataContractMethod;
 
        [SecurityCritical] 
        static MethodInfo getJsonMemberIndexMethod;
 
        [SecurityCritical]
        static MethodInfo getRevisedItemContractMethod;

        [SecurityCritical] 
        static MethodInfo getUninitializedObjectMethod;
 
        [SecurityCritical] 
        static MethodInfo ienumeratorGetCurrentMethod;
 
        [SecurityCritical]
        static MethodInfo ienumeratorMoveNextMethod;

        [SecurityCritical] 
        static MethodInfo isStartElementMethod0;
 
        [SecurityCritical] 
        static MethodInfo isStartElementMethod2;
 
        [SecurityCritical]
        static PropertyInfo nodeTypeProperty;

        [SecurityCritical] 
        static MethodInfo onDeserializationMethod;
 
        [SecurityCritical] 
        static MethodInfo readJsonValueMethod;
 
        [SecurityCritical]
        static ConstructorInfo serializationExceptionCtor;

        [SecurityCritical] 
        static Type[] serInfoCtorArgs;
 
        [SecurityCritical] 
        static MethodInfo throwDuplicateMemberExceptionMethod;
 
        [SecurityCritical]
        static MethodInfo throwMissingRequiredMembersMethod;

        [SecurityCritical] 
        static PropertyInfo typeHandleProperty;
 
        [SecurityCritical] 
        static MethodInfo unboxPointer;
 
        [SecurityCritical]
        static MethodInfo writeAttributeStringMethod;

        [SecurityCritical] 
        static MethodInfo writeEndElementMethod;
 
        [SecurityCritical] 
        static MethodInfo writeJsonISerializableMethod;
 
        [SecurityCritical]
        static MethodInfo writeJsonNameWithMappingMethod;

        [SecurityCritical] 
        static MethodInfo writeJsonValueMethod;
 
        [SecurityCritical] 
        static MethodInfo writeStartElementMethod;
        public static MethodInfo BoxPointer 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (boxPointer == null)
                { 
                    boxPointer = typeof(Pointer).GetMethod("Box"); 
                }
                return boxPointer; 
            }
        }
        public static PropertyInfo CollectionItemNameProperty
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (collectionItemNameProperty == null)
                { 
                    collectionItemNameProperty = typeof(XmlObjectSerializerWriteContextComplexJson).GetProperty("CollectionItemName", Globals.ScanAllMembers);
                }
                return collectionItemNameProperty;
            } 
        }
        public static ConstructorInfo ExtensionDataObjectCtor 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (extensionDataObjectCtor == null)
                {
                    extensionDataObjectCtor = typeof(ExtensionDataObject).GetConstructor(Globals.ScanAllMembers, null, new Type[] { }, null); 
                }
                return extensionDataObjectCtor; 
            } 
        }
        public static PropertyInfo ExtensionDataProperty 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (extensionDataProperty == null)
                { 
                    extensionDataProperty = typeof(IExtensibleDataObject).GetProperty("ExtensionData"); 
                }
                return extensionDataProperty; 
            }
        }
        public static MethodInfo GetCurrentMethod
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (ienumeratorGetCurrentMethod == null)
                { 
                    ienumeratorGetCurrentMethod = typeof(IEnumerator).GetProperty("Current").GetGetMethod();
                }
                return ienumeratorGetCurrentMethod;
            } 
        }
        public static MethodInfo GetItemContractMethod 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (getItemContractMethod == null)
                {
                    getItemContractMethod = typeof(CollectionDataContract).GetProperty("ItemContract", Globals.ScanAllMembers).GetGetMethod(true); // nonPublic 
                }
                return getItemContractMethod; 
            } 
        }
        public static MethodInfo GetJsonDataContractMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (getJsonDataContractMethod == null)
                { 
                    getJsonDataContractMethod = typeof(JsonDataContract).GetMethod("GetJsonDataContract", Globals.ScanAllMembers); 
                }
                return getJsonDataContractMethod; 
            }
        }
        public static MethodInfo GetJsonMemberIndexMethod
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (getJsonMemberIndexMethod == null)
                { 
                    getJsonMemberIndexMethod = typeof(XmlObjectSerializerReadContextComplexJson).GetMethod("GetJsonMemberIndex", Globals.ScanAllMembers);
                }
                return getJsonMemberIndexMethod;
            } 
        }
        public static MethodInfo GetRevisedItemContractMethod 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (getRevisedItemContractMethod == null)
                {
                    getRevisedItemContractMethod = typeof(XmlObjectSerializerWriteContextComplexJson).GetMethod("GetRevisedItemContract", Globals.ScanAllMembers); 
                }
                return getRevisedItemContractMethod; 
            } 
        }
        public static MethodInfo GetUninitializedObjectMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (getUninitializedObjectMethod == null)
                { 
                    getUninitializedObjectMethod = typeof(XmlFormatReaderGenerator).GetMethod("UnsafeGetUninitializedObject", Globals.ScanAllMembers, null, new Type[] { typeof(int) }, null); 
                }
                return getUninitializedObjectMethod; 
            }
        }
        public static MethodInfo IsStartElementMethod0
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (isStartElementMethod0 == null)
                { 
                    isStartElementMethod0 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, null, new Type[] { }, null);
                }
                return isStartElementMethod0;
            } 
        }
        public static MethodInfo IsStartElementMethod2 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (isStartElementMethod2 == null)
                {
                    isStartElementMethod2 = typeof(XmlReaderDelegator).GetMethod("IsStartElement", Globals.ScanAllMembers, null, new Type[] { typeof(XmlDictionaryString), typeof(XmlDictionaryString) }, null); 
                }
                return isStartElementMethod2; 
            } 
        }
        public static MethodInfo MoveNextMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (ienumeratorMoveNextMethod == null)
                { 
                    ienumeratorMoveNextMethod = typeof(IEnumerator).GetMethod("MoveNext"); 
                }
                return ienumeratorMoveNextMethod; 
            }
        }
        public static PropertyInfo NodeTypeProperty
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (nodeTypeProperty == null)
                { 
                    nodeTypeProperty = typeof(XmlReaderDelegator).GetProperty("NodeType", Globals.ScanAllMembers);
                }
                return nodeTypeProperty;
            } 
        }
        public static MethodInfo OnDeserializationMethod 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (onDeserializationMethod == null)
                {
                    onDeserializationMethod = typeof(IDeserializationCallback).GetMethod("OnDeserialization"); 
                }
                return onDeserializationMethod; 
            } 
        }
        public static MethodInfo ReadJsonValueMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (readJsonValueMethod == null)
                { 
                    readJsonValueMethod = typeof(DataContractJsonSerializer).GetMethod("ReadJsonValue", Globals.ScanAllMembers); 
                }
                return readJsonValueMethod; 
            }
        }
        public static ConstructorInfo SerializationExceptionCtor
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (serializationExceptionCtor == null)
                { 
                    serializationExceptionCtor = typeof(SerializationException).GetConstructor(new Type[] { typeof(string) });
                }
                return serializationExceptionCtor;
            } 
        }
        public static Type[] SerInfoCtorArgs 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (serInfoCtorArgs == null)
                {
                    serInfoCtorArgs = new Type[] { typeof(SerializationInfo), typeof(StreamingContext) }; 
                }
                return serInfoCtorArgs; 
            } 
        }
        public static MethodInfo ThrowDuplicateMemberExceptionMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (throwDuplicateMemberExceptionMethod == null)
                { 
                    throwDuplicateMemberExceptionMethod = typeof(XmlObjectSerializerReadContextComplexJson).GetMethod("ThrowDuplicateMemberException", Globals.ScanAllMembers); 
                }
                return throwDuplicateMemberExceptionMethod; 
            }
        }
        public static MethodInfo ThrowMissingRequiredMembersMethod
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (throwMissingRequiredMembersMethod == null)
                { 
                    throwMissingRequiredMembersMethod = typeof(XmlObjectSerializerReadContextComplexJson).GetMethod("ThrowMissingRequiredMembers", Globals.ScanAllMembers);
                }
                return throwMissingRequiredMembersMethod;
            } 
        }
        public static PropertyInfo TypeHandleProperty 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (typeHandleProperty == null)
                {
                    typeHandleProperty = typeof(Type).GetProperty("TypeHandle"); 
                }
                return typeHandleProperty; 
            } 
        }
        public static MethodInfo UnboxPointer 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (unboxPointer == null)
                { 
                    unboxPointer = typeof(Pointer).GetMethod("Unbox"); 
                }
                return unboxPointer; 
            }
        }
        public static MethodInfo WriteAttributeStringMethod
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (writeAttributeStringMethod == null)
                { 
                    writeAttributeStringMethod = typeof(XmlWriterDelegator).GetMethod("WriteAttributeString", Globals.ScanAllMembers, null, new Type[] { typeof(string), typeof(string), typeof(string), typeof(string) }, null);
                }
                return writeAttributeStringMethod;
            } 
        }
        public static MethodInfo WriteEndElementMethod 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (writeEndElementMethod == null)
                {
                    writeEndElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteEndElement", Globals.ScanAllMembers, null, new Type[] { }, null); 
                }
                return writeEndElementMethod; 
            } 
        }
        public static MethodInfo WriteJsonISerializableMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (writeJsonISerializableMethod == null)
                { 
                    writeJsonISerializableMethod = typeof(XmlObjectSerializerWriteContextComplexJson).GetMethod("WriteJsonISerializable", Globals.ScanAllMembers); 
                }
                return writeJsonISerializableMethod; 
            }
        }
        public static MethodInfo WriteJsonNameWithMappingMethod
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            { 
                if (writeJsonNameWithMappingMethod == null)
                { 
                    writeJsonNameWithMappingMethod = typeof(XmlObjectSerializerWriteContextComplexJson).GetMethod("WriteJsonNameWithMapping", Globals.ScanAllMembers);
                }
                return writeJsonNameWithMappingMethod;
            } 
        }
        public static MethodInfo WriteJsonValueMethod 
        { 
            [SecurityCritical, SecurityTreatAsSafe]
            get 
            {
                if (writeJsonValueMethod == null)
                {
                    writeJsonValueMethod = typeof(DataContractJsonSerializer).GetMethod("WriteJsonValue", Globals.ScanAllMembers); 
                }
                return writeJsonValueMethod; 
            } 
        }
        public static MethodInfo WriteStartElementMethod 
        {
            [SecurityCritical, SecurityTreatAsSafe]
            get
            { 
                if (writeStartElementMethod == null)
                { 
                    writeStartElementMethod = typeof(XmlWriterDelegator).GetMethod("WriteStartElement", Globals.ScanAllMembers, null, new Type[] { typeof(XmlDictionaryString), typeof(XmlDictionaryString) }, null); 
                }
                return writeStartElementMethod; 
            }
        }
    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK