private static Dictionary <string, object> TryParsing(IMetarChunkDecoder chunkDecoder, bool strict, string remainingMetar, bool withCavok)
        {
            Dictionary <string, object> decoded;

            try
            {
                decoded = chunkDecoder.Parse(remainingMetar, withCavok);
            }
            catch (MetarChunkDecoderException primaryException)
            {
                if (strict)
                {
                    throw;
                }
                else
                {
                    try
                    {
                        //the PHP version of ConsumeOneChunk implements an additional, unused strict flag
                        var alternativeRemainingMetar = MetarChunkDecoder.ConsumeOneChunk(remainingMetar);
                        decoded = chunkDecoder.Parse(alternativeRemainingMetar, withCavok);
                        decoded.Add(ExceptionKey, primaryException);
                    }
                    catch (MetarChunkDecoderException)
                    {
                        throw primaryException;
                    }
                }
            }
            return(decoded);
        }
예제 #2
0
        public void ConsumeOneChunkTest()
        {
            var result = MetarChunkDecoder.ConsumeOneChunk(TestMetarSource[0]);

            Assert.AreEqual("231027Z AUTO 24004G09MPS 2500 1000NW R32/0400 R08C/0004D +FZRA VCSN //FEW015 17/10 Q1009 REFZRA WS R03", result);
        }
예제 #3
0
 public MetarChunkDecoderException(string remainingMetar, string newRemainingMetar, string message, MetarChunkDecoder chunkDecoder) : base(message)
 {
     RemainingMetar    = remainingMetar;
     NewRemainingMetar = newRemainingMetar;
     ChunkDecoder      = chunkDecoder;
 }