Esempio n. 1
0
        private IEnumerable <XAttribute> GenerateTypeFacets(DataType dataType, Type[] facetsToIgnore)
        {
            PrimitiveDataType pdt    = dataType as PrimitiveDataType;
            List <XAttribute> facets = new List <XAttribute>();

            if (pdt != null)
            {
                MaxLengthFacet        maxLengthFacet;
                NumericScaleFacet     numericScaleFacet;
                NumericPrecisionFacet numericPrecisionFacet;
                TimePrecisionFacet    timePrecisionFacet;
                IsUnicodeFacet        isUnicodeFacet;
                SridFacet             sridFacet;

                if (!facetsToIgnore.Contains(typeof(MaxLengthFacet)) && pdt.TryGetFacet(out maxLengthFacet))
                {
                    facets.Add(new XAttribute("MaxLength", maxLengthFacet.Value));
                }

                if (!facetsToIgnore.Contains(typeof(NumericPrecisionFacet)) && pdt.TryGetFacet(out numericPrecisionFacet))
                {
                    facets.Add(new XAttribute("Precision", numericPrecisionFacet.Value));
                }

                if (!facetsToIgnore.Contains(typeof(NumericScaleFacet)) && pdt.TryGetFacet(out numericScaleFacet))
                {
                    facets.Add(new XAttribute("Scale", numericScaleFacet.Value));
                }

                if (!facetsToIgnore.Contains(typeof(TimePrecisionFacet)) && pdt.TryGetFacet(out timePrecisionFacet))
                {
                    facets.Add(new XAttribute("Precision", timePrecisionFacet.Value));
                }

                if (!facetsToIgnore.Contains(typeof(IsUnicodeFacet)) && pdt.TryGetFacet(out isUnicodeFacet))
                {
                    facets.Add(new XAttribute("Unicode", isUnicodeFacet.Value));
                }

                if (!facetsToIgnore.Contains(typeof(SridFacet)) && pdt.TryGetFacet(out sridFacet))
                {
                    facets.Add(new XAttribute("SRID", sridFacet.Value));
                }
            }

            return(facets);
        }