public static QuestionGenerator CreateGeneratorFromXml(XmlReader reader)
    {
        bool used = reader.GetAttribute("Used").Equals("y");
        if(!used) return null;
        QuestionGenerator generator = new QuestionGenerator();
        generator.m_tags = reader.GetAttribute("Tags").Split(';');
        generator.m_type = (GeneratorType)System.Enum.Parse(typeof(GeneratorType), reader.GetAttribute("Type"));
        generator.m_weight = System.Convert.ToSingle(reader.GetAttribute("Weight"));
        generator.m_questionText = reader.GetAttribute("QuestionText");
        generator.m_adjacentWithin = System.Convert.ToInt32(reader.GetAttribute("AdjacentWithin"));
        generator.m_infoPrefix = reader.GetAttribute("InfoPrefix");
        generator.m_infoSuffix = reader.GetAttribute("InfoSuffix");
        bool preventDuplicates = generator.m_type == GeneratorType.SortedMultiset;

        reader.ReadToDescendant("Answer");
        do{
            generator.AddAnswer(reader.GetAttribute("Text"), reader.GetAttribute("Value"), preventDuplicates);
        }while(reader.ReadToNextSibling("Answer"));
        return generator;
    }
Example #2
0
    /// <summary>
    /// Reads a specific data tag from the xml document.
    /// </summary>
    /// <param name='reader'>
    /// Reader.
    /// </param>
    private void ReadData(XmlReader reader)
    {
        //If these values are not being set,
        //something is wrong.
        string key = "ERROR";

        string value = "ERROR";

        if (reader.HasAttributes)
        {
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "name")
                {
                    key = reader.Value;
                }
            }
        }

        //Move back to the element
        reader.MoveToElement();

        //Read the child nodes
        if (reader.ReadToDescendant("value"))
        {
            do
            {
                value = reader.ReadString();
            }
            while (reader.ReadToNextSibling("value"));
        }

        //Add the raw values to the dictionary
        textDataBase.Add(key, value);

        //Add the localized parsed values to the localizedObjectDataBase
        LocalizedObject newLocalizedObject = new LocalizedObject();
        newLocalizedObject.ObjectType = LocalizedObject.GetLocalizedObjectType(key);
        newLocalizedObject.TextValue = value;
        localizedObjectDataBase.Add(LocalizedObject.GetCleanKey(key,newLocalizedObject.ObjectType), newLocalizedObject);
    }
Example #3
0
 public void Reset()
 {
     reader = new XmlTextReader(filePath);
     reader.ReadToDescendant("Event");
 }
Example #4
0
	protected void LoadPosition(XmlReader reader) {
		reader.ReadToFollowing ("Position");
		reader.ReadToDescendant ("x");
		Vector3 loadedPosition = new Vector3 ();
		loadedPosition.x = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("y");
		loadedPosition.y = reader.ReadElementContentAsFloat ();
		reader.ReadToNextSibling ("z");
		loadedPosition.z = reader.ReadElementContentAsFloat ();
		transform.position = loadedPosition;
		reader.ReadEndElement ();
	}
Example #5
0
	protected virtual void LoadStatus (XmlReader reader) {
		reader.ReadToFollowing ("Status");
		reader.ReadToDescendant ("HP");
		HP = reader.ReadElementContentAsInt ();
	}