コード例 #1
0
        private Exception CheckBuiltInFacets(string s, XmlTypeCode typeCode, bool verifyUri)
        {
            Exception exception = null;

            switch (typeCode)
            {
            case XmlTypeCode.AnyUri:

                if (verifyUri)
                {
                    Uri uri = null;
                    exception = XmlConvertExt.TryToUri(s, out uri);
                }
                break;

            case XmlTypeCode.NormalizedString:
                exception = XmlConvertExt.VerifyNormalizedString(s);
                break;

            case XmlTypeCode.Token:
                try
                {
                    XmlConvert.VerifyTOKEN(s);
                }
                catch (Exception e)
                {
                    exception = e;
                }
                break;

            case XmlTypeCode.Language:
                if (s == null || s.Length == 0)
                {
                    exception = new LinqToXsdException();
                }
                if (!LanguagePattern.IsMatch(s))
                {
                    exception = new LinqToXsdException();
                }
                break;

            case XmlTypeCode.NmToken:
                try
                {
                    XmlConvert.VerifyNMTOKEN(s);
                }
                catch (Exception e)
                {
                    exception = e;
                }
                break;

            case XmlTypeCode.Name:
                try
                {
                    XmlConvert.VerifyName(s);
                }
                catch (Exception e) {
                    exception = e;
                }

                break;

            case XmlTypeCode.NCName:
            case XmlTypeCode.Id:
            case XmlTypeCode.Idref:
            case XmlTypeCode.Entity:
                try
                {
                    XmlConvert.VerifyNCName(s);
                }
                catch (Exception e)
                {
                    exception = e;
                }
                break;

            default:
                break;
            }
            return(exception);
        }
コード例 #2
0
        private Exception CheckBuiltInFacets(string s, XmlTypeCode typeCode, bool verifyUri)
        {
            Exception exception = null;

            switch (typeCode)
            {
            case XmlTypeCode.AnyUri:
            {
                if (verifyUri)
                {
                    Uri uri = null;
                    exception = XmlConvertExt.TryToUri(s, out uri);
                }
                break;
            }

            case XmlTypeCode.QName:
            case XmlTypeCode.Notation:
            {
                break;
            }

            case XmlTypeCode.NormalizedString:
            {
                exception = XmlConvertExt.VerifyNormalizedString(s);
                break;
            }

            case XmlTypeCode.Token:
            {
                try
                {
                    XmlConvert.VerifyTOKEN(s);
                }
                catch (Exception exception1)
                {
                    exception = exception1;
                }
                break;
            }

            case XmlTypeCode.Language:
            {
                if ((s == null ? true : s.Length == 0))
                {
                    exception = new LinqToXsdException();
                }
                if (!Xml.Schema.Linq.StringFacetsChecker.LanguagePattern.IsMatch(s))
                {
                    exception = new LinqToXsdException();
                }
                break;
            }

            case XmlTypeCode.NmToken:
            {
                try
                {
                    XmlConvert.VerifyNMTOKEN(s);
                }
                catch (Exception exception2)
                {
                    exception = exception2;
                }
                break;
            }

            case XmlTypeCode.Name:
            {
                try
                {
                    XmlConvert.VerifyName(s);
                }
                catch (Exception exception3)
                {
                    exception = exception3;
                }
                break;
            }

            case XmlTypeCode.NCName:
            case XmlTypeCode.Id:
            case XmlTypeCode.Idref:
            case XmlTypeCode.Entity:
            {
                try
                {
                    XmlConvert.VerifyNCName(s);
                }
                catch (Exception exception4)
                {
                    exception = exception4;
                }
                break;
            }

            default:
            {
                goto case XmlTypeCode.Notation;
            }
            }
            return(exception);
        }