1. Список говнокодов пользователя Guid

    Всего: 9

  2. C# / Говнокод #12840

    +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
    16. 16
    abstract class A { }
    
    abstract class B
    {
         void CallValidate(A objA)
         {
              MethodInfo info = base.GetType().GetMethod("Validate", new[] { objA.GetType() });
    
              if (info == null)
              {
                   throw new ApplicationException("The method 'Validate' with parameter type '" + objA.GetType() + "' is not implemented.");
              }
    
              info.Invoke(this, new object[] { objA });
         }
    }

    Метод CallValidate базового класса проверяет наличие метода "Validate" с нужной сигнатурой в своих дочерних классах и вызывает его, если таковой есть, иначе - кидает исключение.

    Guid, 02 Апреля 2013

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

    +116

    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
    IList<Hashtable> records = crit.List<Hashtable>();
    Guid[] personsId = records.Select(item => (Guid)item["PersonID"]).Distinct().ToArray();
    List<EmployeeData> empDatas = new List<EmployeeData>();
    
    foreach(Guid personId in personsId) {
    	IEnumerable<Hashtable> employeeRecords = records.Where(item => (Guid)item["PersonID"] == personId);
    	Hashtable employeeRecord = employeeRecords.FirstOrDefault(item => !(bool)item["IsLoad"] || (DateTime)item["EventDate"] == employeeRecords.Max(unit => (DateTime)unit["EventDate"]));
    
    	Hashtable employeeRecordAddition = new GenericNHibernateDao<BaseDocument>().CreateCriteria()
    		.CreateAlias("Department", "department")
    		.CreateAlias("Employee", "employee")
    		.CreateAlias("WorkDescription.Schedule", "schedule", JoinType.LeftOuterJoin)
    		.CreateAlias("WorkDescription.EmployeeApperance", "employeeApperance", JoinType.LeftOuterJoin)
    		.Add(Restrictions.Eq("EmployeeStamp.TabNo", employeeRecord["TabNo"]))
    		.Add(Restrictions.Eq("IsHalf", false))
    	...
    }

    No comments %)

    Guid, 12 Мая 2011

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

    +116

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    mainDays = 0;
    
    for (var d = emplDoc.EventDate.AddMonths(1).AddDays(-1).Date; d <= emplDoc.DateEndWork.Date; d = d.AddMonths(1)) {
          mainDays += 2;
    }

    Guid, 11 Мая 2011

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

    +111

    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
    public List<Zone> IncludedZones {
    	get {
    		var result = new List<Zone>();
    		if (CarreerToHeap.Career.Name != null)
    			result.Add(CarreerToHeap.Career);
    		if (CarreerToHeap.UnLoading.Name != null)
    			result.Add(CarreerToHeap.UnLoading);
    
    		if (CarreerToBank.Career.Name != null)
    			result.Add(CarreerToBank.Career);
    		if (CarreerToBank.UnLoading.Name != null)
    			result.Add(CarreerToBank.UnLoading);
    
    		if (RT3110ToHeap.Career.Name != null)
    			result.Add(RT3110ToHeap.Career);
    		if (RT3110ToHeap.UnLoading.Name != null)
    			result.Add(RT3110ToHeap.UnLoading);
    
    		if (RT3110ToBank.Career.Name != null)
    			result.Add(RT3110ToBank.Career);
    		if (RT3110ToBank.UnLoading.Name != null)
    			result.Add(RT3110ToBank.UnLoading);
    
    		if (WestSubZoneToHeap.Career.Name != null)
    			result.Add(WestSubZoneToHeap.Career);
    		if (WestSubZoneToHeap.UnLoading.Name != null)
    			result.Add(WestSubZoneToHeap.UnLoading);
    
    		if (WestSubZoneToBank.Career.Name != null)
    			result.Add(WestSubZoneToBank.Career);
    		if (WestSubZoneToBank.UnLoading.Name != null)
    			result.Add(WestSubZoneToBank.UnLoading);
    
    		if (RemZone.Name != null)
    			result.Add(RemZone);
    		if (ParkingZone.Name != null)
    			result.Add(ParkingZone);
    		return result;
    	}
    }

    Охрененное свойство

    Guid, 01 Апреля 2011

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

    +116

    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
    /// <summary> 
    /// Сохраняет элементы справочника
    /// </summary>
    public IEnumerable SaveBookElements(IList elements) {
    	IList result = null;
    
    	try {
    		if (elements != null && elements.Count > 0) {
    			if (elements.GetType().GetGenericArguments().Length == 1 && elements[0].GetType() != elements.GetType().GetGenericArguments()[0]) {
    				var mi = typeof(BooksWorker).GetMethod("SaveTypedBookElements", BindingFlags.NonPublic | BindingFlags.Instance)
    					.MakeGenericMethod(new[] { elements[0].GetType() });
    
    				var casted = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(new[] { elements[0].GetType() }));
    
    				foreach (var t in elements) {
    					casted.Add(t);
    				}
    
    				result = mi.Invoke(this, new object[] { casted }) as IList;
    			}
    		}
    	}
    	catch (Exception ex) {
    		throw new ApplicationException("Ошибка!", ex);
    	}
    
    	return result;
    }

    Автор проникся рефлексией :-!

    Guid, 31 Марта 2011

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

    +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
    public class BasisTariffing : IFormattable
    {
    	public override bool Equals(object obj) {
    		BasisTariffing subject = obj as BasisTariffing;
    		if (subject == null) {
    			return false;
    		}
    		return ((Profession == null && subject.Profession == null) || (Profession != null && subject.Profession != null && Profession.Equals(subject.Profession))) &&
    			((BasisRateOf == null && subject.BasisRateOf == null) || (BasisRateOf != null && subject.BasisRateOf != null && BasisRateOf.Equals(subject.BasisRateOf))) &&
    			((BasisRating1Main == null && subject.BasisRating1Main == null) || (BasisRating1Main != null && subject.BasisRating1Main != null && BasisRating1Main.Equals(subject.BasisRating1Main))) &&
    			((BasisRating1Add == null && subject.BasisRating1Add == null) || (BasisRating1Add != null && subject.BasisRating1Add != null && BasisRating1Add.Equals(subject.BasisRating1Add))) &&
    			((BasisRating2Main == null && subject.BasisRating2Main == null) || (BasisRating2Main != null && subject.BasisRating2Main != null && BasisRating2Main.Equals(subject.BasisRating2Main))) &&
    			((BasisRating2Add == null && subject.BasisRating2Add == null) || (BasisRating2Add != null && subject.BasisRating2Add != null && BasisRating2Add.Equals(subject.BasisRating2Add))) &&
    			((BasisRating3Main == null && subject.BasisRating3Main == null) || (BasisRating3Main != null && subject.BasisRating3Main != null && BasisRating3Main.Equals(subject.BasisRating3Main))) &&
    			((BasisRating3Add == null && subject.BasisRating3Add == null) || (BasisRating3Add != null && subject.BasisRating3Add != null && BasisRating3Add.Equals(subject.BasisRating3Add))) &&
    			((BasisRating4Main == null && subject.BasisRating4Main == null) || (BasisRating4Main != null && subject.BasisRating4Main != null && BasisRating4Main.Equals(subject.BasisRating4Main))) &&
    			((BasisRating4Add == null && subject.BasisRating4Add == null) || (BasisRating4Add != null && subject.BasisRating4Add != null && BasisRating4Add.Equals(subject.BasisRating4Add))) &&
    			((BasisRating5Main == null && subject.BasisRating5Main == null) || (BasisRating5Main != null && subject.BasisRating5Main != null && BasisRating5Main.Equals(subject.BasisRating5Main))) &&
    			((BasisRating5Add == null && subject.BasisRating5Add == null) || (BasisRating5Add != null && subject.BasisRating5Add != null && BasisRating5Add.Equals(subject.BasisRating5Add))) &&
    			((BasisRating6Main == null && subject.BasisRating6Main == null) || (BasisRating6Main != null && subject.BasisRating6Main != null && BasisRating6Main.Equals(subject.BasisRating6Main))) &&
    			((BasisRating6Add == null && subject.BasisRating6Add == null) || (BasisRating6Add != null && subject.BasisRating6Add != null && BasisRating6Add.Equals(subject.BasisRating6Add))) &&
    			((BasisRating7Main == null && subject.BasisRating7Main == null) || (BasisRating7Main != null && subject.BasisRating7Main != null && BasisRating7Main.Equals(subject.BasisRating7Main))) &&
    			((BasisRating7Add == null && subject.BasisRating7Add == null) || (BasisRating7Add != null && subject.BasisRating7Add != null && BasisRating7Add.Equals(subject.BasisRating7Add))) &&
    			((BasisRating8Main == null && subject.BasisRating8Main == null) || (BasisRating8Main != null && subject.BasisRating8Main != null && BasisRating8Main.Equals(subject.BasisRating8Main))) &&
    			((BasisRating8Add == null && subject.BasisRating8Add == null) || (BasisRating8Add != null && subject.BasisRating8Add != null && BasisRating8Add.Equals(subject.BasisRating8Add)));
    	}
    
    	public override int GetHashCode() {
    		return ((Profession != null) ? Profession.GetHashCode() : 0) ^
    			((BasisRateOf != null) ? BasisRateOf.GetHashCode() : 0) ^
    			((BasisRating1Main != null) ? BasisRating1Main.GetHashCode() : 0) ^
    			((BasisRating1Add != null) ? BasisRating1Add.GetHashCode() : 0) ^
    			((BasisRating2Main != null) ? BasisRating2Main.GetHashCode() : 0) ^
    			....................................
    	}
    }

    Как вам перегрузочка? И это только часть кода *сущности*, больше просто не вместилось =)

    Guid, 15 Марта 2011

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

    +122

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    catch (TargetInvocationException ex) {
         try {
              throw ex.InnerException;
         }
         catch (EndpointNotFoundException innerEx) {
              factory.Abort();
              throw new InvalidOperationException("Service unreachable", innerEx);
         }
    }

    Обработчик исключений %)

    Guid, 16 Февраля 2011

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

    +116

    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
    public RabotaJurnal(string ceh, string kod, string nameN, string nameM, string nameP, string shet, string tip, string statya, string obj, string nomen, string edIzm, double normaTime, double normaVir, double rascenka, DateTime dateFrom, DateTime dateTo)
    {
                   Ceh = ceh;
                   Kod = kod;
                   NameN = nameN;
                   NameM = nameM;
                   NameP = nameP;
                   Shet = shet;
                   Tip = tip;
                   Statya = statya;
                   Obj = obj;
                   Nomen = nomen;
                   EdIzm = edIzm;
                   NormaTime = normaTime;
                   NormaVir = normaVir;
                   Rascenka = rascenka;
                   DateFrom = dateFrom;
                   DateTo = dateTo;
    }

    Конструктор =)

    Guid, 12 Января 2011

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

    +121

    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
    [DataContract]
         public class DismissForm1ReportItem {
              [DataMember]
              public int grPersonalCode { get; set; }
              [DataMember]
              public string grPersonalName { get; set; }
              [DataMember]
              public int grIndustrialCode { get; set; }
              [DataMember]
              public string grIndustrialName { get; set; }
              [DataMember]
              public string cexCode { get; set; }
              [DataMember]
              public string cexName { get; set; }
              [DataMember]
              public int totalDismissed { get; set; }
              [DataMember]
              public int dismissedProfGroup1 { get; set; }
              [DataMember]
              public int dismissedProfGroup2 { get; set; }
              [DataMember]
              public int dismissedProfGroup3 { get; set; }
              [DataMember]
              public int dismissedProfGroup4 { get; set; }
              [DataMember]
              public int dismissedProfGroup5 { get; set; }
              [DataMember]
              public int dismissedProfGroup6 { get; set; }
              [DataMember]
              public int dismissedProfGroup7 { get; set; }
              [DataMember]
              public int dismissedProfGroup8 { get; set; }
              [DataMember]
              public int dismissedProfGroup9 { get; set; }
              [DataMember]
              public int dismissedProfGroup10 { get; set; }
              [DataMember]
              public int dismissedProfGroup11 { get; set; }
              [DataMember]
              public int dismissedProfGroup12 { get; set; }
              [DataMember]
              public int dismissedProfGroup13 { get; set; }
              [DataMember]
              public int dismissedProfGroup14 { get; set; }
              [DataMember]
              public int dismissedProfGroupOther { get; set; }
         }

    Откуда вот берутся такие наклонности? Как можно так называть члены классов? (Это только один подобный класс из множества!) Может быть сделать специальную версию Framework'а для таких людей, где классам давать имена Class1, Class2, ..., а методам Method1, Method2, ...

    Guid, 13 Декабря 2010

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