Ejemplo n.º 1
0
    // Here we deserialize it back into its original form
    public static object DeserializeObject <T>(string pXmlizedString) where T : class
    {
        MemoryStream memoryStream = new MemoryStream(ColoredLogHelper.StringToUTF8ByteArray(pXmlizedString));

        XmlSerializer xs = new XmlSerializer(typeof(T));

        return(xs.Deserialize(memoryStream));
    }
Ejemplo n.º 2
0
    // Here we serialize our object of type T
    public static string SerializeObject <T>(object pObject) where T : class
    {
        MemoryStream  memoryStream  = new MemoryStream();
        XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);

        XmlSerializer xs = new XmlSerializer(typeof(T));

        xs.Serialize(xmlTextWriter, pObject);

        memoryStream = (MemoryStream)xmlTextWriter.BaseStream;

        return(ColoredLogHelper.UTF8ByteArrayToString(memoryStream.ToArray()));
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Adds a color tag around the key phraase within the message with a specific HEX code.
    /// Uses the Unity Color and converts it into HEX code.
    /// </summary>
    /// <param name="str">The string the function is an extension of.</param>
    /// <param name="keyPhrase">The key phrase to stylize within the message.</param>
    /// <param name="color">The Unity Color</param>
    /// <param name="bold">Make the key phrase bold?</param>
    /// <param name="italic">Make the key phrase italic?</param>
    /// <returns>Returns the new string with the color tag surrounding it.</returns>
    public static string AddColorToKeyPhrase(this string str, string keyPhrase, Color color, bool bold, bool italic)
    {
        string colorInHex = ColoredLogHelper.ColorToHex(color);

        return(str.AddColorToKeyPhrase(keyPhrase, colorInHex, bold, italic));
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Adds a color tag around the string with a specific HEX code.
    /// Uses the Unity Color and converts it into HEX code.
    /// </summary>
    /// <param name="str">The string the function is an extension of.</param>
    /// <param name="color">The Unity Color</param>
    /// <returns>Returns the new string with the color tag surrounding it.</returns>
    public static string AddColorTag(this string str, Color color)
    {
        string colorInHex = ColoredLogHelper.ColorToHex(color);

        return(str.AddColorTag(colorInHex));
    }