NavigationProperty.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / NavigationProperty.cs / 2 / NavigationProperty.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....], [....]
//--------------------------------------------------------------------- 
using System.Collections.Generic; 
using System.Data.Common;
using System.Diagnostics; 
using System.Threading;

namespace System.Data.Metadata.Edm
{ 
    /// 
    /// Represent the edm navigation property class 
    ///  
    public sealed class NavigationProperty : EdmMember
    { 
        #region Constructors
        /// 
        /// Initializes a new instance of the navigation property class
        ///  
        /// name of the navigation property
        /// TypeUsage object containing the navigation property type and its facets 
        /// Thrown if name or typeUsage arguments are null 
        /// Thrown if name argument is empty string
        internal NavigationProperty(string name, TypeUsage typeUsage) 
            : base(name, typeUsage)
        {
            EntityUtil.CheckStringArgument(name, "name");
            EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage"); 
        }
 
        ///  
        /// Initializes a new OSpace instance of the property class
        ///  
        /// name of the property
        /// TypeUsage object containing the property type and its facets
        /// for the property
        internal NavigationProperty(string name, TypeUsage typeUsage, System.Reflection.PropertyInfo propertyInfo) 
            : this(name, typeUsage)
        { 
            System.Diagnostics.Debug.Assert(name == propertyInfo.Name, "different PropertyName?"); 
            if (null != propertyInfo)
            { 
                System.Reflection.MethodInfo method;

                method = propertyInfo.GetGetMethod();
                PropertyGetterHandle = ((null != method) ? method.MethodHandle : default(System.RuntimeMethodHandle)); 
            }
        } 
        #endregion 

        ///  
        /// Returns the kind of the type
        /// 
        public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.NavigationProperty; } }
 
        #region Fields
        internal const string RelationshipTypeNamePropertyName = "RelationshipType"; 
        internal const string ToEndMemberNamePropertyName = "ToEndMember"; 
        private RelationshipType _relationshipType;
        private RelationshipEndMember _toEndMember; 
        private RelationshipEndMember _fromEndMember;

        /// Store the handle, allowing the PropertyInfo/MethodInfo/Type references to be GC'd
        internal readonly System.RuntimeMethodHandle PropertyGetterHandle; 

        /// cached dynamic method to get the property value from a CLR instance 
        private Func _memberGetter; 
        #endregion
 
        /// 
        /// Gets/Sets the relationship type that this navigation property operates on
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state 
        [MetadataProperty(BuiltInTypeKind.RelationshipType, false)]
        public RelationshipType RelationshipType 
        { 
            get
            { 
                return _relationshipType;
            }
            internal set
            { 
                _relationshipType = value;
            } 
        } 

        ///  
        /// Gets/Sets the to relationship end member in the navigation
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state
        [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] 
        public RelationshipEndMember ToEndMember
        { 
            get 
            {
                return _toEndMember; 
            }
            internal set
            {
                _toEndMember = value; 
            }
        } 
 
        /// 
        /// Gets/Sets the from relationship end member in the navigation 
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state
        [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
        public RelationshipEndMember FromEndMember 
        {
            get 
            { 
                return _fromEndMember;
            } 
            internal set
            {
                _fromEndMember = value;
            } 
        }
 
        /// cached dynamic method to get the property value from a CLR instance 
        internal Func ValueGetter
        { 
            get { return _memberGetter; }
            set
            {
                System.Diagnostics.Debug.Assert(null != value, "clearing ValueGetter"); 
                // It doesn't matter which delegate wins, but only one should be jitted
                Interlocked.CompareExchange(ref _memberGetter, value, null); 
            } 
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
// 
// @owner  [....], [....]
//--------------------------------------------------------------------- 
using System.Collections.Generic; 
using System.Data.Common;
using System.Diagnostics; 
using System.Threading;

namespace System.Data.Metadata.Edm
{ 
    /// 
    /// Represent the edm navigation property class 
    ///  
    public sealed class NavigationProperty : EdmMember
    { 
        #region Constructors
        /// 
        /// Initializes a new instance of the navigation property class
        ///  
        /// name of the navigation property
        /// TypeUsage object containing the navigation property type and its facets 
        /// Thrown if name or typeUsage arguments are null 
        /// Thrown if name argument is empty string
        internal NavigationProperty(string name, TypeUsage typeUsage) 
            : base(name, typeUsage)
        {
            EntityUtil.CheckStringArgument(name, "name");
            EntityUtil.GenericCheckArgumentNull(typeUsage, "typeUsage"); 
        }
 
        ///  
        /// Initializes a new OSpace instance of the property class
        ///  
        /// name of the property
        /// TypeUsage object containing the property type and its facets
        /// for the property
        internal NavigationProperty(string name, TypeUsage typeUsage, System.Reflection.PropertyInfo propertyInfo) 
            : this(name, typeUsage)
        { 
            System.Diagnostics.Debug.Assert(name == propertyInfo.Name, "different PropertyName?"); 
            if (null != propertyInfo)
            { 
                System.Reflection.MethodInfo method;

                method = propertyInfo.GetGetMethod();
                PropertyGetterHandle = ((null != method) ? method.MethodHandle : default(System.RuntimeMethodHandle)); 
            }
        } 
        #endregion 

        ///  
        /// Returns the kind of the type
        /// 
        public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.NavigationProperty; } }
 
        #region Fields
        internal const string RelationshipTypeNamePropertyName = "RelationshipType"; 
        internal const string ToEndMemberNamePropertyName = "ToEndMember"; 
        private RelationshipType _relationshipType;
        private RelationshipEndMember _toEndMember; 
        private RelationshipEndMember _fromEndMember;

        /// Store the handle, allowing the PropertyInfo/MethodInfo/Type references to be GC'd
        internal readonly System.RuntimeMethodHandle PropertyGetterHandle; 

        /// cached dynamic method to get the property value from a CLR instance 
        private Func _memberGetter; 
        #endregion
 
        /// 
        /// Gets/Sets the relationship type that this navigation property operates on
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state 
        [MetadataProperty(BuiltInTypeKind.RelationshipType, false)]
        public RelationshipType RelationshipType 
        { 
            get
            { 
                return _relationshipType;
            }
            internal set
            { 
                _relationshipType = value;
            } 
        } 

        ///  
        /// Gets/Sets the to relationship end member in the navigation
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state
        [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)] 
        public RelationshipEndMember ToEndMember
        { 
            get 
            {
                return _toEndMember; 
            }
            internal set
            {
                _toEndMember = value; 
            }
        } 
 
        /// 
        /// Gets/Sets the from relationship end member in the navigation 
        /// 
        /// Thrown if the NavigationProperty instance is in ReadOnly state
        [MetadataProperty(BuiltInTypeKind.RelationshipEndMember, false)]
        public RelationshipEndMember FromEndMember 
        {
            get 
            { 
                return _fromEndMember;
            } 
            internal set
            {
                _fromEndMember = value;
            } 
        }
 
        /// cached dynamic method to get the property value from a CLR instance 
        internal Func ValueGetter
        { 
            get { return _memberGetter; }
            set
            {
                System.Diagnostics.Debug.Assert(null != value, "clearing ValueGetter"); 
                // It doesn't matter which delegate wins, but only one should be jitted
                Interlocked.CompareExchange(ref _memberGetter, value, null); 
            } 
        }
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

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