コード例 #1
0
        /// <summary>
        /// Validates whether facets are declared correctly.
        /// </summary>
        /// <param name="element">Schema element being validated. Must not be null.</param>
        /// <param name="type">Resolved type (from declaration on the element). Possibly null.</param>
        /// <param name="typeUsageBuilder">TypeUsageBuilder for the current element. Must not be null.</param>
        internal static void ValidateFacets(SchemaElement element, SchemaType type, TypeUsageBuilder typeUsageBuilder)
        {
            Debug.Assert(element != null);
            Debug.Assert(typeUsageBuilder != null);

            if (type != null)
            {
                var schemaEnumType = type as SchemaEnumType;
                if (schemaEnumType != null)
                {
                    typeUsageBuilder.ValidateEnumFacets(schemaEnumType);
                }
                else if(!(type is ScalarType) && typeUsageBuilder.HasUserDefinedFacets)
                {
                    Debug.Assert(!(type is SchemaEnumType), "Note that enums should have already been handled.");

                    // Non-scalar type should not have Facets. 
                    element.AddError(ErrorCode.FacetOnNonScalarType, EdmSchemaErrorSeverity.Error, Strings.FacetsOnNonScalarType(type.FQName));
                }
            }
            else
            {
                if(typeUsageBuilder.HasUserDefinedFacets)
                {
                    // Type attribute not specified but facets exist.
                    element.AddError(ErrorCode.IncorrectlyPlacedFacet, EdmSchemaErrorSeverity.Error, Strings.FacetDeclarationRequiresTypeAttribute);
                }
            }
        }
コード例 #2
0
ファイル: ModelFunction.cs プロジェクト: uQr/referencesource
 /// <summary>
 /// ctor for a schema function
 /// </summary>
 public ModelFunction(Schema parentElement)
     :
     base(parentElement)
 {
     _isComposable = true;
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #3
0
ファイル: ModelFunction.cs プロジェクト: dox0/DotNet471RS3
 /// <summary>
 /// ctor for a schema function
 /// </summary>
 public ModelFunction(Schema parentElement)
     :
     base(parentElement)
 {
     _isComposable     = true;
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #4
0
        /// <summary>
        /// Validates whether facets are declared correctly.
        /// </summary>
        /// <param name="element">Schema element being validated. Must not be null.</param>
        /// <param name="type">Resolved type (from declaration on the element). Possibly null.</param>
        /// <param name="typeUsageBuilder">TypeUsageBuilder for the current element. Must not be null.</param>
        internal static void ValidateFacets(SchemaElement element, SchemaType type, TypeUsageBuilder typeUsageBuilder)
        {
            Debug.Assert(element != null);
            Debug.Assert(typeUsageBuilder != null);

            if (type != null)
            {
                var schemaEnumType = type as SchemaEnumType;
                if (schemaEnumType != null)
                {
                    typeUsageBuilder.ValidateEnumFacets(schemaEnumType);
                }
                else if (!(type is ScalarType) && typeUsageBuilder.HasUserDefinedFacets)
                {
                    Debug.Assert(!(type is SchemaEnumType), "Note that enums should have already been handled.");

                    // Non-scalar type should not have Facets.
                    element.AddError(ErrorCode.FacetOnNonScalarType, EdmSchemaErrorSeverity.Error, Strings.FacetsOnNonScalarType(type.FQName));
                }
            }
            else
            {
                if (typeUsageBuilder.HasUserDefinedFacets)
                {
                    // Type attribute not specified but facets exist.
                    element.AddError(ErrorCode.IncorrectlyPlacedFacet, EdmSchemaErrorSeverity.Error, Strings.FacetDeclarationRequiresTypeAttribute);
                }
            }
        }
コード例 #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parentElement"></param>
 internal Parameter(Function parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #6
0
        //private static System.Text.RegularExpressions.Regex _binaryValueValidator = new System.Text.RegularExpressions.Regex("0[xX][0-9a-fA-F]+");
        #endregion
        #region Public Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentElement"></param>
        internal StructuredProperty(StructuredType parentElement)
            : base(parentElement)
        {
            _typeUsageBuilder = new TypeUsageBuilder(this);
        }
コード例 #7
0
 internal RowTypePropertyElement(SchemaElement parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #8
0
 internal ModelFunctionTypeElement(SchemaElement parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);  
 }
コード例 #9
0
ファイル: ReturnType.cs プロジェクト: uQr/referencesource
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parentElement"></param>
 internal ReturnType(Function parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #10
0
 internal RowTypePropertyElement(SchemaElement parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="parentElement"></param>
 internal Parameter(Function parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #12
0
        //private static System.Text.RegularExpressions.Regex _binaryValueValidator = new System.Text.RegularExpressions.Regex("0[xX][0-9a-fA-F]+");
        #endregion
        #region Public Methods

        /// <summary>
        ///
        /// </summary>
        /// <param name="parentElement"></param>
        internal StructuredProperty(StructuredType parentElement)
            : base(parentElement)
        {
            _typeUsageBuilder = new TypeUsageBuilder(this);
        }
コード例 #13
0
 internal ModelFunctionTypeElement(SchemaElement parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
コード例 #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="parentElement"></param>
 internal ReturnType(Function parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }