/// <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
 /// <summary>
 /// ctor for a schema function
 /// </summary>
 public ModelFunction(Schema parentElement)
     :
     base(parentElement)
 {
     _isComposable = true;
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
Пример #3
0
 /// <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);
 }
        //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);
 }
 internal ModelFunctionTypeElement(SchemaElement parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);  
 }
Пример #9
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="parentElement"></param>
 internal ReturnType(Function parentElement)
     : base(parentElement)
 {
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
 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);
        }
 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);
 }