protected bool SerializationDepthLimitExceeded() { if (serializationDepth > settings.serializationDepthLimit) { ES3Debug.LogWarning("Serialization depth limit of " + settings.serializationDepthLimit + " has been exceeded, indicating that there may be a circular reference.\nIf this is not a circular reference, you can increase the depth by going to Window > Easy Save 3 > Settings > Advanced Settings > Serialization Depth Limit"); return(true); } return(false); }
public override void ReadInto(ES3Reader reader, object obj) { var collection = (IList)obj; if (collection.Count == 0) { ES3Debug.LogWarning("LoadInto/ReadInto expects a collection containing instances to load data in to, but the collection is empty."); } if (reader.StartReadCollection()) { throw new NullReferenceException("The Collection we are trying to load is stored as null, which is not allowed when using ReadInto methods."); } int itemsLoaded = 0; // Iterate through each item in the collection and try to load it. foreach (var item in collection) { itemsLoaded++; if (!reader.StartReadCollectionItem()) { break; } reader.ReadInto <object>(item, elementType); // If we find a ']', we reached the end of the array. if (reader.EndReadCollectionItem()) { break; } // If there's still items to load, but we've reached the end of the collection we're loading into, throw an error. if (itemsLoaded == collection.Count) { throw new IndexOutOfRangeException("The collection we are loading is longer than the collection provided as a parameter."); } } // If we loaded fewer items than the parameter collection, throw index out of range exception. if (itemsLoaded != collection.Count) { throw new IndexOutOfRangeException("The collection we are loading is shorter than the collection provided as a parameter."); } reader.EndReadCollection(); }
internal static void Store(ES3Settings settings) { ES3File cachedFile; if (!cachedFiles.TryGetValue(settings.path, out cachedFile)) { throw new FileNotFoundException("The file '" + settings.path + "' could not be stored because it could not be found in the cache."); } if (settings.location == ES3.Location.Cache) { settings = (ES3Settings)settings.Clone(); settings.location = ES3.Location.File; ES3Debug.LogWarning("Location is set to 'Cache' when trying to store a cached file, but this should be set to a location in persistent storage (e.g. File, PlayerPrefs). Easy Save will store this cached file to ES3.Location.File."); } cachedFile.Sync(settings); }