Example #1
0
 private IJSONDocument LoadFromSource(JSONSource source)
 {
     currentSource = source;
     using ( currentSource )
     {
         if (source.ReadNextChar() < 0)
         {
             throw new JSONException("unexpected end met");
         }
         currentDoc = JSONDocument.CreateDocument();
         try
         {
             var root = ReadValue();
             // TODO read til end?
             currentDoc.Root = root;
             var cd = currentDoc;
             currentDoc    = null;
             currentSource = null;
             return(cd);
         } catch (InvalidOperationException e)
         {
             throw new JSONException("Invalid Operation @ " + currentSource.pos, e);
         }
         catch (ArgumentException e)
         {
             throw new JSONException("Invalid Argument @ " + currentSource.pos, e);
         }
     }
 }
        public void BadJSONTest()
        {
            FileProcessor fileProcessor = new FileProcessor();

            IFileSource fileSource = new JSONSource();

            Assert.False(fileSource.CanProcess("disk:\\folder\\file.xml"));
        }
        public void OkayJSONTest()
        {
            FileProcessor fileProcessor = new FileProcessor();

            IFileSource fileSource = new JSONSource();

            Assert.True(fileSource.CanProcess("disk:\\folder\\file.json"));
        }