<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGenerics%2FGeneric_Interface</id>
		<title>Csharp/C Sharp/Generics/Generic Interface - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FGenerics%2FGeneric_Interface"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Generics/Generic_Interface&amp;action=history"/>
		<updated>2026-04-29T20:16:25Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Generics/Generic_Interface&amp;diff=1364&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Generics/Generic_Interface&amp;diff=1364&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Generics/Generic_Interface&amp;diff=1365&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Generics/Generic_Interface&amp;diff=1365&amp;oldid=prev"/>
				<updated>2010-05-26T11:45:47Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Demonstrate a generic interface==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
public interface ISequence&amp;lt;T&amp;gt; {&lt;br /&gt;
  T getNext(); &lt;br /&gt;
  void reset(); &lt;br /&gt;
  void setStart(T v);&lt;br /&gt;
}&lt;br /&gt;
class ByTwos&amp;lt;T&amp;gt; : ISequence&amp;lt;T&amp;gt; {&lt;br /&gt;
  T start;&lt;br /&gt;
  T val;&lt;br /&gt;
  public delegate T IncByTwo(T v);&lt;br /&gt;
  IncByTwo incr;&lt;br /&gt;
  public ByTwos(IncByTwo incrMeth) {&lt;br /&gt;
    start = default(T);&lt;br /&gt;
    val = default(T);&lt;br /&gt;
    incr = incrMeth;&lt;br /&gt;
  }&lt;br /&gt;
  public T getNext() {&lt;br /&gt;
    val = incr(val);&lt;br /&gt;
    return val;&lt;br /&gt;
  }&lt;br /&gt;
  public void reset() {&lt;br /&gt;
    val = start;&lt;br /&gt;
  }&lt;br /&gt;
  public void setStart(T v) {&lt;br /&gt;
    start = v;&lt;br /&gt;
    val = start;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
class GenIntfDemo {&lt;br /&gt;
  static int intPlusTwo(int v) {&lt;br /&gt;
    return v + 2;&lt;br /&gt;
  }&lt;br /&gt;
  static double doublePlusTwo(double v) {&lt;br /&gt;
    return v + 2.0;&lt;br /&gt;
  }&lt;br /&gt;
  public static void Main() {&lt;br /&gt;
    ByTwos&amp;lt;int&amp;gt; intBT = new ByTwos&amp;lt;int&amp;gt;(intPlusTwo);&lt;br /&gt;
    for(int i=0; i &amp;lt; 5; i++)&lt;br /&gt;
      Console.Write(intBT.getNext() + &amp;quot;  &amp;quot;);&lt;br /&gt;
    Console.WriteLine();&lt;br /&gt;
    ByTwos&amp;lt;double&amp;gt; dblBT = new ByTwos&amp;lt;double&amp;gt;(doublePlusTwo);&lt;br /&gt;
    dblBT.setStart(11.4);&lt;br /&gt;
    for(int i=0; i &amp;lt; 5; i++)&lt;br /&gt;
      Console.Write(dblBT.getNext() + &amp;quot;  &amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Generic Interface Demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
class Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        Console.WriteLine(&amp;quot;Generic Interfaces&amp;quot;);&lt;br /&gt;
        BasicMath m = new BasicMath();&lt;br /&gt;
        Console.WriteLine(&amp;quot;1 + 1 = {0}&amp;quot;, m.Add(1, 1));&lt;br /&gt;
        Console.ReadLine();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public interface IBinaryOperations&amp;lt;T&amp;gt; {&lt;br /&gt;
    T Add(T arg1, T arg2);&lt;br /&gt;
    T Subtract(T arg1, T arg2);&lt;br /&gt;
    T Multiply(T arg1, T arg2);&lt;br /&gt;
    T Divide(T arg1, T arg2);&lt;br /&gt;
}&lt;br /&gt;
public class BasicMath : IBinaryOperations&amp;lt;int&amp;gt; {&lt;br /&gt;
    public int Add(int arg1, int arg2) { return arg1 + arg2; }&lt;br /&gt;
    public int Subtract(int arg1, int arg2) { return arg1 - arg2; }&lt;br /&gt;
    public int Multiply(int arg1, int arg2) { return arg1 * arg2; }&lt;br /&gt;
    public int Divide(int arg1, int arg2) { return arg1 / arg2; }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Generic parameter interface==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt; &lt;br /&gt;
using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
public interface IPresentation {&lt;br /&gt;
    string Title {&lt;br /&gt;
        get;&lt;br /&gt;
    }&lt;br /&gt;
    string Content {&lt;br /&gt;
        get;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class Presentation : IPresentation {&lt;br /&gt;
    private string title;&lt;br /&gt;
    public string Title {&lt;br /&gt;
        get {&lt;br /&gt;
            return title;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    private string content;&lt;br /&gt;
    public string Content {&lt;br /&gt;
        get {&lt;br /&gt;
            return content;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public Presentation(string title, string content) {&lt;br /&gt;
        this.title = title;&lt;br /&gt;
        this.content = content;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class ProcessPresentations&amp;lt;TPresentation, TPresentationManager&amp;gt;&lt;br /&gt;
    where TPresentation : IPresentation&lt;br /&gt;
    where TPresentationManager : IPresentationManager&amp;lt;TPresentation&amp;gt; {&lt;br /&gt;
    public static void Start(TPresentationManager dm) {&lt;br /&gt;
        new Thread(new ProcessPresentations&amp;lt;TPresentation, TPresentationManager&amp;gt;(dm).Run).Start();&lt;br /&gt;
    }&lt;br /&gt;
    protected ProcessPresentations(TPresentationManager dm) {&lt;br /&gt;
        documentManager = dm;&lt;br /&gt;
    }&lt;br /&gt;
    private TPresentationManager documentManager;&lt;br /&gt;
    protected void Run() {&lt;br /&gt;
        while (true) {&lt;br /&gt;
            if (documentManager.IsPresentationAvailable) {&lt;br /&gt;
                TPresentation doc = documentManager.GetPresentation();&lt;br /&gt;
                Console.WriteLine(&amp;quot;Processing document {0}&amp;quot;, doc.Title);&lt;br /&gt;
            }&lt;br /&gt;
            Thread.Sleep(20);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public interface IPresentationManager&amp;lt;T&amp;gt; {&lt;br /&gt;
    void AddPresentation(T doc);&lt;br /&gt;
    T GetPresentation();&lt;br /&gt;
    bool IsPresentationAvailable {&lt;br /&gt;
        get;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
public class PresentationManager&amp;lt;T&amp;gt; : IPresentationManager&amp;lt;T&amp;gt; {&lt;br /&gt;
    private Queue&amp;lt;T&amp;gt; documentQueue = new Queue&amp;lt;T&amp;gt;();&lt;br /&gt;
    public void AddPresentation(T doc) {&lt;br /&gt;
        lock (this) {&lt;br /&gt;
            documentQueue.Enqueue(doc);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    public T GetPresentation() {&lt;br /&gt;
        T doc;&lt;br /&gt;
        lock (this) {&lt;br /&gt;
            doc = documentQueue.Dequeue();&lt;br /&gt;
        }&lt;br /&gt;
        return doc;&lt;br /&gt;
    }&lt;br /&gt;
    public bool IsPresentationAvailable {&lt;br /&gt;
        get {&lt;br /&gt;
            return (documentQueue.Count &amp;gt; 0) ? true : false;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
class Program {&lt;br /&gt;
    static void Main(string[] args) {&lt;br /&gt;
        PresentationManager&amp;lt;Presentation&amp;gt; dm = new PresentationManager&amp;lt;Presentation&amp;gt;();&lt;br /&gt;
        ProcessPresentations&amp;lt;Presentation, PresentationManager&amp;lt;Presentation&amp;gt;&amp;gt;.Start(dm);&lt;br /&gt;
        for (int i = 0; i &amp;lt; 1000; i++) {&lt;br /&gt;
            Presentation d1 = new Presentation(&amp;quot;title&amp;quot; + i.ToString(), &amp;quot;content&amp;quot;);&lt;br /&gt;
            dm.AddPresentation(d1);&lt;br /&gt;
            Console.WriteLine(&amp;quot;added document {0}&amp;quot;, d1.Title);&lt;br /&gt;
            Thread.Sleep(10);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
 &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>