Ejemplo n.º 1
0
        public static XmlReader CreateReader(string readerType, XmlReader underlyingReader, bool enableNormalization, object eventHndlr, XmlReaderSettings settings, bool isFragment)
        {
            CError.WriteLineIgnore(readerType);
            ReaderType         type         = (ReaderType)Enum.Parse(typeof(ReaderType), readerType.ToUpperInvariant());
            CreateReaderParams readerParams = new CreateReaderParams(type);

            readerParams.InputType           = ReadOverload.XmlReader;
            readerParams.Input               = underlyingReader;
            readerParams.EnableNormalization = enableNormalization;
            readerParams.IsFragment          = isFragment;
            readerParams.Settings            = settings;

            return(CreateReader(readerParams));
        }
Ejemplo n.º 2
0
        public static XmlReaderSettings GetSettings(CreateReaderParams createParams)
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            if (createParams.Settings != null)
            {
                settings = createParams.Settings;
            }
            else
            {
                if (createParams.IsFragment)
                {
                    settings.ConformanceLevel = ConformanceLevel.Fragment;
                }
            }

            return(settings);
        }
Ejemplo n.º 3
0
 public static XmlParserContext GetParserContext(CreateReaderParams createParams)
 {
     if (createParams.ParserContext != null)
     {
         return(createParams.ParserContext);
     }
     else
     {
         if (createParams.BaseUri != null)
         {
             XmlParserContext parserContext = new XmlParserContext(null, null, null, null, null, null, createParams.BaseUri, null, XmlSpace.None);
             return(parserContext);
         }
         else
         {
             return(null);
         }
     }
 }
Ejemplo n.º 4
0
        public static XmlReader CreateReader(CreateReaderParams createParams)
        {
            switch (createParams.readerType)
            {
            case ReaderType.COREREADER:
            case ReaderType.COREVALIDATINGREADER:
                return(CreateFactoryReader(createParams));

            case ReaderType.CHARCHECKINGREADER:
                return(CreateCharCheckingReader(createParams));

            case ReaderType.SUBTREEREADER:
                return(CreateSubtreeReader(createParams));

            case ReaderType.WRAPPEDREADER:
                return(CreateWrappedReader(createParams));

            default:
                throw new CTestFailedException("Unsupported ReaderType");
            }
        }
Ejemplo n.º 5
0
        public static XmlReader CreateCharCheckingReader(CreateReaderParams createParams)
        {
            XmlReaderSettings settings      = GetSettings(createParams);
            XmlParserContext  parserContext = GetParserContext(createParams);
            XmlReader         r             = null;

            settings.CheckCharacters = false;
            XmlReaderSettings rs = settings.Clone();

            rs.CheckCharacters = true;
            switch (createParams.InputType)
            {
            case ReadOverload.String:
                r = Create(new StringReader((string)createParams.Input), settings, parserContext);
                return(Create(r, rs));

            case ReadOverload.URL:
                r = Create((string)createParams.Input, settings);
                return(Create(r, rs));

            case ReadOverload.Stream:
                r = Create((Stream)createParams.Input, settings, parserContext);
                return(Create(r, rs));

            case ReadOverload.TextReader:
                r = Create((TextReader)createParams.Input, settings, parserContext);
                return(Create(r, rs));

            case ReadOverload.XmlReader:
                r = Create((XmlReader)createParams.Input, settings);
                return(Create(r, rs));

            default:
                throw new CTestFailedException("Unknown ReadOverload");
            }
        }
Ejemplo n.º 6
0
        public static XmlReader CreateSubtreeReader(CreateReaderParams createParams)
        {
            XmlReaderSettings settings      = GetSettings(createParams);
            XmlParserContext  parserContext = GetParserContext(createParams);
            XmlReader         r             = null;

            switch (createParams.InputType)
            {
            case ReadOverload.String:
                r = Create(new StringReader((string)createParams.Input), settings, parserContext);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                return(r.ReadSubtree());

            case ReadOverload.URL:
                r = Create((string)createParams.Input, settings);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                return(r.ReadSubtree());

            case ReadOverload.Stream:
                r = Create((Stream)createParams.Input, settings, parserContext);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                return(r.ReadSubtree());

            case ReadOverload.TextReader:
                r = Create((TextReader)createParams.Input, settings, parserContext);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                return(r.ReadSubtree());

            case ReadOverload.XmlReader:
                r = Create((XmlReader)createParams.Input, settings);
                while (r.Read())
                {
                    if (r.NodeType == XmlNodeType.Element)
                    {
                        break;
                    }
                }
                return(r.ReadSubtree());

            default:
                throw new CTestFailedException("Unknown ReadOverload");
            }
        }
Ejemplo n.º 7
0
        public static XmlReader CreateFactoryReader(CreateReaderParams createParams)
        {
            XmlReaderSettings settings = GetSettings(createParams);
            XmlParserContext parserContext = GetParserContext(createParams);
            switch (createParams.InputType)
            {
                case ReadOverload.String:
                    return Create(new StringReader((string)createParams.Input), settings, parserContext);

                case ReadOverload.URL:
                    return Create((string)createParams.Input, settings, parserContext);

                case ReadOverload.Stream:
                    return Create((Stream)createParams.Input, settings, parserContext);

                case ReadOverload.TextReader:
                    return Create((TextReader)createParams.Input, settings, parserContext);

                case ReadOverload.XmlReader:
                    return Create((XmlReader)createParams.Input, settings);

                default:
                    throw new CTestFailedException("Unknown ReadOverload");
            }
        }
Ejemplo n.º 8
0
 public static XmlParserContext GetParserContext(CreateReaderParams createParams)
 {
     if (createParams.ParserContext != null)
         return createParams.ParserContext;
     else
     {
         if (createParams.BaseUri != null)
         {
             XmlParserContext parserContext = new XmlParserContext(null, null, null, null, null, null, createParams.BaseUri, null, XmlSpace.None);
             return parserContext;
         }
         else
         {
             return null;
         }
     }
 }
Ejemplo n.º 9
0
        public static XmlReaderSettings GetSettings(CreateReaderParams createParams)
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            if (createParams.Settings != null)
            {
                settings = createParams.Settings;
            }
            else
            {
                if (createParams.IsFragment)
                    settings.ConformanceLevel = ConformanceLevel.Fragment;
            }

            return settings;
        }
Ejemplo n.º 10
0
        public static XmlReader CreateSubtreeReader(CreateReaderParams createParams)
        {
            XmlReaderSettings settings = GetSettings(createParams);
            XmlParserContext parserContext = GetParserContext(createParams);
            XmlReader r = null;
            switch (createParams.InputType)
            {
                case ReadOverload.String:
                    r = Create(new StringReader((string)createParams.Input), settings, parserContext);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element)
                            break;
                    }
                    return r.ReadSubtree();

                case ReadOverload.URL:
                    r = Create((string)createParams.Input, settings);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element)
                            break;
                    }
                    return r.ReadSubtree();

                case ReadOverload.Stream:
                    r = Create((Stream)createParams.Input, settings, parserContext);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element)
                            break;
                    }
                    return r.ReadSubtree();

                case ReadOverload.TextReader:
                    r = Create((TextReader)createParams.Input, settings, parserContext);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element)
                            break;
                    }
                    return r.ReadSubtree();

                case ReadOverload.XmlReader:
                    r = Create((XmlReader)createParams.Input, settings);
                    while (r.Read())
                    {
                        if (r.NodeType == XmlNodeType.Element)
                            break;
                    }
                    return r.ReadSubtree();

                default:
                    throw new CTestFailedException("Unknown ReadOverload");
            }
        }
Ejemplo n.º 11
0
        public static XmlReader CreateCharCheckingReader(CreateReaderParams createParams)
        {
            XmlReaderSettings settings = GetSettings(createParams);
            XmlParserContext parserContext = GetParserContext(createParams);
            XmlReader r = null;
            settings.CheckCharacters = false;
            XmlReaderSettings rs = settings.Clone();
            rs.CheckCharacters = true;
            switch (createParams.InputType)
            {
                case ReadOverload.String:
                    r = Create(new StringReader((string)createParams.Input), settings, parserContext);
                    return Create(r, rs);

                case ReadOverload.URL:
                    r = Create((string)createParams.Input, settings);
                    return Create(r, rs);

                case ReadOverload.Stream:
                    r = Create((Stream)createParams.Input, settings, parserContext);
                    return Create(r, rs);

                case ReadOverload.TextReader:
                    r = Create((TextReader)createParams.Input, settings, parserContext);
                    return Create(r, rs);

                case ReadOverload.XmlReader:
                    r = Create((XmlReader)createParams.Input, settings);
                    return Create(r, rs);

                default:
                    throw new CTestFailedException("Unknown ReadOverload");
            }
        }
Ejemplo n.º 12
0
        public static XmlReader CreateReader(CreateReaderParams createParams)
        {
            switch (createParams.readerType)
            {
                case ReaderType.COREREADER:
                case ReaderType.COREVALIDATINGREADER:
                    return CreateFactoryReader(createParams);

                case ReaderType.CHARCHECKINGREADER:
                    return CreateCharCheckingReader(createParams);
                case ReaderType.SUBTREEREADER:
                    return CreateSubtreeReader(createParams);
                case ReaderType.WRAPPEDREADER:
                    return CreateWrappedReader(createParams);

                default:
                    throw new CTestFailedException("Unsupported ReaderType");
            }
        }
Ejemplo n.º 13
0
        public static XmlReader CreateReader(string readerType, XmlReader underlyingReader, bool enableNormalization, object eventHndlr, XmlReaderSettings settings, bool isFragment)
        {
            CError.WriteLineIgnore(readerType);
            ReaderType type = (ReaderType)Enum.Parse(typeof(ReaderType), readerType.ToUpperInvariant());
            CreateReaderParams readerParams = new CreateReaderParams(type);
            readerParams.InputType = ReadOverload.XmlReader;
            readerParams.Input = underlyingReader;
            readerParams.EnableNormalization = enableNormalization;
            readerParams.IsFragment = isFragment;
            readerParams.Settings = settings;

            return CreateReader(readerParams);
        }