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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    Func<int,int> fact = (int i_in) => i_in;
    
    fact = (int i_in) =>
    {
    	if (i_in>1) return (fact(i_in-1)*i_in);
    	else return (1);
    };

    tucvbif, 29 Января 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    public ActionResult Exception()
    {
      throw new Exception("You better not to execute this!");
    }

    нашел говнокод, оставленный прошлым архитектором)

    govnokoder1488, 28 Января 2016

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

    0

    1. 1
    <cms:CMSWebPartZone ZoneID="AnalZone" runat="server" />

    ASP.NET, аналитика

    taburetka, 28 Января 2016

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

    +2

    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
    switch (button.Tag.ToString()) {
                    case "Ezp":
                    {
                        if (nowLayer.OpenedFiles.Count == 0)
                        {
                            nowLayer.OpenedFiles = new List<ExemplarFile> { new ExemplarFile("") };
                        }
                        if (nowLayer.OpenedFiles[0].EdinZemleps == null)
                        {
                            nowLayer.OpenedFiles[0].EdinZemleps = new List<EdinZemlep>();
                        }
                        var strName = ":ЕЗ" + (nowLayer.OpenedFiles[0].EdinZemleps.Count + 1);
                        nowLayer.OpenedFiles[0].EdinZemleps.Add(new EdinZemlep(strName) { Status = StatusEnum.Образуемый });
                        _ezpListTreeView.Add(new EzpTreeView { NameEzp = strName, ContourList = new List<ContourTreeView>(), ParcelList = new List<PartZuTreeView>(), IsEzpVisible = true, IsSelectedEzp = false } );
                        _dictionaryEzpTreeViewFile.Add(_ezpListTreeView[_ezpListTreeView.Count - 1], nowLayer.OpenedFiles[0]);
                        _dictionaryEzpTreeViewEdinZemlep.Add(_ezpListTreeView[_ezpListTreeView.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[nowLayer.OpenedFiles[0].EdinZemleps.Count - 1]);
                        break;
                    }
                    case "ContourEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((button.Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        var strName = (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].CadNum != "" ? nowLayer.OpenedFiles[0].EdinZemleps[indexEz].CadNum : nowLayer.OpenedFiles[0].EdinZemleps[indexEz].LastName) + "(" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours.Count + 1) + ")";
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].AddContour(new Contour(strName) { Status = StatusEnum.Образуемый });
                        if (_ezpListTreeView[indexEz].ContourList == null)
                        {
                            _ezpListTreeView[indexEz].ContourList = new List<ContourTreeView>();
                        }
                        strName = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours.Last().Name;
                        _ezpListTreeView[indexEz].ContourList.Add(new ContourTreeView { NameContour = strName, IsContourVisible = true, IsSelectedContour = false } );
                        for (var i = 0; i < _ezpListTreeView[indexEz].ContourList.Count; i++)
                        {
                            _ezpListTreeView[indexEz].ContourList[i].NameContour = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Contours[i].Name;
                        }
                        break;
                    }
                    case "ZuEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((button.Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        var strName = ":ЗУ" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Count + 1);
                        if (_ezpListTreeView[indexEz].ParcelList == null)
                        {
                            _ezpListTreeView[indexEz].ParcelList = new List<PartZuTreeView>();
                        }
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Add(new Parcel(strName) { Status = StatusEnum.Образуемый });
                        _ezpListTreeView[indexEz].ParcelList.Add(new PartZuTreeView { NamePartZu = strName, ContourList = new List<ContourTreeView>(), PartList = new List<PartTreeView>(), IsPartZuVisible = true, IsSelectedPartZu = false });
                        _dictionaryPartZuTreeViewFile.Add(_ezpListTreeView[indexEz].ParcelList[_ezpListTreeView[indexEz].ParcelList.Count - 1], nowLayer.OpenedFiles[0]);
                        _dictionaryPartZuTreeViewParcel.Add(_ezpListTreeView[indexEz].ParcelList[_ezpListTreeView[indexEz].ParcelList.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels.Count - 1]);
                        break;
                    }              
                    case "PartZuEzp":
                    {
                        indexEz = TreeViewStackPanelMain.Children.IndexOf(((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid) - _partZuListTreeView.Count;
                        indexZu = ((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Children.IndexOf((((((button.Parent as Grid).Parent as StackPanel).Parent as Grid).Parent as StackPanel).Parent as Grid));
                        var sbPrclName = nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].LastName + "/чзу" + (nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Count + 1);
                        nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Add(new Subparcel(sbPrclName) { Status = StatusEnum.Образуемый });
                        if (_ezpListTreeView[indexEz].ParcelList[indexZu].PartList == null)
                        {
                            _ezpListTreeView[indexEz].ParcelList[indexZu].PartList = new List<PartTreeView>();
                        }
                        _ezpListTreeView[indexEz].ParcelList[indexZu].PartList.Add(new PartTreeView { NamePart = sbPrclName, ContourList = new List<ContourTreeView>(), IsPartVisible = true, IsSelectedPart = _ezpListTreeView[indexEz].ParcelList[indexZu].IsSelectedPartZu });
                        _dictionaryPartTreeViewSubparcel.Add(_ezpListTreeView[indexEz].ParcelList[indexZu].PartList[_ezpListTreeView[indexEz].ParcelList[indexZu].PartList.Count - 1], nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels[nowLayer.OpenedFiles[0].EdinZemleps[indexEz].Parcels[indexZu].Subparcels.Count - 1]);
                        break;
                    }

    и это продолжается, продолжается и продолжается....

    deathguard771, 27 Января 2016

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if (string.IsNullOrWhiteSpace(frmDelegatorLogin.ViewModel.Username))
                    throw new Exception("Не введен логин");
                if (dbEmployee == null)
                    throw new Exception(string.Format("Не найден пользователь с логином \"{0}\"", frmDelegatorLogin.ViewModel.Username));
                if (dbEmployee.DelegatePassword != frmDelegatorLogin.ViewModel.Password)
                    throw new Exception("Указан неверный пароль");

    Вот такой вот новый метод валидации полей. Да, логин и пароль вводятся текстом, да, Exception потом ничем не ловится и пользователь получает unhandeled exception...

    kerman, 20 Января 2016

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

    +3

    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
    protected override void mergeModels(IStuff Stuff, IStuff With)
            {
                var stuff = (MyObject)Stuff;
                var with = (MyObject)With;
    
                if (with.title != null)
                    stuff.title = with.title;
    
                if (with.description != null)
                    stuff.description = with.description;
                if (with.creator != null)
                    stuff.creator = with.creator;
                if (with.status != null)
                    stuff.status = with.status;
                if (with.client_name != null)
                    stuff.client_name = with.client_name;
                if (with.client_mail != null)
                    stuff.client_mail = with.client_mail;
                if (with.client_phone != null)
                    stuff.client_phone = with.client_phone;
                if (with.folder != null)
                    stuff.folder = with.folder;
    
                if (with.flag1 != null)
                    stuff.flag1 = with.flag1;
                if (with.flag2 != null)
                    stuff.flag2 = with.flag2;
                if (with.flag3 != null)
                    stuff.flag4 = with.flag3;
                if (with.flag4 != null)
                    stuff.flag4 = with.flag4;
                if (with.flag5 != null)
                    stuff.flag5 = with.flag5;
                if (with.flag6 != null)
                    stuff.flag6 = with.flag6;
                if (with.flag7 != null)
                    stuff.flag7 = with.flag7;
            }

    Копирование данных из одного объекта в другой.

    yakov_255, 19 Января 2016

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

    +1

    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
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    namespace SmalltalkPHP
    {
    	class Model
    	{
    		internal static void CreateClass(string className)
    		{
    			ClassObject = new Class(className);
    		}
    
    		public static Class ClassObject { get; set; }
    		public class Message
    		{
    			public class Arguments
    			{
    				private SortedList arguments = new SortedList();
    				public void Add(String key, String name)
    				{
    					this.arguments.Add(key, name);
    				}
    				public String AsPhp()
    				{
    					String[] sb = new String[arguments.Count];
    					int i = 0;
    					foreach (DictionaryEntry arg in arguments)
    					{
    						if ((String)(arg.Value) != "") sb[i] = "$" + arg.Value;
    						i++;
    					}
    					return String.Join(", ", sb);
    				}
    				public String MakeFunctionName()
    				{
    					String[] sb = new String[arguments.Count];
    					int i = 0;
    					foreach (DictionaryEntry arg in arguments)
    					{
    						if ((String)(arg.Key) != "") sb[i] = (String)arg.Key;
    						i++;
    					}
    					return String.Join("_", sb);
    				}
    			}
    			public class Generic
    			{
    				public virtual string AsPhp()
    				{
    					return "nya";
    				}
    			}
    			public class Unary : Generic
    			{
    				public Unary(String name, Boolean isStatic = false)
    				{
    					this.Name = name;
    					this.Arguments = new Arguments();
    					this.IsStatic = isStatic;
    				}
    				public string Name { get; set; }
    				public Arguments Arguments { get; set; }
    				public Boolean IsStatic { get; set; }
    				public string PhpHeader
    				{
    					get
    					{
    						return String.Format("public {0}function {1}()", IsStatic ? "static " : "", Name);
    					}
    				}
    
    				public override string AsPhp()
    				{
    					return PhpHeader;
    				}
    			}
    			public class Keyword : Generic
    			{
    				public Keyword(Boolean isStatic = false)
    				{
    					this.Arguments = new Arguments();
    					this.IsStatic = isStatic;
    				}
    				public string Name { get { return Arguments.MakeFunctionName(); } }
    				public Arguments Arguments { get; set; }
    				public Boolean IsStatic { get; set; }
    				public string PhpHeader
    				{
    					get
    					{
    						return String.Format("public {0}function {1}({2})", IsStatic ? "static " : "", Name, Arguments.AsPhp());
    					}
    				}
    
    				public override string AsPhp()
    				{
    					return PhpHeader;
    				}
    			}
    		}
    	}
    }

    Писал конвертер Smalltalk -> PHP
    Где-то еще валяется Smalltalk -> Erlang

    kgm-rj, 14 Января 2016

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

    −2

    1. 1
    2. 2
    3. 3
    var indexes = T.Select((item, index) => new { Item = item, Index = index })
                    .Where(nitem => n.Item == 0).Select(nindex => n.Index).ToArray();
    Console.WriteLine("Первый: {0}, последний: {1}", indexes.First(), indexes.Last());

    Не слишком много item index? index item?

    Govno_Coder, 14 Января 2016

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

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public static bool IsNullOrEmpty(this string str)
    	{
    		return string.IsNullOrEmpty(str);
    	}
    
    	public static bool IsNotNullOrEmpty(this string str)
    	{
    		return !string.IsNullOrEmpty(str);
    	}

    экономия должна быть экономной

    esromhaz, 26 Декабря 2015

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

    +1

    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
    langDict0.Add(eng , new string[] { ger, fre, spa, chi, rus, jap, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(ger , new string[] { eng, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(fre , new string[] { eng, ger, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(spa , new string[] { eng, ger, fre, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(chi , new string[] { eng });
    langDict0.Add(rus , new string[] { eng });
    langDict0.Add(jap , new string[] { eng });
    langDict0.Add(por , new string[] { eng, ger, fre, spa, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(ita , new string[] { eng, ger, fre, spa, por, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(dut , new string[] { eng, ger, fre, spa, por, ita, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(pol , new string[] { eng, ger, fre, spa, por, ita, dut, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal  });
    langDict0.Add(swe , new string[] { eng, ger, fre, spa, por, ita, dut, pol, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(dan , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(fin , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(gre , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, cze, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(cze , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, rom, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(rom , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, hun, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(hun , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, slvk, bul, slvn, lit, lat, est, mal });
    langDict0.Add(slvk, new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, bul, slvn, lit, lat, est, mal });
    langDict0.Add(bul , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, slvn, lit, lat, est, mal });
    langDict0.Add(slvn, new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, lit, lat, est, mal });
    langDict0.Add(lit , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lat, est, mal });
    langDict0.Add(lat , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, est, mal });
    langDict0.Add(est , new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, mal });
    langDict0.Add(mal, new string[] { eng, ger, fre, spa, por, ita, dut, pol, swe, dan, fin, gre, cze, rom, hun, slvk, bul, slvn, lit, lat, est });

    ffff, 25 Декабря 2015

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