Where can I find a good implementation of responsive templates with good examples in C #?

Where can I find a good implementation Adapter templates with good examples in C #?

+4
source share
3 answers

(I'm going to add something similar to the Wikipedia sample here ...)

Let's say you had a requirement to provide an IDeque<T> interface for some library with the following signature:

 public interface IDeque<T> { void PushFront(T element); T PopFront(); void PushBack(T element); T PopBack(); int Count { get; } } 

This can be easily implemented using a class in BCL-LinkedList <T>, but the specific interface required here will not match. To implement this interface, you need to provide an adapter - a class that executed the required interface using some other incompatible interface. It will look something like this:

 public class Deque<T> : IDeque<T> { LinkedList<T> list = new LinkedList<T>(); public void PushFront(T element) { list.AddFirst(element); } public T PopFront() { T result = list.First.Value; list.RemoveFirst(); return result; } // ... Fill in the rest... 

In this case, you simply use the existing class (LinkedList <T>), but you wrap it in an adapter so that it can execute a different interface.

+3
source

There's a great podcast on DimeCasts.net about it here.

This is a 10-minute video on the adapter template, and they also publish the source code so you can watch it.

+1
source

This is an interface conversion template. Data and Factory Object: Adapter Template . Explanation, UML, example source - you can also buy their additional source code on your templates.

+1
source

All Articles