/// <summary> /// Sets the entries of the given <paramref name="dictionary"/> according to the current instance. /// </summary> /// <param name="modeInclusion">The extended <see cref="ModeInclusion"/> instance.</param> /// <param name="dictionary">The <see cref="IDictionary{String, Object}"/> to configure.</param> public static void ToDictionary(this ModeInclusion modeInclusion, IDictionary <string, object> dictionary) { // Note that the BYAML values are negated, they are true if an object is excluded from track. dictionary["Multi2P"] = !modeInclusion.HasFlag(ModeInclusion.Multi2P); dictionary["Multi4P"] = !modeInclusion.HasFlag(ModeInclusion.Multi4P); dictionary["WiFi"] = !modeInclusion.HasFlag(ModeInclusion.WiFi); dictionary["WiFi2P"] = !modeInclusion.HasFlag(ModeInclusion.WiFi2P); }
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- /// <summary> /// Gets a <see cref="ModeInclusion"/> value according to the Multi2P, Multi4P, WiFi2P and WiFi4P entries of the /// given <paramref name="dictionary"/>. /// </summary> /// <param name="modeInclusion">The extended <see cref="ModeInclusion"/> instance.</param> /// <param name="dictionary">The <see cref="IDictionary{String, Object}"/> to retrieve the entries from.</param> /// <returns>A <see cref="ModeInclusion"/> value according to the dictionary.</returns> public static ModeInclusion FromDictionary(this ModeInclusion modeInclusion, IDictionary <string, object> dictionary) { // Note that the BYAML values are negated, they are true if an object is excluded from track. if (!(bool)dictionary["Multi2P"]) { modeInclusion |= ModeInclusion.Multi2P; } if (!(bool)dictionary["Multi4P"]) { modeInclusion |= ModeInclusion.Multi4P; } if (!(bool)dictionary["WiFi"]) { modeInclusion |= ModeInclusion.WiFi; } if (!(bool)dictionary["WiFi2P"]) { modeInclusion |= ModeInclusion.WiFi2P; } return(modeInclusion); }
/// <summary> /// Writes instance members into the given <paramref name="dictionary"/> to store them as BYAML data. /// </summary> /// <param name="dictionary">The <see cref="Dictionary{String, Object}"/> to store the data in.</param> public void SerializeByaml(IDictionary <string, object> dictionary) { ModeInclusion.ToDictionary(dictionary); }
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- /// <summary> /// Reads data from the given <paramref name="dictionary"/> to satisfy members. /// </summary> /// <param name="dictionary">The <see cref="IDictionary{String, Object}"/> to read the data from.</param> public void DeserializeByaml(IDictionary <string, object> dictionary) { ModeInclusion = ModeInclusion.FromDictionary(dictionary); }