Example #1
0
        internal static INode TryResolveUri(IResultsParserContext context, IToken t)
        {
            switch (t.TokenType)
            {
            case Token.URI:
                try
                {
                    String uri = Tools.ResolveUri(t.Value, String.Empty);
                    return(context.Handler.CreateUriNode(UriFactory.Create(uri)));
                }
#if PORTABLE
                catch (FormatException formatEx)
#else
                catch (UriFormatException formatEx)
#endif
                {
                    throw new RdfParseException("Unable to resolve the URI '" + t.Value + "' due to the following error:\n" + formatEx.Message, t, formatEx);
                }
                catch (RdfException rdfEx)
                {
                    throw new RdfParseException("Unable to resolve the URI '" + t.Value + "' due to the following error:\n" + rdfEx.Message, t, rdfEx);
                }

            default:
                throw ParserHelper.Error("Unexpected Token '" + t.GetType().ToString() + "' encountered, expected a URI/QName Token to resolve into a URI", t);
            }
        }
        private void Parse(IResultsParserContext context, String data)
        {
            try
            {
                context.Handler.StartResults();

                bool result;
                if (Boolean.TryParse(data.Trim(), out result))
                {
                    context.Handler.HandleBooleanResult(result);
                }
                else
                {
                    throw new RdfParseException("The input was not a single boolean value as a String");
                }

                context.Handler.EndResults(true);
            }
            catch (RdfParsingTerminatedException)
            {
                context.Handler.EndResults(true);
            }
            catch
            {
                context.Handler.EndResults(false);
                throw;
            }
        }
Example #3
0
 internal static INode TryResolveUri(IResultsParserContext context, String value)
 {
     try
     {
         String uri = Tools.ResolveUri(value, String.Empty);
         return(context.Handler.CreateUriNode(UriFactory.Create(uri)));
     }
     catch (UriFormatException formatEx)
     {
         throw new RdfParseException("Unable to resolve the URI '" + value + "' due to the following error:\n" + formatEx.Message, formatEx);
     }
     catch (RdfException rdfEx)
     {
         throw new RdfParseException("Unable to resolve the URI '" + value + "' due to the following error:\n" + rdfEx.Message, rdfEx);
     }
 }
 private void Parse(IResultsParserContext context, TextReader input)
 {
     Parse(context, input.ReadToEnd());
 }
Example #5
0
        internal static INode TryResolveUri(IResultsParserContext context, IToken t)
        {
            switch (t.TokenType)
            {
                case Token.URI:
                    try
                    {
                        String uri = Tools.ResolveUri(t.Value, String.Empty);
                        return context.Handler.CreateUriNode(UriFactory.Create(uri));
                    }
                    catch (UriFormatException formatEx)
                    {
                        throw new RdfParseException("Unable to resolve the URI '" + t.Value + "' due to the following error:\n" + formatEx.Message, t, formatEx);
                    }
                    catch (RdfException rdfEx)
                    {
                        throw new RdfParseException("Unable to resolve the URI '" + t.Value + "' due to the following error:\n" + rdfEx.Message, t, rdfEx);
                    }

                default:
                    throw ParserHelper.Error("Unexpected Token '" + t.GetType().ToString() + "' encountered, expected a URI/QName Token to resolve into a URI", t);
            }
        }
        private void Parse(IResultsParserContext context, String data)
        {
            try
            {
                context.Handler.StartResults();

                bool result;
                if (Boolean.TryParse(data.Trim(), out result))
                {
                    context.Handler.HandleBooleanResult(result);
                }
                else
                {
                    throw new RdfParseException("The input was not a single boolean value as a String");
                }

                context.Handler.EndResults(true);
            }
            catch (RdfParsingTerminatedException)
            {
                context.Handler.EndResults(true);
            }
            catch
            {
                context.Handler.EndResults(false);
                throw;
            }
        }
 private void Parse(IResultsParserContext context, TextReader input)
 {
     this.Parse(context, input.ReadToEnd());
 }