Skip to content

Commit

Permalink
Generics review the code and UT #79
Browse files Browse the repository at this point in the history
- changed the file name NodeObservable.cs to NodeEnumerable.cs
- Now the class is derived from Node.cs
- it is working copy
- UT green
  • Loading branch information
mpostol committed Jun 6, 2018
1 parent e79b061 commit 4a3f477
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Lecture/Lecture/Lecture.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<Compile Include="LessonExtensionMethods\IMyInterface.cs" />
<Compile Include="LessonGenerics\Generics.cs" />
<Compile Include="InterfaceExample.cs" />
<Compile Include="LessonGenerics\NodeObservable.cs" />
<Compile Include="LessonGenerics\NodeEnumerable.cs" />
<Compile Include="LinqExtensions.cs" />
<Compile Include="LessonGenerics\Node.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
1 change: 0 additions & 1 deletion Lecture/Lecture/LessonGenerics/Generics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public MethodType GenericMethod<MethodType>(MethodType methodTypeParameter)
{
return methodTypeParameter;
}

}

public class SelfDictionary<Type> : Dictionary<Type, Type>
Expand Down
10 changes: 5 additions & 5 deletions Lecture/Lecture/LessonGenerics/Node.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
namespace TP.Lecture.LessonGenerics
{
class Node<ClassA>
public class Node<ValueTypeParameter>
{
public Node<ClassA> Next { get; private set; }
public static Node<ClassA> First { get; private set; } = null;
public ClassA Value { get; private set; }
public Node(ClassA value)
public Node<ValueTypeParameter> Next { get; private set; }
public static Node<ValueTypeParameter> First { get; private set; } = null;
public ValueTypeParameter Value { get; private set; }
public Node(ValueTypeParameter value)
{
Value = value;
Next = First;
Expand Down
30 changes: 30 additions & 0 deletions Lecture/Lecture/LessonGenerics/NodeEnumerable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

using System.Collections;
using System.Collections.Generic;

namespace TP.Lecture.LessonGenerics
{
public class NodeEnumerable<ValueTypeParameter> : Node<ValueTypeParameter>, IEnumerable<ValueTypeParameter>
{
public NodeEnumerable(ValueTypeParameter value) : base(value) { }

#region IEnumerable<TypeParameter>
public IEnumerator<ValueTypeParameter> GetEnumerator()
{
Node<ValueTypeParameter> _current = First;
while (_current != null)
{
ValueTypeParameter _value = _current.Value;
_current = _current.Next;
yield return _value;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
#endregion

}

}
38 changes: 0 additions & 38 deletions Lecture/Lecture/LessonGenerics/NodeObservable.cs

This file was deleted.

0 comments on commit 4a3f477

Please sign in to comment.