SpecialTypeDataContract.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 / WCF / Serialization / System / Runtime / Serialization / SpecialTypeDataContract.cs / 1 / SpecialTypeDataContract.cs

                            //------------------------------------------------------------------------------ 
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------
using System;
using System.Collections.Generic; 
using System.Text;
using System.Xml; 
using System.Security; 

namespace System.Runtime.Serialization 
{
    internal sealed class SpecialTypeDataContract : DataContract
    {
        ///  
        /// Critical - holds instance of CriticalHelper which keeps state that is cached statically for serialization.
        ///            Static fields are marked SecurityCritical or readonly to prevent 
        ///            data from being modified or leaked to other components in appdomain. 
        /// 
        [SecurityCritical] 
        SpecialTypeDataContractCriticalHelper helper;

        /// 
        /// Critical - initializes SecurityCritical field 'helper' 
        /// Safe - doesn't leak anything
        ///  
        [SecurityCritical, SecurityTreatAsSafe] 
        public SpecialTypeDataContract(Type type) : base(new SpecialTypeDataContractCriticalHelper(type))
        { 
            helper = base.Helper as SpecialTypeDataContractCriticalHelper;
        }

        ///  
        /// Critical - initializes SecurityCritical field 'helper'
        /// Safe - doesn't leak anything 
        ///  
        [SecurityCritical, SecurityTreatAsSafe]
        public SpecialTypeDataContract(Type type, XmlDictionaryString name, XmlDictionaryString ns) : base(new SpecialTypeDataContractCriticalHelper(type, name, ns)) 
        {
            helper = base.Helper as SpecialTypeDataContractCriticalHelper;
        }
 
        internal override bool IsBuiltInDataContract
        { 
            get 
            {
                return true; 
            }
        }

        ///  
        /// Critical - holds all state used for for (de)serializing known types like System.Enum, System.ValueType, etc.
        ///            since the data is cached statically, we lock down access to it. 
        ///  
        [SecurityCritical(SecurityCriticalScope.Everything)]
        class SpecialTypeDataContractCriticalHelper : DataContract.DataContractCriticalHelper 
        {
            internal SpecialTypeDataContractCriticalHelper(Type type) : base(type)
            {
            } 

            internal SpecialTypeDataContractCriticalHelper(Type type, XmlDictionaryString name, XmlDictionaryString ns) : base(type) 
            { 
                SetDataContractName(name, ns);
            } 
        }
    }
}
 

// 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