Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Xml;
- using System.Xml.Serialization;
- namespace Utils
- {
- /// <summary>
- /// Represents an object of language for the localization.
- /// </summary>
- [Serializable]
- public class Language
- {
- /// <summary>
- /// Represents a pair of language text
- /// </summary>
- [Serializable]
- public struct Text
- {
- private string _Key;
- private string _Value;
- /// <summary>
- /// Sets or gets the key of this pair.
- /// </summary>
- [XmlAttribute]
- public string Key
- {
- get { return _Key; }
- set { _Key = value; }
- }
- /// <summary>
- /// Sets or gets the value of this pair.
- /// </summary>
- [XmlAttribute]
- public string Value
- {
- get { return _Value; }
- set { _Value = value; }
- }
- /// <summary>
- /// Initializes a new instance of the Text structure with the specified key and value.
- /// </summary>
- /// <param name="key">The key of the pair.</param>
- /// <param name="value">The value of the pair.</param>
- public Text(string key, string value)
- {
- _Key = key;
- _Value = value;
- }
- }
- /// <summary>
- /// Sets or gets the name.
- /// </summary>
- public string Name
- {
- set;
- get;
- }
- /// <summary>
- /// Gets the list of the text pairs.
- /// </summary>
- public List<Text> Texts
- {
- private set;
- get;
- }
- /// <summary>
- /// Initializes a new instance of Language.
- /// </summary>
- public Language()
- {
- Texts = new List<Text>();
- Name = string.Empty;
- }
- /// <summary>
- /// Initializes a new instance of Language with the specified name.
- /// </summary>
- /// <param name="name">Name of the language.</param>
- public Language(string name) : this()
- {
- Name = name;
- }
- /// <summary>
- /// Save this language into the XML file specified.
- /// </summary>
- /// <param name="path">Path of the XML file where to save this object.</param>
- public void Save(string path)
- {
- Serializer<Language>.Serialize(this, path);
- }
- /// <summary>
- /// Open the XML file specified to load the language contained in.
- /// </summary>
- /// <param name="path">Path of the XML file where an object of language is saved.</param>
- /// <returns>Returns a Language object representig the XML file specified.</returns>
- public Language Load(string path)
- {
- return Serializer<Language>.Dezerialize(path);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment