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(); using (var ms = new MemoryStream(settings.encoding.GetBytes(value))) { using (var jsonReader = new ES3JSONReader(ms, settings, false)) { var obj = ES3TypeMgr.GetOrCreateES3Type(type, true).Read <object>(jsonReader); return(obj); } } }
public T GetCell <T>(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(default(T)); } // IF we're loading a string, simply return the string value. if (typeof(T) == typeof(string)) { return((T)(object)value); } var settings = new ES3Settings(); using (var ms = new MemoryStream(settings.encoding.GetBytes(value))) using (var jsonReader = new ES3JSONReader(ms, settings, false)) return(jsonReader.Read <T>()); }
public T GetCell <T>(int col, int row) { string value; if (!cells.TryGetValue(new Index(col, row), out value)) { throw new KeyNotFoundException("Cell with index (" + col + " ," + row + ") was not found."); } var settings = new ES3Settings(); using (var ms = new MemoryStream(settings.encoding.GetBytes(value))) using (var jsonReader = new ES3JSONReader(ms, settings, false)) return(jsonReader.Read <T>()); }