Esempio n. 1
0
 public static AudioCodecOptionsUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new AudioCodecOptionsUnmarshaller();
     }
     return(instance);
 }
        public AudioParameters Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
                return null;

            AudioParameters audioParameters = new AudioParameters();

        
        
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            while (context.Read())
            {
              
              if (context.TestExpression("Codec", targetDepth))
              {
                context.Read();
                audioParameters.Codec = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("SampleRate", targetDepth))
              {
                context.Read();
                audioParameters.SampleRate = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("BitRate", targetDepth))
              {
                context.Read();
                audioParameters.BitRate = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("Channels", targetDepth))
              {
                context.Read();
                audioParameters.Channels = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("CodecOptions", targetDepth))
              {
                context.Read();
                audioParameters.CodecOptions = AudioCodecOptionsUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
                if (context.CurrentDepth <= originalDepth)
                {
                    return audioParameters;
                }
            }
          

            return audioParameters;
        }