Add pattern descriptionn on iterator pattern
This commit is contained in:
@@ -1,15 +1,18 @@
|
|||||||
using IteratorPattern.FileExample;
|
using IteratorPattern.FileExample;
|
||||||
using IteratorPattern.TVExample.TVEnumerable;
|
using IteratorPattern.TVExample.TVEnumerable;
|
||||||
using IteratorPattern.TvIterator;
|
using IteratorPattern.TvIterator;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace IteratorPattern
|
namespace IteratorPattern
|
||||||
{
|
{
|
||||||
// This project can output the Class library as a NuGet Package.
|
|
||||||
// To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
|
|
||||||
public class IteratorPatternExamples
|
public class IteratorPatternExamples
|
||||||
{
|
{
|
||||||
public static void Run()
|
public static void Run()
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(GetPatternDescription());
|
||||||
|
Console.WriteLine(GetActors());
|
||||||
|
GoToNextStep();
|
||||||
|
|
||||||
TVIteratorExample tvIteratorExample = new TVIteratorExample();
|
TVIteratorExample tvIteratorExample = new TVIteratorExample();
|
||||||
tvIteratorExample.Run();
|
tvIteratorExample.Run();
|
||||||
|
|
||||||
@@ -21,5 +24,28 @@ namespace IteratorPattern
|
|||||||
|
|
||||||
//Iterator that selects in batches
|
//Iterator that selects in batches
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetPatternDescription()
|
||||||
|
{
|
||||||
|
return @"Pattern description:
|
||||||
|
In object-oriented programming, the iterator pattern is a design pattern in which an iterator is used to traverse a container and access the container's elements.
|
||||||
|
C# interfaces helpers for Iterator pattern: IEnumerator<T>, IEnumerable<T>, yield for creating IEnumerable<T>
|
||||||
|
Java: Iterator<E>, Iterable<E>";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetActors()
|
||||||
|
{
|
||||||
|
return @"Actors:
|
||||||
|
Iterator: interface with hasNext/next/current methods or variantions from this
|
||||||
|
Concrete interator: concrete class that implements Iterator
|
||||||
|
Aggregate: interface for returning the iterator
|
||||||
|
Concrete aggregate: imlpementation of aggregate";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GoToNextStep()
|
||||||
|
{
|
||||||
|
Console.ReadKey();
|
||||||
|
Console.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user