Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/nes-containers.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-11-04 10:34:12 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2022-11-04 10:34:12 +0300
commitace1a80681c19d0a76e4af038db84574eb554983 (patch)
treed0a348b983fce3607298712fb54891c8943f8f7a /UnifFile.cs
parent719ec3ac1d864319148ec8a9679c97616b743765 (diff)
UnifFile is enumerable now
Diffstat (limited to 'UnifFile.cs')
-rw-r--r--UnifFile.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/UnifFile.cs b/UnifFile.cs
index c2d69a6..56be6be 100644
--- a/UnifFile.cs
+++ b/UnifFile.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
@@ -10,7 +11,7 @@ namespace com.clusterrr.Famicom.Containers
/// <summary>
/// UNIF file container for NES/Famicom games
/// </summary>
- public class UnifFile
+ public class UnifFile : IEnumerable<KeyValuePair<string, IEnumerable<byte>>>
{
/// <summary>
/// UNIF fields
@@ -45,6 +46,15 @@ namespace com.clusterrr.Famicom.Containers
}
/// <summary>
+ /// Returns enumerator that iterates throught fields
+ /// </summary>
+ /// <returns>IEnumerable object</returns>
+ public IEnumerator<KeyValuePair<string, IEnumerable<byte>>> GetEnumerator()
+ => fields.Select(kv => new KeyValuePair<string,IEnumerable<byte>>(kv.Key, Array.AsReadOnly(kv.Value))).GetEnumerator();
+
+ IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
+
+ /// <summary>
/// Constructor to create empty UnifFile object
/// </summary>
public UnifFile()