Programming C#
				Day 7: IEnumerable, Libraries and NuGet, work on the projects
			
			 
		
	 
		
			
			
				- The IEnumerable interface
- creating Enumerators with yield
- What are libraries?
- Creating (CLR) libraries with C#
- Package managers
- The NuGet package manager
- Overall project structure
 
		
			
				The IEnumerable interface
			
			
				- IEnumerableallows us to iterate through classes
- Our own implementation enables use of foreachfor user-defined classes
- opens way to LINQ requests
- an enumerator is used to go through the elements
- 
				
- think about using a specialized version with IEnumerable<T>
 
		
			
			
				- Writing a whole Enumerator class to iterate through a user defined class can be lengthy
- In many cases only the method GetEnumeratoris needed.
- Here yieldcan simplify our life as it creates an Enumerator.
 
		
			
			
				- A library is a compiled binary
- The only difference to an executable is that no Main() is defined
- A library consists of types and functionality
- Using 3rd party libraries boosts our productivity
- There are great libraries written in C# or
- Libraries that just wrap native libraries
- We already use libraries if we use the .NET-Framework
 
		
			
				Creating a library with C#
			
			
				- In Visual Studio: Start, New Project, C#, Class Library
- Libraries are the most efficient way to re-use projects
- Libraries are to the OS as what classes are to C#
- They improve reusability and encapsulation
- MSIL libraries also contain meta-data for reflection
 
		
			
			
				- Using external libraries is quite easy
- The hard part is maintenance and dependencies
- We have to keep them up-to-date and we might need other libraries
- This can get quite cruel, since where to get is not always trivial
- A package manager offers a solution to those problems
- Usually there is a database with libraries
- Adding a library will result in a check for the dependencies and installation of the required libraries
 
		
			
			
				- NuGet is an open-source package manager for the Visual Studio
- It is so popular, that it has been integrated into the Visual Studio 2012
- Every external library is now on NuGet
- Easy to publish on the public NuGet feed or create own private feeds
- Big advantage: Project bound and easy updating
- Another advantage: Powershell integrated
 
		
			
				Overall project structure
			
			
				- Add external resources to your project(s)
- Use NuGet for external libraries
- Create own libraries if you want to re-use (non-UI) functionality
- Use resource files for data, like images, sounds, texts, ...
- Big advantage: They can be localized (German, English, ...)
- Use DRY: Don't Repeat Yourself
 
		
			
				All available presentations