From 68d45102ca95f78fd9b7b05c2998e6698f5a1dfe Mon Sep 17 00:00:00 2001 From: pharan Date: Thu, 27 Jul 2017 17:10:50 +0800 Subject: [PATCH] [csharp] Make Atlas compatible with foreach + cleanup --- spine-csharp/src/Atlas.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/spine-csharp/src/Atlas.cs b/spine-csharp/src/Atlas.cs index 04f2c5755..b58897153 100644 --- a/spine-csharp/src/Atlas.cs +++ b/spine-csharp/src/Atlas.cs @@ -43,11 +43,21 @@ using Windows.Storage; #endif namespace Spine { - public class Atlas { + public class Atlas : IEnumerable { readonly List pages = new List(); List regions = new List(); TextureLoader textureLoader; + #region IEnumerable implementation + public IEnumerator GetEnumerator () { + return regions.GetEnumerator(); + } + + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator () { + return regions.GetEnumerator(); + } + #endregion + #if !(IS_UNITY) #if WINDOWS_STOREAPP private async Task ReadFile(string path, TextureLoader textureLoader) { @@ -99,7 +109,7 @@ namespace Spine { } private void Load (TextReader reader, string imagesDir, TextureLoader textureLoader) { - if (textureLoader == null) throw new ArgumentNullException("textureLoader cannot be null."); + if (textureLoader == null) throw new ArgumentNullException("textureLoader", "textureLoader cannot be null."); this.textureLoader = textureLoader; string[] tuple = new string[4]; @@ -168,11 +178,11 @@ namespace Spine { region.height = Math.Abs(height); if (ReadTuple(reader, tuple) == 4) { // split is optional - region.splits = new int[] {int.Parse(tuple[0]), int.Parse(tuple[1]), + region.splits = new [] {int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3])}; if (ReadTuple(reader, tuple) == 4) { // pad is optional, but only present with splits - region.pads = new int[] {int.Parse(tuple[0]), int.Parse(tuple[1]), + region.pads = new [] {int.Parse(tuple[0]), int.Parse(tuple[1]), int.Parse(tuple[2]), int.Parse(tuple[3])}; ReadTuple(reader, tuple);