1. C# / Говнокод #17398

    +136

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    int num10 = Convert.ToInt16(this.label13.Text);
        int num11 = Convert.ToInt16(this.label11.Text);
        int num12 = Convert.ToInt16(this.LH2.Text);
        int num13 = Convert.ToInt16(this.dmserver.Text);
        int num14 = Convert.ToInt16(this.vipserver.Text);
        int num15 = Convert.ToInt16(this.NAMALSK_FREE_server.Text);
        int num16 = Convert.ToInt16(this.Igromafia_serevr.Text);
        int num18 = Convert.ToInt16(this.LH3_total_on_off.Text);
        int num17 = ((((((num10 + num11) + num13) + num14) + num15) + num12) + num16) + num18;
        this.servers.Text = Convert.ToString(num17);

    Часть метода статистики одного из лаунчеров для пиратского клиента игры.

    kingmonstr, 03 Января 2015

    Комментарии (2)
  2. C# / Говнокод #17393

    +97

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    using System;
    using Microsoft.Win32;
     
    namespace Reester
    {
        class Program
        {
            static void Main(string[] args)
            {
                RegCreatySubKey();
            }
     
            private static void RegCreatySubKey()
            {
                RegistryKey regKey = Registry.LocalMachine;
                string[] shell = new[] { "SOFTWARE", "Microsoft", "Windows", "CurrentVersion", "Explorer", "CommandStore", "shell" };
     
                string prog = "Programma";
    1)            using (regKey = Registry.LocalMachine.OpenSubKey(shell[0],true))// тут regKey равно{HKEY_LOCAL_MACHINE}
    2)                {                                                    //сдеть уже regKey   равно {HKEY_LOCAL_MACHINE\SOFTWARE}
     
     
    3)                    if (regKey != null)//и тут уже regkey равно Null.А дальше программа не идет.
                        {
                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[1], true))
                            {
                                if (regKey != null)
                                {
                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[2], true))
                                    {
                                        if (regKey != null)
                                        {
                                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[3], true))
                                            {
                                                if (regKey != null)
                                                {
                                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[4], true))
                                                    {
                                                        if (regKey != null)
                                                        {
                                                            using (regKey = Registry.LocalMachine.OpenSubKey(shell[5], true))
                                                                
                                                            {
                                                                if (regKey != null)
                                                                {
                                                                    using (regKey = Registry.LocalMachine.OpenSubKey(shell[6], true))
                                                                    {
                                                                        if (regKey != null)
                                                                        {
                                                                            regKey.CreateSubKey(prog);
                                                                        }
                                                                    }
                                                                 }
     
                                                              }
                                                          }
                                                      }
                                                    }
                                                 }
                                               }
                                            }
                                          }
                                        }
                                     }
                                  }
                              }
                        
                       }
                  }

    Работаем с реестром

    Psilon, 31 Декабря 2014

    Комментарии (15)
  3. C# / Говнокод #17388

    +96

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    _catalogDb.Categories
                     .Where(w => w.Resources.Where(r => _catalogDb.Resources
                        .Where(a => _catalogDb.Persons.Where(b => b.EmployeeNumber == employeeNumber)
                            .Select(c => c.VIP).FirstOrDefault() || !a.VIP)
                     .Where(a => _catalogDb.Persons.Where(b => b.EmployeeNumber == employeeNumber)
                         .Select(c => c.InnerEmployee).FirstOrDefault() || !a.InnerEmployee)
                     .Where(a => !a.Paths.Any()
                         || a.Paths.Where(wer => wer.Name == null).Any()
                            || a.Paths.Where(pt => pt.Name != null && _catalogDb.Persons
                                .Where(b => b.EmployeeNumber == employeeNumber)
                                    .Select(c => c.Path).FirstOrDefault().Contains(pt.Name)).Any())
                     .Where(a => !a.Filials.Any() || a.Filials.Where(wer => wer.Code == null).Any() || a.Filials
                         .Where(pt => pt.Code != null && pt.Code == _catalogDb.Persons
                             .Where(b => b.EmployeeNumber == employeeNumber)
                                .Select(c => c.Filial).FirstOrDefault()).Any())
                     .Select(a => a.UNID).Contains(r.UNID)).Any())
                        .Select(s => s.ID).Distinct().ToList();

    Кто сказал что Entity framework облегчает жизнь...

    SuperCuke, 30 Декабря 2014

    Комментарии (30)
  4. C# / Говнокод #17386

    +135

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    /// <summary>
    /// Converts to number.
    /// </summary>
    /// <param name="value">The value.</param>
    /// <returns>System.String.</returns>
    public static string convertToNumber(string value) {
        string mvalue = "0";
        string wildchars = @"~!@#$%^&*()_+={}[]|\/?><,`:;'";
        bool chknegative = false;
    	if (value == null)
    		value = "";
        try {
            if (value == "") {
                mvalue = "0";
            }
            for (var i = 0; i < wildchars.Length; i++) {
                string wildchar = wildchars.Substring(i, 1);
                //chknegative = value.Contains(wildchar);
                mvalue = value.Replace(wildchar, "");
                value = mvalue;
            }
    
    
            chknegative = value.Contains("-");
    
            if (chknegative) {
                mvalue = value.Replace("-", "");
                mvalue = "-" + mvalue;
            }
            else {
                mvalue = value;
            }
        }
        catch {
            mvalue = "0";
        }
        return mvalue;
    }

    barsv, 29 Декабря 2014

    Комментарии (4)
  5. C# / Говнокод #17373

    +97

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (((((length > 4) && ((anUrl[0] == 'h') || (anUrl[0] == 'H'))) && 
    ((anUrl[1] == 't') || (anUrl[1] == 'T'))) && 
    (((anUrl[2] == 't') || (anUrl[2] == 'T')) &&
    ((anUrl[3] == 'p') || (anUrl[3] == 'P')))) && 
    ((anUrl[4] == ':') || (((length > 5) && 
    ((anUrl[4] == 's') || (anUrl[4] == 'S'))) && (anUrl[5] == ':'))))

    Нашел в коде проверку на http(s)

    logman, 26 Декабря 2014

    Комментарии (33)
  6. C# / Говнокод #17345

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    var resultList = new List<CentralBankRateData>();
    using (var resultSet = m_Service.GetCursOnDate(request.Date))
    using (var reader = new DataTableReader(resultSet.Tables["ValuteCursOnDate"]))
    	while (reader.Read())
    		resultList.Add(new CentralBankRateData
    		{
    			Name = (string) reader["Vname"],
    			Nominal = (decimal) reader["Vnom"],
    			Rate = (decimal) reader["Vcurs"],
    			NumberCode = (int) reader["Vcode"],
    			StringCode = (string) reader["VchCode"]
    		});

    Какой Центробанк, такая и валюта. m_Service типа DailyInfoSoap, это сервис отдачи курсов валют. А еще у них получение актуального списка БИКов возможно только в древнейшем формате dBASE.

    yamamoto, 19 Декабря 2014

    Комментарии (4)
  7. C# / Говнокод #17332

    +134

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    if (String.Compare(GlobalSettings.EnvironmentType, "Production", StringComparison.OrdinalIgnoreCase) != 0
                        && !value.EndsWith(StgPostfix, StringComparison.OrdinalIgnoreCase))
                    {
                        namePostfix = value;
                    }
                    else
                    {
                        namePostfix = value;
                    }

    condition

    mzahor, 18 Декабря 2014

    Комментарии (7)
  8. C# / Говнокод #17331

    +96

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static string RemoveWhitespace(this string input)
            {
                return input.ToCharArray()
                    .Where(c => !Char.IsWhiteSpace(c))
                    .Select(c => c.ToString(CultureInfo.InvariantCulture))
                    .Aggregate((a, b) => a + b);
            }

    RemoveWhitespace

    mzahor, 18 Декабря 2014

    Комментарии (9)
  9. C# / Говнокод #17329

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            var alldir = Directory.GetDirectories(SearchIn.Text);
            foreach (var s in alldir)
            {
                if(s.Split('\\').Last().IndexOf(SearchFor.Text) != -1)
                {
                    string parent = Directory.GetParent(s).FullName;
                    string thisfolder = s.Split('\\').Last().Replace(SearchFor.Text, ReplaceTo.Text);
                    string fullpath = parent + "\\" + thisfolder;
                    Directory.Move(s, fullpath);
                }
            }
        }
    
        private void SearchIn_DoubleClick(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                SearchIn.Text = folderBrowserDialog1.SelectedPath;
            }
        }
    }

    Откопала свой хэллоу ворлд на шарпе.
    Что забавно, больше всего здесь меня удручают названия переменных и компонентов.

    pushistayapodmyshka, 18 Декабря 2014

    Комментарии (55)
  10. C# / Говнокод #17328

    +133

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    public static T ElementAtReverse<T>(this IEnumerable<T> source, int index)
    {
        while (true)
        {
            var array = source as T[] ?? source.ToArray();
    
            var elementsCount = array.Count();
    
            if (index < elementsCount || elementsCount == 0)
                return array.ElementAt(elementsCount - 1 - index);
    
            source = array;
            index = index % elementsCount;
        }
    }

    pushistayapodmyshka, 18 Декабря 2014

    Комментарии (0)