namespace net.lshift.ndocproc.examples.twopointoh { using System; ///Code examples from ///http://msdn2.microsoft.com/en-us/library/ms379564(vs.80).aspx public class Node: ICloneable where K: struct, IComparable where T: class, new() { ///Key field public K Key; ///Item field public T Item; ///Link to next element in list public Node NextNode; ///Default ctor public Node() { Key = default(K); Item = new T(); NextNode = null; } ///Full ctor public Node(K key,T item,Node nextNode) { Key = key; Item = item; NextNode = nextNode; } ///Implement ICloneable.Clone by delegating to our type-safe variant. /// /// MCS (and possibly CSC also) is buggy. The emitted /// documentation XML file refers to this method as /// M:net.lshift.ndocproc.examples.twopointoh.Node`2.System.ICloneable.Clone /// when implemented as System.ICloneable.Clone (in so many /// words), and as /// M:net.lshift.ndocproc.examples.twopointoh.Node`2.ICloneable.Clone /// when implemented as ICloneable.Clone. It shouldn't matter /// which name it's implemented under - the compiler should /// fully-qualify the method name before emitting the /// documentation XML - but since there's no clean way of /// guessing the actual identifier used by the author of a /// piece of code (other than perhaps laboriously guessing and /// checking against the actual emitted XML), NDocProc ignores /// the problem and relies on code authors to write the /// fully-qualified names in order to find the appropriate /// documentation stanza. /// object System.ICloneable.Clone() { return ((Node) this).Clone(); } ///Typesafe clone. public Node Clone() { Node n = this.MemberwiseClone() as Node; return n; } } public class Dummy { public Dummy() {} } ///I am a linked list /// /// /// Type K is ... /// /// /// Type T is ... /// /// public class LinkedList where K: struct, IComparable { ///Head of the list Node m_Head; ///Creates an empty list public LinkedList() { m_Head = new Node(); } ///Inserts an element at the head of the list public void AddHead(K key,Dummy item) { Node newNode = new Node(key,item,m_Head.NextNode); m_Head.NextNode = newNode; } ///This has bizarre generic types in it public void Odd(Node> something) { } } }