Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.66 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Net;
  7. using System.Net.Sockets;
  8.  
  9.  
  10. internal class Data
  11. {
  12.     Dictionary<string, string> array = new Dictionary<string, string>();
  13.     IEnumerable num = new string[] { "user", "password", "host", "port", "type" };
  14.     IEnumerator key, value;
  15.  
  16.     internal string User, Password, Port, Host, Type;
  17.  
  18.     public virtual void Set(IEnumerable args)
  19.     {
  20.         key = num.GetEnumerator();
  21.         value = args.GetEnumerator();
  22.  
  23.         while (key.MoveNext() && value.MoveNext())
  24.         {
  25.             array.Add(key.Current.ToString(), value.Current.ToString());
  26.         };
  27.  
  28.         foreach (var item in array)
  29.         {
  30.             if (item.Key == "user") User = item.Value;
  31.  
  32.             switch (item.Key)
  33.             {
  34.                 case "user": User = item.Value;
  35.                     break;
  36.                 case "password": Password = item.Value;
  37.                     break;
  38.                 case "host": Host = item.Value;
  39.                     break;
  40.                 case "port": Port = item.Value;
  41.                     break;
  42.                 case "type": Type = item.Value;
  43.                     break;
  44.             };
  45.         };
  46.     }
  47. };
  48.  
  49. class Config : Data
  50. {
  51.     public override void Set(IEnumerable arg)
  52.     {
  53.         base.Set(arg);
  54.     }
  55.  
  56.     unsafe public Config(ref IEnumerator arg, int i)
  57.     {
  58.         ArrayList list = new ArrayList();
  59.  
  60.         while (arg.MoveNext())
  61.         {
  62.             list.Add(arg.Current);
  63.         };
  64.  
  65.         this.Set((IEnumerable)list);
  66.     }
  67. };
  68.  
  69. class Program
  70. {
  71.     static List<Config> Config;
  72.     static int Current;
  73.  
  74.     static byte[] data;
  75.  
  76.     static void Init(string[] args)
  77.     {
  78.         Config = new List<Config>();
  79.         IEnumerator ie = args.GetEnumerator();
  80.         Config.Add(new Config(ref ie, args.Length));
  81.         ie = Config.GetEnumerator();
  82.         while (ie.MoveNext()) ;
  83.         Current = 0;
  84.     }
  85.  
  86.     static void Main()
  87.     {
  88.         Init(new string[] { "sergylens", "dr15gera", "ftp.drivehq.com", "21", "FTP" });
  89.  
  90.         TcpClient client = new Connection(Config[Current].Host, Convert.ToInt32(Config[Current].Port)).GetTclClient();
  91.         data = new byte[client.Available];
  92.         string text = Encoding.UTF8.GetString(data);
  93.         Console.WriteLine(text);
  94.     }
  95. };
  96.  
  97. class Connection
  98. {
  99.     static TcpClient Connector;
  100.  
  101.     public Connection(string arg1, int arg2)
  102.     {
  103.         Connector = new TcpClient();
  104.         Connector.Connect(arg1, arg2);
  105.     }
  106.  
  107.     internal TcpClient GetTclClient()
  108.     {
  109.         return Connector;
  110.     }
  111. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement