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

    +152

    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
    var retriesLeft = 100;
    while (true)
    {
        try
        {
            return SetRestorePoint(0, pointType, enentType, description);
        }
        catch (Win32Exception ex)
        {
            if (ex.NativeErrorCode != ErrorServiceDisabled || retriesLeft < 0)
                throw;
    
            Thread.Sleep(500);
            retriesLeft--;
        }
    }

    abatishchev, 01 Февраля 2013

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

    +138

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    var xmls = outPut.Select(x => new XmlSolutionRecord(x.Key, x.Value))
                             .Where(x => x.CanParse()) // check parameters
                             .Where(x =>
                               {
                                 x.Parse(); // parse values
                                 return true;
                               })
                             .GroupBy(
                               x => new Tuple<string, string, int>(x.DefSolutionName, x.SolutionName, x.DefSolutionVarsion)) // make groups
                             .Select(group => group.OrderByDescending(row => row.SolutionVersion).First().XmlId) // get id of latest solution for each group
                             .Select(config.GetXML);

    Очередной шедевр чешского с шарп строения.

    taburetka, 31 Января 2013

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

    +107

    1. 1
    2. 2
    while (!jHove.WaitForExit(2000)) { }
            Thread.Sleep(2000); // just for case

    комментарий убил

    taburetka, 31 Января 2013

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

    +137

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    foreach (BoxActor crate in crates)
                {
                    crate.Body.EnableBody();
                    crate.Body.ApplyGravity = true;
                    physicSystem.RemoveBody(crate.Body);
                    Components.Remove(crate);
                }
                crates.Clear();

    Раскопал древний код. Перед смертью не надышишься, как говорится...

    RaZeR, 31 Января 2013

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

    +106

    1. 1
    if (curProperty[ele].ToString().ToLower() == "nan" || curProperty[ele] != m_MinimumDensity)

    redrick, 31 Января 2013

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

    +128

    1. 1
    2. 2
    wr = new StreamWriter(fs);
    wr.WriteLine(string.Format("{0}", toPrint));

    redrick, 31 Января 2013

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

    +113

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    private int GenerateRandom(int MaxValue)
    {
        var mas = Guid.NewGuid().ToByteArray();
        return BitConverter.ToInt32(mas, 4) % MaxValue;
    }

    ....

    roman-kashitsyn, 28 Января 2013

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

    +137

    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
    private void SetRowColor()
            {
                DataGridView dg = new DataGridView();
                dg.Sorted += new EventHandler(DataGridView1_Sorted);
                foreach (DataGridViewColumn col in DataGridView1.Columns)
                {
                    if (col is DataGridViewTextBoxColumn)
                    {
                        if (col.HeaderText == "Status")
                        {
                            foreach (DataGridViewRow dgRow in DataGridView1.Rows)
                            {
                                if (dgRow.Cells[col.Index].Value.ToString() == "0" || dgRow.Cells[col.Index].Value.ToString() == "Inactive")
                                {
                                    DataGridViewCellStyle dStyle = new DataGridViewCellStyle();
                                    dStyle.BackColor = Color.Goldenrod;
                                    dStyle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
                                    dgRow.DefaultCellStyle = dStyle;
                                }
                            }
                        }
                        if (col.HeaderText == "StatusID")
                        {
                            foreach (DataGridViewRow dgRow in DataGridView1.Rows)
                            {
                                if (dgRow.Cells[col.Index].Value.ToString() == "0" || dgRow.Cells[col.Index].Value.ToString() == "Inactive")
                                {
                                    DataGridViewCellStyle dStyle = new DataGridViewCellStyle();
                                    dStyle.BackColor = Color.Goldenrod;
                                    dStyle.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
                                    dgRow.DefaultCellStyle = dStyle;
                                }
                            }
                        }
                    }
                    //if (DataGridView1.Columns[i].ValueType == typeof(System.DateTime) && DataGridView1.Columns[i].Name != "CreateTS" && DataGridView1.Columns[i].Name != "ModifyTS" && DataGridView1.Columns[i].Name != "InactiveTS" && DataGridView1.Columns[i].Name != "PrintedTS")
                    //{
                    //    DataGridView1.Columns[i].DefaultCellStyle.Format = m_strDateFormat;
                    //    DataGridView1.Columns[i].Width = m_strDateFormat == "dd MMM yyyy hh:mm:ss tt" ? 150 : DataGridView1.Columns[i].Width;
                    //}
                    //DataGridView1.Columns[i].DefaultCellStyle.
                }
            }

    Новая работа. WinForms.
    90% примерно такое.

    kore_sar, 24 Января 2013

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

    +130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public XDocument GetHelpFile(string path)
    {
          try
          {
            return _dataFacade.LoadDocument(path);
          }
          catch
          {
            return null;
          }
    }

    taburetka, 23 Января 2013

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

    +141

    1. 1
    2. 2
    3. 3
    4. 4
    protected override Type GetEntryType()
    {
        return typeof(ReportEntry);
    }

    Код из реального проекта

    UniXoiD, 21 Января 2013

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