コード例 #1
0
    public void SetCell <T>(int col, int row, T value)
    {
        // If we're writing a string, add it without formatting.
        if (value.GetType() == typeof(string))
        {
            SetCellString(col, row, (string)(object)value);
            return;
        }

        var settings = new ES3Settings();

        if (ES3Reflection.IsPrimitive(value.GetType()))
        {
            SetCellString(col, row, value.ToString());
        }
        else
        {
            SetCellString(col, row, settings.encoding.GetString(ES3.Serialize(value)));
        }

        // Expand the spreadsheet if necessary.
        if (col >= cols)
        {
            cols = (col + 1);
        }
        if (row >= rows)
        {
            rows = (row + 1);
        }
    }
コード例 #2
0
ファイル: ES3File.cs プロジェクト: wkdeo12/myshooting
    /// <summary>Saves a value to a key in this ES3File.</summary>
    /// <param name="key">The key we want to use to identify our value in the file.</param>
    /// <param name="value">The value we want to save.</param>
    public void Save <T>(string key, T value)
    {
        var unencryptedSettings = (ES3Settings)settings.Clone();

        unencryptedSettings.encryptionType  = ES3.EncryptionType.None;
        unencryptedSettings.compressionType = ES3.CompressionType.None;
        cache[key] = new ES3Data(ES3TypeMgr.GetOrCreateES3Type(typeof(T)), ES3.Serialize(value, unencryptedSettings));
    }
コード例 #3
0
    /// <summary>Saves a value to a key in this ES3File.</summary>
    /// <param name="key">The key we want to use to identify our value in the file.</param>
    /// <param name="value">The value we want to save.</param>
    public void Save <T>(string key, T value)
    {
        var unencryptedSettings = (ES3Settings)settings.Clone();

        unencryptedSettings.encryptionType  = ES3.EncryptionType.None;
        unencryptedSettings.compressionType = ES3.CompressionType.None;

        // If T is object, use the value to get it's type. Otherwise, use T so that it works with inheritence.

        cache[key] = new ES3Data(ES3TypeMgr.GetOrCreateES3Type(typeof(T)), ES3.Serialize(value, unencryptedSettings));
    }