Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.60 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.             switch (item.Key)
  31.             {
  32.                 case "user": User = item.Value;
  33.                     break;
  34.                 case "password": Password = item.Value;
  35.                     break;
  36.                 case "host": Host = item.Value;
  37.                     break;
  38.                 case "port": Port = item.Value;
  39.                     break;
  40.                 case "type": Type = item.Value;
  41.                     break;
  42.             };
  43.         };
  44.     }
  45. };
  46.  
  47. class Config : Data
  48. {
  49.     public override void Set(IEnumerable arg)
  50.     {
  51.         base.Set(arg);
  52.     }
  53.  
  54.     unsafe public Config(ref IEnumerator arg, int i)
  55.     {
  56.         ArrayList list = new ArrayList();
  57.  
  58.         while (arg.MoveNext())
  59.         {
  60.             list.Add(arg.Current);
  61.         };
  62.  
  63.         this.Set((IEnumerable)list);
  64.     }
  65. };
  66.  
  67. class Program
  68. {
  69.     static List<Config> Config;
  70.     static int Current;
  71.  
  72.     static byte[] data;
  73.  
  74.     static void Init(string[] args)
  75.     {
  76.         Config = new List<Config>();
  77.         IEnumerator ie = args.GetEnumerator();
  78.         Config.Add(new Config(ref ie, args.Length));
  79.         ie = Config.GetEnumerator();
  80.         while (ie.MoveNext()) ;
  81.         Current = 0;
  82.     }
  83.  
  84.     static void Main()
  85.     {
  86.         Init(new string[] { "sergylens", "dr15gera", "ftp.drivehq.com", "21", "FTP" });
  87.  
  88.         TcpClient client = new Connection(Config[Current].Host, Convert.ToInt32(Config[Current].Port)).GetTclClient();
  89.         data = new byte[client.Available];
  90.         string text = Encoding.UTF8.GetString(data);
  91.         Console.WriteLine(text);
  92.     }
  93. };
  94.  
  95. class Connection
  96. {
  97.     static TcpClient Connector;
  98.  
  99.     public Connection(string arg1, int arg2)
  100.     {
  101.         Connector = new TcpClient();
  102.         Connector.Connect(arg1, arg2);
  103.     }
  104.  
  105.     internal TcpClient GetTclClient()
  106.     {
  107.         return Connector;
  108.     }
  109. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement