property | value |
---|---|
IDE | Visual Studio |
Language | C# |
Title | Enumerator class |
Shortcut | c_ |
Description | custom enumerator class |
Snippet Types | Expansion |
Namespaces |
System System.Collections System.Collections.Generic System.Diagnostics.CodeAnalysis |
Placeholders
Identifier | Tooltip | Default Value | Editable | Function | Type Name |
---|---|---|---|---|---|
elementType | Element type name | T | yes | ||
type | Type name | TypeName | yes | ||
variableName | Variable name | x | yes |
Code
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return new EnumeratorImpl(this);
}
IEnumerator IEnumerable.GetEnumerator()
{
return new EnumeratorImpl(this);
}
public Enumerator GetEnumerator()
{
return new Enumerator(this);
}
[SuppressMessage("Performance", "CA1815")]
[SuppressMessage("Usage", "CA2231")]
public struct Enumerator
{
private TypeName _x;
private T _current;
internal Enumerator(TypeName x)
{
_x = x;
_current = null;
}
public bool MoveNext()
{
throw new NotImplementedException();
}
public T Current
{
get { throw new NotImplementedException(); }
}
public void Reset()
{
_current = null;
}
public override bool Equals(object obj) => throw new NotSupportedException();
public override int GetHashCode() => throw new NotSupportedException();
}
private class EnumeratorImpl : IEnumerator<T>
{
private Enumerator _en;
internal EnumeratorImpl(TypeName x)
{
_en = new Enumerator(x);
}
public T Current => _en.Current;
object IEnumerator.Current => _en.Current;
public bool MoveNext() => _en.MoveNext();
public void Reset() => _en.Reset();
public void Dispose()
{
}
}