/// <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);
                }
            }
        }
 /// <summary>
 /// ctor for a schema function
 /// </summary>
 public ModelFunction(Schema parentElement)
     :
         base(parentElement)
 {
     _isComposable = true;
     _typeUsageBuilder = new TypeUsageBuilder(this);
 }
Example #3
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)
        {
            DebugCheck.NotNull(element);
            DebugCheck.NotNull(typeUsageBuilder);

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