ResourceContainer.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / Providers / ResourceContainer.cs / 1305376 / ResourceContainer.cs

                            //---------------------------------------------------------------------- 
// 
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//  
//      Contains information about a resource set.
//  
// 
// @owner  [....]
//--------------------------------------------------------------------- 

namespace System.Data.Services.Providers
{
    using System; 
    using System.Collections.Generic;
    using System.Diagnostics; 
    using System.Reflection; 

    ///  
    /// Structure to keep information about a resource set
    /// 
    /// 
    /// Custom providers can choose to use it as is or derive from it 
    /// in order to flow provider-specific data.
    ///  
    [DebuggerDisplay("{Name}: {ResourceType}")] 
    public class ResourceSet
    { 
        #region Fields
        ///  Reference to resource type that this resource set is a collection of
        private readonly ResourceType elementType;
 
        /// Name of the resource set.
        private readonly string name; 
 
        /// Cached delegate to read an IQueryable from the context.
        private Func readFromContextDelegate; 

        /// Is true, if the resource set is fully initialized and validated. No more changes can be made once its set to readonly.
        private bool isReadOnly;
 
        #endregion Fields
 
        #region Constructors 

        ///  
        /// Constructs a new ResourceSet instance using the specified name and ResourceType instance
        /// 
        /// name of the resource set
        /// Reference to clr type that this resource set is a collection of 
        public ResourceSet(string name, ResourceType elementType)
        { 
            WebUtil.CheckStringArgumentNull(name, "name"); 
            WebUtil.CheckArgumentNull(elementType, "elementType");
 
            if (elementType.ResourceTypeKind != ResourceTypeKind.EntityType)
            {
                throw new ArgumentException(Strings.ResourceContainer_ContainerMustBeAssociatedWithEntityType);
            } 

            this.name = name; 
            this.elementType = elementType; 
        }
 
        #endregion Constructors

        #region Properties
 
        /// Name of the resource set.
        public string Name 
        { 
            get { return this.name; }
        } 

        ///  Reference to resource type that this resource set is a collection of 
        public ResourceType ResourceType
        { 
            get { return this.elementType; }
        } 
 
        /// 
        /// PlaceHolder to hold custom state information about resource set. 
        /// 
        public object CustomState
        {
            get; 
            set;
        } 
 
        /// 
        /// Returns true, if this container has been set to read only. Otherwise returns false. 
        /// 
        public bool IsReadOnly
        {
            get { return this.isReadOnly; } 
        }
 
        /// Cached delegate to read an IQueryable from the context. 
        internal Func ReadFromContextDelegate
        { 
            get { return this.readFromContextDelegate; }
            set { this.readFromContextDelegate = value; }
        }
 
        #endregion Properties
 
        #region Methods 
        /// 
        /// Sets the resource set to readonly mode. resource sets cannot be updated once this property is set. 
        /// 
        public void SetReadOnly()
        {
            // If its already set to readonly, then its a no-op 
            if (this.isReadOnly)
            { 
                return; 
            }
 
            this.elementType.SetReadOnly();
            this.isReadOnly = true;
        }
 
        #endregion Methods
    } 
} 

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