internal object GetCell(System.Type type, int col, int row) { string value; if (col >= cols || row >= rows) { throw new System.IndexOutOfRangeException("Cell (" + col + ", " + row + ") is out of bounds of spreadsheet (" + cols + ", " + rows + ")."); } if (!cells.TryGetValue(new Index(col, row), out value) || string.IsNullOrEmpty(value)) { return(null); } // If we're loading a string, simply return the string value. if (type == typeof(string)) { var str = (object)value; return(str); } var settings = new ES3Settings(); return(ES3.Deserialize(ES3TypeMgr.GetOrCreateES3Type(type, true), settings.encoding.GetBytes(value), settings)); }
/// <summary>Loads the value from this ES3File with the given key.</summary> /// <param name="key">The key which identifies the value we want to load.</param> /// <param name="defaultValue">The value we want to return if the key does not exist in this ES3File.</param> public T Load <T>(string key, T defaultValue) { ES3Data es3Data; if (!cache.TryGetValue(key, out es3Data)) { return(defaultValue); } var unencryptedSettings = (ES3Settings)this.settings.Clone(); unencryptedSettings.encryptionType = ES3.EncryptionType.None; unencryptedSettings.compressionType = ES3.CompressionType.None; if (typeof(T) == typeof(object)) { return((T)ES3.Deserialize(es3Data.type, es3Data.bytes, unencryptedSettings)); } return(ES3.Deserialize <T>(es3Data.bytes, unencryptedSettings)); }
/// <summary>Loads the value from this ES3File with the given key.</summary> /// <param name="key">The key which identifies the value we want to load.</param> public T Load <T>(string key) { ES3Data es3Data; if (!cache.TryGetValue(key, out es3Data)) { throw new KeyNotFoundException("Key \"" + key + "\" was not found in this ES3File. Use Load<T>(key, defaultValue) if you want to return a default value if the key does not exist."); } var unencryptedSettings = (ES3Settings)this.settings.Clone(); unencryptedSettings.encryptionType = ES3.EncryptionType.None; unencryptedSettings.compressionType = ES3.CompressionType.None; if (typeof(T) == typeof(object)) { return((T)ES3.Deserialize(es3Data.type, es3Data.bytes, unencryptedSettings)); } return(ES3.Deserialize <T>(es3Data.bytes, unencryptedSettings)); }