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

    +101

    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
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    private void SetValue(UserStructure item, int id, int tabKey, int elementKey, string newValue)
            {
                if (!item.Chats.ContainsKey(id))
                    throw new KeyNotFoundException(String.Format(
                        "Чат с id = '{0}' недоступен с этой учётной записи", id));
    
                if (item.UserName != item.Chats[id].Own)
                {
                    switch (item.Chats[id].UserPremission)
                    {
                        case UserPremission.AccountLocked:
                            throw new AccessViolationException(String.Format(
                                "Чат с id = '{0}' заблокирован", id));
                    }
                }
    
                int assemblyNumber = item.Chats[id].AssemplyNumber;
    
                if (!_contentManager.AssembplyContent.ContainsKey(assemblyNumber))
                    throw new NotImplementedException(String.Format(
                        "Для сборки = '{0}' контент не реализован", assemblyNumber));
    
                Dictionary<int, TabItem> tabs = _contentManager.AssembplyContent[assemblyNumber];
    
                if (!tabs.ContainsKey(tabKey))
                    throw new NotImplementedException(String.Format(
                        "Вкладка с ключём = '{0}' в сборке = '{1}' не существует", tabKey, assemblyNumber));
    
                if (!tabs[tabKey].Elements.ContainsKey(elementKey))
                    throw new NotImplementedException(String.Format(
                        "Элемент с ключём = '{0}' во вкладке = '{1}' и сборке = '{2}' не существует", 
                        elementKey, tabKey, assemblyNumber));
    
                ElementItem element = tabs[tabKey].Elements[elementKey];
    
                GetSetParametrs getSetParametrs = new GetSetParametrs(item.Chats[id]);
    
                switch (element.ContentType)
                { 
                    case ContentType.text_box:
                        switch (element.Resource)
                        { 
                            case ResourceType.file:
                                getSetParametrs.SetValueToFile(element.Value, newValue);
                                break;
    
    			...............................................
    
                            case ResourceType.change_login:
                                getSetParametrs.SetValueToChangeLogin(item.UserName, newValue);
                                break;
    
                            case ResourceType.change_password:
                                getSetParametrs.SetValueToChangePassword(newValue);
                                break;
                        }
                        break;
    
                    case ContentType.payment_button:
                        switch (element.Resource)
                        {
                            case ResourceType.extend_chat:
                                getSetParametrs.PayForChat();
                                break;
    
                            case ResourceType.clear_credentials:
                                getSetParametrs.SetValueToClearCredentials(element.Price);
                                break;
    
                            case ResourceType.clear_users:
                                getSetParametrs.SetValueToClearUsers(element.Price);
                                break;
                        }
                        break;
    
                    case ContentType.money_transfer:
                        switch (element.Resource)
                        {
                            case ResourceType.money_to_chat:
                                getSetParametrs.SetValueToMoneyTransfer(item.MainChat, newValue);
                                break;
                        }
                        break;
    
                    default:
                        throw new FieldAccessException(String.Format(
                            "Ресурс '{0}' с ключём = '{1}' во вкладке = '{2}' и сборке = '{3}' недоступен для редакирования",
                            element.Resource, elementKey, tabKey, assemblyNumber));
                }
            }

    Люди, не гавнокод ли?
    Напрягает объёмность метода.
    А сколько по вашему максимальное кол-во строк в методе?
    Кодинг мой, приму любую критику. По поводу использования встроенных исключений попрошу промолчать

    Nigma143, 21 Августа 2010

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

    +144

    1. 1
    2. 2
    // TODO: Rewiew
    // ...

    жопой чую, что ниже этих строк - пиздец

    mozg_raka, 19 Августа 2010

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

    +120

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    string makesig(string mid, string apiid, string method, string secret, string[] param)
            {
                string[] fullparams = new string[] { "api_id=" + apiid, "method=" + method, "v=3.0", "format=JSON" };
                string methodparams = String.Join("©", param);
                string fullparams_j = String.Join("©", fullparams);
                string fpr = String.Join("©", new string[] { fullparams_j, methodparams });
                string[] fpr_s = fpr.Split(new char[] { Convert.ToChar("©") });
                Array.Sort(fpr_s);
                fpr = String.Join("", fpr_s);
                string last = String.Concat(mid, fpr, secret);
                return getMd5Hash(last);
            }

    Так люди делают подпись для запроса к API ВКонтакте

    A1mighty, 19 Августа 2010

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

    +134

    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
    TestIssue = new Issue(Id, ProjectId, ProjectName, Code, Title,  
        Description, CategoryId, CategoryName, PriorityId,
        PriorityName,PriorityImageUrl, StatusId, StatusName, 
        StatusImageUrl, IssueTypeId, IssueTypeName,IssueTypeImageUrl,
        ResolutionId, ResolutionName,ResolutionImageUrl, 
        AssignedDisplayName, AssignedUsername, AssignedUserId,
        CreatorDisplayName, CreatorUsername, CreatorUserId, 
        OwnerDisplayName, OwnerUsername, OwnerUserId, DueDate, 
        MilestoneId, MilestoneName, MilestoneImageUrl, 
        MilestoneDueDate, AffectedMilestoneId, AffectedMilestoneName, 
        AffectedMilestoneImageUrl, Visibility, TimeLogged, Estimation, 
        DateCreated, LastUpdate, LastUpdateUsername, 
        LastUpdateDisplayName, Progress, Disabled, Votes);

    В конструкторе класса Issue 47 аргументов (http://codehelper.ru/questions/156).

    admax, 18 Августа 2010

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

    +126

    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
    public string ConvDoubToStr(double doub)
            {
                string str = ((int)doub).ToString();
                double k = (doub - (int)doub);
                if (k > 0)
                    str += ",";
                while (k > 0)
                {
                    k = k * 10;
                    switch ((int)k)
                    {
                        case 0:
                            str += "0";
                            break;
                        case 1:
                            str += "1";
                            break;
                        case 2:
                            str += "2";
                            break;
                        case 3:
                            str += "3";
                            break;
                        case 4:
                            str += "4";
                            break;
                        case 5:
                            str += "5";
                            break;
                        case 6:
                            str += "6";
                            break;
                        case 7:
                            str += "7";
                            break;
                        case 8:
                            str += "8";
                            break;
                        case 9:
                            str += "9";
                            break;
                    }
                    k = k - (int)k;
                }
                return str;
     
            }

    Мега конверт
    http://www.cyberforum.ru/csharp-net/thread20446.html#post667930

    Nigma143, 18 Августа 2010

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

    +121

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /// <summary>
            /// Returns current UTC time
            /// </summary>
            /// <returns></returns>
            public static DateTime GetCurrentTimeUtc()
            {
                DateTime dt = DateTime.UtcNow;
                return dt;
            }

    Индус-стайл метод

    sem13, 17 Августа 2010

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

    +142

    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
    void InitializeComponent()
            {
                ResizeRedraw = true;
                this.Paint += new PaintEventHandler(Do);
            }
    
            void Do(object sender, PaintEventArgs e)
            {
                object[] ob = { e.Graphics };
                new Thread(Update).Start(ob);
            }
    
            void Update(Graphics e)
            {
                PointF[] pp = new PointF[this.Width];
    
                for (int i = 0; i < this.Width; i++)
                {
                    pp[i].X = i;
                    pp[i].Y = this.Height / 2;
                }
    
                e.DrawCurve(new Pen(Color.Black, 3), pp);
            }

    sergylens, 16 Августа 2010

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

    +113

    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
    double x, y;
    
    void InitializeComponent()
    {
        this.MouseClick += new MouseEventHandler(Form1_Click);
        this.Paint += new PaintEventHandler(Form1_Paint);
    }
    
    void Form1_Paint(object sender, PaintEventArgs e)
    {
        PointF p = new PointF(0, 0);
        PointF pp = new PointF((float)x, (float)y);
        e.Graphics.DrawPolygon(new Pen(Color.Black, 3), new PointF[2] { p, pp });
    }
    
    void Form1_Click(object sender, MouseEventArgs e)
    {
        x = e.X;
        y = e.Y;
    
        AsyncDraw(ref x, ref y);
    }
    
    void AsyncDraw(ref double x, ref double y)
    {
        x = x;
        y = y;
    }

    sergylens, 14 Августа 2010

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

    +143

    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
    void Draw(object sender, PaintEventArgs e)
            {
                e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    
                //X
                e.Graphics.DrawLine(new Pen(Color.Blue, 3), new Point(0, this.Height / 2), new Point(this.Width, this.Height / 2));
    
                //Y
                e.Graphics.DrawLine(new Pen(Color.Red, 3), new Point(this.Width / 2, this.Height), new Point(this.Width / 2, 0));
    
    
                PointF[] p = new PointF[this.Width];
    
                //MessageBox.Show((Math.PI / 180 * 1).ToString());
                for(int i = 0, z = this.Width; i < (this.Height / 2); i++, z++)
                {
                    p[i].X = (float)Math.Cos(z) * this.Width;
                    p[i].Y = (float)Math.Sin(i) * this.Height;
                }
    
                e.Graphics.DrawCurve(new Pen(Color.LightSkyBlue, 2), p, 2);
            }

    sergylens, 13 Августа 2010

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

    +112

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    //Floating
    float k = 0.0001f;
    for (float i = 10.9f; i >= -10.9f; i--)
    {
        i += +1 - k;
        e.Graphics.DrawEllipse(new Pen(Color.Green, 5), 15 * (float)Math.Sin(i), 15 * i, 5, 5);
    }

    Учусь рисовать окружность

    sergylens, 11 Августа 2010

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