FacetEnabledSchemaElement.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 / EntityModel / SchemaObjectModel / FacetEnabledSchemaElement.cs / 1 / FacetEnabledSchemaElement.cs

                            using System; 
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Metadata.Edm; 
using System.Diagnostics;
using System.Xml; 
 
namespace System.Data.EntityModel.SchemaObjectModel
{ 
    abstract class FacetEnabledSchemaElement : SchemaElement
    {
        protected SchemaType _type = null;
        protected string _unresolvedType = null; 
        protected TypeUsageBuilder _typeUsageBuilder;
 
        #region public properties 
        public new Function ParentElement
        { 
            get
            {
                return base.ParentElement as Function;
            } 
        }
 
        public SchemaType Type 
        {
            get 
            {
                return _type;
            }
        } 

        public TypeUsage TypeUsage 
        { 
            get
            { 
                return _typeUsageBuilder.TypeUsage;
            }
        }
 
        public bool HasUserDefinedFacets
        { 
            get 
            {
                return _typeUsageBuilder.HasUserDefinedFacets; 
            }
        }
        #endregion
 
        #region Internal Properties
        internal string UnresolvedType 
        { 
            get
            { 
                return _unresolvedType;
            }
            set
            { 
                _unresolvedType = value;
            } 
        } 
        #endregion
 
        #region Public Methods
        /// 
        ///
        ///  
        /// 
        internal FacetEnabledSchemaElement(Function parentElement) 
            : base(parentElement) 
        {
 
        }

        #endregion
 
        #region Internal Methods
        internal override void ResolveTopLevelNames() 
        { 
            base.ResolveTopLevelNames();
 
            Debug.Assert(this.Type == null, "This must be resolved exactly once");

            if (Schema.ResolveTypeName(this, UnresolvedType, out _type))
            { 
                if (!(_type is ScalarType))
                { 
                    AddError(ErrorCode.FunctionWithNonScalarTypeNotSupported, 
                             EdmSchemaErrorSeverity.Error,
                             this, 
                             System.Data.Entity.Strings.FunctionWithNonScalarTypeNotSupported(_type.FQName, this.ParentElement.FQName));
                    return;
                }
 
                if (_typeUsageBuilder.HasUserDefinedFacets)
                { 
                    bool isInProviderManifest = Schema.DataModel == SchemaDataModelOption.ProviderManifestModel; 
                    _typeUsageBuilder.ValidateAndSetTypeUsage((ScalarType)_type, !isInProviderManifest);
                } 
            }
        }
        #endregion
 
        protected override bool HandleAttribute(XmlReader reader)
        { 
            if (base.HandleAttribute(reader)) 
            {
                return true; 
            }
            else if (_typeUsageBuilder.HandleAttribute(reader))
            {
                return true; 
            }
 
            return false; 
        }
 
    }
}

// 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.Linq;
using System.Text;
using System.Data.Metadata.Edm; 
using System.Diagnostics;
using System.Xml; 
 
namespace System.Data.EntityModel.SchemaObjectModel
{ 
    abstract class FacetEnabledSchemaElement : SchemaElement
    {
        protected SchemaType _type = null;
        protected string _unresolvedType = null; 
        protected TypeUsageBuilder _typeUsageBuilder;
 
        #region public properties 
        public new Function ParentElement
        { 
            get
            {
                return base.ParentElement as Function;
            } 
        }
 
        public SchemaType Type 
        {
            get 
            {
                return _type;
            }
        } 

        public TypeUsage TypeUsage 
        { 
            get
            { 
                return _typeUsageBuilder.TypeUsage;
            }
        }
 
        public bool HasUserDefinedFacets
        { 
            get 
            {
                return _typeUsageBuilder.HasUserDefinedFacets; 
            }
        }
        #endregion
 
        #region Internal Properties
        internal string UnresolvedType 
        { 
            get
            { 
                return _unresolvedType;
            }
            set
            { 
                _unresolvedType = value;
            } 
        } 
        #endregion
 
        #region Public Methods
        /// 
        ///
        ///  
        /// 
        internal FacetEnabledSchemaElement(Function parentElement) 
            : base(parentElement) 
        {
 
        }

        #endregion
 
        #region Internal Methods
        internal override void ResolveTopLevelNames() 
        { 
            base.ResolveTopLevelNames();
 
            Debug.Assert(this.Type == null, "This must be resolved exactly once");

            if (Schema.ResolveTypeName(this, UnresolvedType, out _type))
            { 
                if (!(_type is ScalarType))
                { 
                    AddError(ErrorCode.FunctionWithNonScalarTypeNotSupported, 
                             EdmSchemaErrorSeverity.Error,
                             this, 
                             System.Data.Entity.Strings.FunctionWithNonScalarTypeNotSupported(_type.FQName, this.ParentElement.FQName));
                    return;
                }
 
                if (_typeUsageBuilder.HasUserDefinedFacets)
                { 
                    bool isInProviderManifest = Schema.DataModel == SchemaDataModelOption.ProviderManifestModel; 
                    _typeUsageBuilder.ValidateAndSetTypeUsage((ScalarType)_type, !isInProviderManifest);
                } 
            }
        }
        #endregion
 
        protected override bool HandleAttribute(XmlReader reader)
        { 
            if (base.HandleAttribute(reader)) 
            {
                return true; 
            }
            else if (_typeUsageBuilder.HandleAttribute(reader))
            {
                return true; 
            }
 
            return false; 
        }
 
    }
}

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