protected override void finish()
        {
            FoodJSON result = new FoodJSON();

            Debug.Assert(result != null);
            finish(result);
            handle_result(result);
        }
Beispiel #2
0
    private void  fromJSONFoodBlocks(JSONValue json_value, bool ignore_extras)
    {
        Debug.Assert(json_value != null);
        JSONArrayValue json_array1 = json_value.array_value();

        if (json_array1 == null)
        {
            throw new Exception("The value for field FoodBlocks of NutritionInformationNuggetJSON is not an array.");
        }
        int count1 = json_array1.componentCount();
        List <List <FoodJSON> > vector_FoodBlocks1 = new List <List <FoodJSON> >(count1);

        for (int num1 = 0; num1 < count1; ++num1)
        {
            JSONArrayValue json_array2 = json_array1.component(num1).array_value();
            if (json_array2 == null)
            {
                throw new Exception("The value for an element of field FoodBlocks of NutritionInformationNuggetJSON is not an array.");
            }
            int             count2             = json_array2.componentCount();
            List <FoodJSON> vector_FoodBlocks2 = new List <FoodJSON>(count2);
            for (int num2 = 0; num2 < count2; ++num2)
            {
                FoodJSON convert_classy = FoodJSON.from_json(json_array2.component(num2), ignore_extras, true);
                vector_FoodBlocks2.Add(convert_classy);
            }
            vector_FoodBlocks1.Add(vector_FoodBlocks2);
        }
        initFoodBlocks();
        for (int num2 = 0; num2 < vector_FoodBlocks1.Count; ++num2)
        {
            appendFoodBlocks(vector_FoodBlocks1[num2]);
        }
        for (int num1 = 0; num1 < vector_FoodBlocks1.Count; ++num1)
        {
            for (int num2 = 0; num2 < vector_FoodBlocks1[num1].Count; ++num2)
            {
            }
        }
    }
 protected override void handle_result(FoodJSON result)
 {
     top.value.Add(result);
 }
        protected override void handle_result(FoodJSON result)
        {
//@@@            Debug.Assert(!have_value);
            have_value = true;
            value      = result;
        }
 protected abstract void handle_result(FoodJSON new_result);
 protected void finish(FoodJSON result)
 {
     if (fieldGeneratorID.have_value)
     {
         result.setID(fieldGeneratorID.value);
         fieldGeneratorID.have_value = false;
     }
     else if ((!(result.hasID())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"ID\" field was missing.");
     }
     if (fieldGeneratorQuantity.have_value)
     {
         result.setQuantityText(fieldGeneratorQuantity.value);
         fieldGeneratorQuantity.have_value = false;
     }
     else if ((!(result.hasQuantity())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"Quantity\" field was missing.");
     }
     if (fieldGeneratorNDB_No.have_value)
     {
         result.setNDB_No(fieldGeneratorNDB_No.value);
         fieldGeneratorNDB_No.have_value = false;
     }
     else if ((!(result.hasNDB_No())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"NDB_No\" field was missing.");
     }
     if (fieldGeneratorSizeIndex.have_value)
     {
         result.setSizeIndex(fieldGeneratorSizeIndex.value);
         fieldGeneratorSizeIndex.have_value = false;
     }
     else if ((!(result.hasSizeIndex())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"SizeIndex\" field was missing.");
     }
     if (fieldGeneratorNameIncludesUnits.have_value)
     {
         result.setNameIncludesUnits(fieldGeneratorNameIncludesUnits.value);
         fieldGeneratorNameIncludesUnits.have_value = false;
     }
     else if ((!(result.hasNameIncludesUnits())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"NameIncludesUnits\" field was missing.");
     }
     if (fieldGeneratorExclude.have_value)
     {
         result.setExclude(fieldGeneratorExclude.value);
         fieldGeneratorExclude.have_value = false;
     }
     else if ((!(result.hasExclude())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"Exclude\" field was missing.");
     }
     if (fieldGeneratorSpokenNoSize.have_value)
     {
         result.setSpokenNoSize(fieldGeneratorSpokenNoSize.value);
         fieldGeneratorSpokenNoSize.have_value = false;
     }
     else if ((!(result.hasSpokenNoSize())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"SpokenNoSize\" field was missing.");
     }
     if (fieldGeneratorWrittenNoSize.have_value)
     {
         result.setWrittenNoSize(fieldGeneratorWrittenNoSize.value);
         fieldGeneratorWrittenNoSize.have_value = false;
     }
     else if ((!(result.hasWrittenNoSize())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"WrittenNoSize\" field was missing.");
     }
     if (fieldGeneratorWikiUrl.have_value)
     {
         result.setWikiUrl(fieldGeneratorWikiUrl.value);
         fieldGeneratorWikiUrl.have_value = false;
     }
     else if ((!(result.hasWikiUrl())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"WikiUrl\" field was missing.");
     }
     if (fieldGeneratorImageUrl.have_value)
     {
         result.setImageUrl(fieldGeneratorImageUrl.value);
         fieldGeneratorImageUrl.have_value = false;
     }
     else if ((!(result.hasImageUrl())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"ImageUrl\" field was missing.");
     }
     if (fieldGeneratorAllSizes.have_value)
     {
         result.initAllSizes();
         int count = fieldGeneratorAllSizes.value.Count;
         for (int num = 0; num < count; ++num)
         {
             result.appendAllSizes(fieldGeneratorAllSizes.value[num]);
         }
         fieldGeneratorAllSizes.value.Clear();
         fieldGeneratorAllSizes.have_value = false;
     }
     else if ((!(result.hasAllSizes())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"AllSizes\" field was missing.");
     }
     if (fieldGeneratorNutrients.have_value)
     {
         result.initNutrients();
         int count = fieldGeneratorNutrients.value.Count;
         for (int num = 0; num < count; ++num)
         {
             result.appendNutrients(fieldGeneratorNutrients.value[num]);
         }
         fieldGeneratorNutrients.value.Clear();
         fieldGeneratorNutrients.have_value = false;
     }
     else if ((!(result.hasNutrients())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"Nutrients\" field was missing.");
     }
     if (fieldGeneratorNutrientNameToID.have_value)
     {
         result.setNutrientNameToID(fieldGeneratorNutrientNameToID.value);
         fieldGeneratorNutrientNameToID.have_value = false;
     }
     else if ((!(result.hasNutrientNameToID())) && !allow_incomplete)
     {
         error("When parsing the object for %what%, the \"NutrientNameToID\" field was missing.");
     }
 }