Baml2006KeyRecord.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / Markup / Baml2006 / Baml2006KeyRecord.cs / 1586720 / Baml2006KeyRecord.cs

                            using System; 
using System.Collections.Generic;
using System.Text;
using System.Xaml;
using System.Windows.Markup; 
using System.Diagnostics;
 
namespace System.Windows.Baml2006 
{
    [DebuggerDisplay("{DebuggerString}")] 
    internal class KeyRecord
    {
        public KeyRecord(bool shared, bool sharedSet, int valuePosition, Type keyType) :
            this(shared, sharedSet, valuePosition) 
        {
            _data = keyType; 
        } 

        public KeyRecord(bool shared, bool sharedSet, int valuePosition, string keyString) : 
            this(shared, sharedSet, valuePosition)
        {
            _data = keyString;
        } 

        public KeyRecord(bool shared, bool sharedSet, int valuePosition, XamlSchemaContext context) : 
            this(shared, sharedSet, valuePosition) 
        {
            _data = new XamlNodeList(context, 8); 
        }

        private KeyRecord(bool shared, bool sharedSet, int valuePosition)
        { 
            _shared = shared;
            _sharedSet = sharedSet; 
            ValuePosition = valuePosition; 
        }
 
        public bool Shared { get { return _shared; } }
        public bool SharedSet { get { return _sharedSet; } }
        public long ValuePosition { get; set; }
        public int ValueSize { get; set; } 
        public byte Flags { get; set; }
 
        // This can either be a StaticResource or an OptimizedStaticResource 
        // Since they don't share anything in common, we've made this a list of objects.
        public List StaticResources 
        {
            get
            {
                if (_resources == null) 
                {
                    _resources = new List(); 
                } 

                return _resources; 
            }
        }

        public bool HasStaticResources 
        {
            get { return (_resources != null && _resources.Count > 0); } 
        } 

        public StaticResource LastStaticResource 
        {
            get
            {
                Debug.Assert(StaticResources[StaticResources.Count - 1] is StaticResource); 
                return StaticResources[StaticResources.Count - 1] as StaticResource;
            } 
        } 

        public string KeyString 
        {
            get { return _data as String; }
        }
 
        public Type KeyType
        { 
            get { return _data as Type; } 
        }
 
        public XamlNodeList KeyNodeList
        {
            get
            { 
                return _data as XamlNodeList;
            } 
        } 

        private List _resources; 
        private object _data;
        bool _shared;
        bool _sharedSet;
    } 

    internal class StaticResource 
    { 

        public StaticResource(XamlType type, XamlSchemaContext schemaContext) 
        {
            ResourceNodeList = new XamlNodeList(schemaContext, 8);
            ResourceNodeList.Writer.WriteStartObject(type);
        } 

        public XamlNodeList ResourceNodeList { get; private set; } 
    } 

    internal class OptimizedStaticResource 
    {
        public OptimizedStaticResource(byte flags, short keyId)
        {
            _isType = (flags & TypeExtensionValueMask) != 0; 
            _isStatic = (flags & StaticExtensionValueMask) != 0;
 
            KeyId = keyId; 
        }
 
        public short KeyId { get; set; }

        public object KeyValue { get; set; }
 
        public bool IsKeyStaticExtension
        { 
            get { return _isStatic; } 
        }
        public bool IsKeyTypeExtension 
        {
            get { return _isType; }
        }
 
        private bool _isStatic;
        private bool _isType; 
 
        private static readonly byte TypeExtensionValueMask = 0x01;
        private static readonly byte StaticExtensionValueMask = 0x02; 
    }
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System; 
using System.Collections.Generic;
using System.Text;
using System.Xaml;
using System.Windows.Markup; 
using System.Diagnostics;
 
namespace System.Windows.Baml2006 
{
    [DebuggerDisplay("{DebuggerString}")] 
    internal class KeyRecord
    {
        public KeyRecord(bool shared, bool sharedSet, int valuePosition, Type keyType) :
            this(shared, sharedSet, valuePosition) 
        {
            _data = keyType; 
        } 

        public KeyRecord(bool shared, bool sharedSet, int valuePosition, string keyString) : 
            this(shared, sharedSet, valuePosition)
        {
            _data = keyString;
        } 

        public KeyRecord(bool shared, bool sharedSet, int valuePosition, XamlSchemaContext context) : 
            this(shared, sharedSet, valuePosition) 
        {
            _data = new XamlNodeList(context, 8); 
        }

        private KeyRecord(bool shared, bool sharedSet, int valuePosition)
        { 
            _shared = shared;
            _sharedSet = sharedSet; 
            ValuePosition = valuePosition; 
        }
 
        public bool Shared { get { return _shared; } }
        public bool SharedSet { get { return _sharedSet; } }
        public long ValuePosition { get; set; }
        public int ValueSize { get; set; } 
        public byte Flags { get; set; }
 
        // This can either be a StaticResource or an OptimizedStaticResource 
        // Since they don't share anything in common, we've made this a list of objects.
        public List StaticResources 
        {
            get
            {
                if (_resources == null) 
                {
                    _resources = new List(); 
                } 

                return _resources; 
            }
        }

        public bool HasStaticResources 
        {
            get { return (_resources != null && _resources.Count > 0); } 
        } 

        public StaticResource LastStaticResource 
        {
            get
            {
                Debug.Assert(StaticResources[StaticResources.Count - 1] is StaticResource); 
                return StaticResources[StaticResources.Count - 1] as StaticResource;
            } 
        } 

        public string KeyString 
        {
            get { return _data as String; }
        }
 
        public Type KeyType
        { 
            get { return _data as Type; } 
        }
 
        public XamlNodeList KeyNodeList
        {
            get
            { 
                return _data as XamlNodeList;
            } 
        } 

        private List _resources; 
        private object _data;
        bool _shared;
        bool _sharedSet;
    } 

    internal class StaticResource 
    { 

        public StaticResource(XamlType type, XamlSchemaContext schemaContext) 
        {
            ResourceNodeList = new XamlNodeList(schemaContext, 8);
            ResourceNodeList.Writer.WriteStartObject(type);
        } 

        public XamlNodeList ResourceNodeList { get; private set; } 
    } 

    internal class OptimizedStaticResource 
    {
        public OptimizedStaticResource(byte flags, short keyId)
        {
            _isType = (flags & TypeExtensionValueMask) != 0; 
            _isStatic = (flags & StaticExtensionValueMask) != 0;
 
            KeyId = keyId; 
        }
 
        public short KeyId { get; set; }

        public object KeyValue { get; set; }
 
        public bool IsKeyStaticExtension
        { 
            get { return _isStatic; } 
        }
        public bool IsKeyTypeExtension 
        {
            get { return _isType; }
        }
 
        private bool _isStatic;
        private bool _isType; 
 
        private static readonly byte TypeExtensionValueMask = 0x01;
        private static readonly byte StaticExtensionValueMask = 0x02; 
    }
}

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