DictionaryBase Builder
От: Олег Гашев
Дата: 03.05.03 16:42
Оценка: 7 (2)
<html>
<HEAD>
<TITLE>DictionaryBase Builder</TITLE>
</HEAD>

<BODY>


<?
if (isset($btnEnter))
{
    echo"<font face=\"Courier New\" size=2><font color=blue>using</font> System;<br>
         <br>
         <font color=blue>namespace</font> $Namespace;<br>
        {<br>
            &nbsp;&nbsp;&nbsp;<font color=green>//$Class";echo".cs</font><br>
            &nbsp;&nbsp;&nbsp;<font color=blue>public class</font> $Class: System.Collections.DictionaryBase<br>
            &nbsp;&nbsp;&nbsp;{<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>public</font> $Item <font color=blue>this</font>[<font color=blue>int</font> $Item";echo"ID]<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>get</font> { <font color=blue>return</font> (($Item)(Dictionary[$Item";echo"ID])); }<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>set</font> { Dictionary[$Item";echo"ID] = <font color=blue>value</font>; }<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>public void</font> Add(<font color=blue>int</font> $Item";echo"ID, $Item item)<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dictionary.Add($Item";echo"ID, item);<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>public void</font> Remove(<font color=blue>int</font> $Item";echo"ID)<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dictionary.Remove($Item";echo"ID);<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>public bool</font> Contains(<font color=blue>int</font> $Item";echo"ID)<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=blue>return</font> Dictionary.Contains($Item";echo"ID);<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>
                <br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=green>// Add other type-safe methods here<br>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ...<br>
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// ...<br></font>
            &nbsp;&nbsp;&nbsp;}<br>
        }
        <br><br><a href=\"dictionarybase.php\">Build new DictionaryBase</a></font>";

}
else
{
    ?>
    <div align=center><CENTER>
<table height=100%>
<tr><td valign=middle>
<form method=post action=dictionarybase.php>
<table border=0 cellpadding=1 cellspacing=0   width=300 bgcolor=black>
<tr>
        <td>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="white">
    <tr>
        <td bgcolor="#285888" align=center><table><tr><td><font face=Verdana size=2 color=white><b>DictionaryBase Builder</b></font></td></tr></table></td>
    </tr>

    <tr>
        <td>
        <table width=100%><tr><td width=100%>
        <font face=Verdana size=2>Namespace:<br></font><input name="Namespace" type="text"     style="width:100%" /></td></tr>
        <tr><td>
        <font face=Verdana size=2>Class:<br></font><input name="Class" type="text"    style="width:100%" /></td></tr>
        <tr><td>
        <font face=Verdana size=2>Item:<br></font><input name="Item" type="text"    style="width:100%" /></td></tr>
        
        <tr><td align=center>
        <input type="submit" name="btnEnter" value="Build" id="btnEnter"></td>

    </tr>
</table></table></table></form></table></center></div>
<?
}    
?>
</BODY>
</HTML>


Пример использования

Namespace: Customers
Class: CustomerTable
Item: Customer

Результат:

using System;

namespace Customers;
{
   //CustomerTable.cs
   public class CustomerTable: System.Collections.DictionaryBase
   {
      public Customer this[int CustomerID]
      {
         get { return ((Customer)(Dictionary[CustomerID])); }
         set { Dictionary[CustomerID] = value; }
      }

      public void Add(int CustomerID, Customer item)
      {
         Dictionary.Add(CustomerID, item);
      }

      public void Remove(int CustomerID)
      {
         Dictionary.Remove(CustomerID);
      }

      public bool Contains(int CustomerID)
      {
         return Dictionary.Contains(CustomerID);
      }

      // Add other type-safe methods here
      // ...
      // ...
   }
}
Либо я найду путь, либо проложу его. © Свифт
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.