gio: Make FileEnumerator implement IEnumerable<FileInfo>

This commit is contained in:
Bertrand Lorentz 2012-11-03 17:57:31 +01:00
parent c312fb739c
commit 24b0e12c62
2 changed files with 23 additions and 11 deletions

View file

@ -21,34 +21,47 @@
namespace GLib { namespace GLib {
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
public partial class FileEnumerator { public partial class FileEnumerator : IEnumerable<FileInfo> {
public IEnumerator GetEnumerator () public IEnumerator<FileInfo> GetEnumerator ()
{ {
return new Enumerator (this); return new Enumerator (this);
} }
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumerator ();
}
public FileInfo NextFile () public FileInfo NextFile ()
{ {
return NextFile ((Cancellable) null); return NextFile ((Cancellable) null);
} }
class Enumerator : IEnumerator class Enumerator : IEnumerator<FileInfo>
{ {
FileEnumerator file_enumerator; FileEnumerator file_enumerator;
public Enumerator (FileEnumerator file_enumerator) public Enumerator (FileEnumerator file_enumerator)
{ {
this.file_enumerator = file_enumerator; this.file_enumerator = file_enumerator;
} }
FileInfo current=null; void IDisposable.Dispose() { }
public object Current {
FileInfo current;
public FileInfo Current {
get { get {
return current; return current;
} }
} }
object IEnumerator.Current
{
get { return Current; }
}
public bool MoveNext () public bool MoveNext ()
{ {
current = file_enumerator.NextFile (); current = file_enumerator.NextFile ();

View file

@ -37,7 +37,6 @@
<attr path="/api/namespace/interface[@cname='GTlsServerConnection']/property[@cname='authentication-mode']" name="hidden">1</attr> <attr path="/api/namespace/interface[@cname='GTlsServerConnection']/property[@cname='authentication-mode']" name="hidden">1</attr>
<attr path="/api/namespace/interface[@cname='GVolume']" name="consume_only">1</attr> <attr path="/api/namespace/interface[@cname='GVolume']" name="consume_only">1</attr>
<attr path="/api/namespace/interface[@cname='GVolume']/method[@name='GetMount']" name="name">GetMountInstance</attr> <attr path="/api/namespace/interface[@cname='GVolume']/method[@name='GetMount']" name="name">GetMountInstance</attr>
<add-node path="/api/namespace/object[@cname='GFileEnumerator']"><implements><interface name="IEnumerable" /></implements></add-node>
<attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='activate']" name="name">Activated</attr> <attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='activate']" name="name">Activated</attr>
<attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='open']" name="name">Opened</attr> <attr path="/api/namespace/object[@cname='GApplication']/signal[@cname='open']" name="name">Opened</attr>
<attr path="/api/namespace/object[@cname='GDBusAuthObserver']/signal[@cname='authorize-authenticated-peer']" name="name">AuthenticatedPeerAuthorized</attr> <attr path="/api/namespace/object[@cname='GDBusAuthObserver']/signal[@cname='authorize-authenticated-peer']" name="name">AuthenticatedPeerAuthorized</attr>