Пример #1
0
    /// <summary>
    /// Initializes the journal dictionary.
    /// </summary>
    private void InitializeJournalDictionary()
    {
        JSONNode json = JSON_IO.ReadJSON("journalItems");

        journalTable = new Hashtable();
        for (int i = 0; i < json.Count; i++)           //Iteract through phases in the .json
        {
            ExperimentsState.Stage[] setOfStages = new ExperimentsState.Stage[json[i].Count];
            for (int j = 0; j < json[i].Count; j++)               //Iteract through the stages in the phase i
            {
                setOfStages [j]       = new ExperimentsState.Stage();
                setOfStages [j].name  = json [i][j] ["name"];
                setOfStages [j].steps = new ExperimentsState.JournalStep[json [i][j]["steps"].Count];
                for (int k = 0; k < json [i][j] ["steps"].Count; k++)                   //Iteract through the steps of stage j
                {
                    setOfStages [j].steps [k]      = new ExperimentsState.JournalStep();
                    setOfStages [j].steps [k].text = json [i][j] ["steps"][k]["text"].Value;
                    if (json [i] [j] ["steps"] [k] ["isDone"].AsBool != null)
                    {
                        setOfStages [j].steps [k].isDone = json [i] [j] ["steps"] [k] ["isDone"].AsBool;
                    }
                }
            }
            journalTable [i] = setOfStages;
        }
    }
Пример #2
0
	/// <summary>
	/// Loads the stages.
	/// </summary>
	/// <returns>Array of stages loaded.</returns>
	public static Stage[] LoadStages () {
		JSONNode json = JSON_IO.ReadJSON ("journalItems");
	
		Stage[] stages = new Stage[json.Count];
		for (int i = 0; i < json.Count; i++) {
			stages [i] = new Stage ();
			stages [i].name = json [i] ["name"];
			stages [i].steps = new JournalStep[json [i] ["steps"].Count];
			for (int j = 0; j < json [i] ["steps"].Count; j++) {
				stages [i].steps [j] = new JournalStep ();
				stages [i].steps [j].text = json [i] ["steps"][j]["text"].Value;
				stages [i].steps [j].isDone = json [i] ["steps"][j]["isDone"].AsBool;
			}
		}
		return stages;
	}