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

    Всего: 3

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

    +129.7

    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
    public string GetHtmlElement(RepeaterItem Container)
            {
                string Result = string.Empty;
                string AClasses = HAS_CHILDREN_BASE_CSS_CLASS;
                SiteMapNode Node = (SiteMapNode)Container.DataItem;
                string Title = Node.Title;
                string EnabledAttrSign = CustomSiteMapNodeInfo.ENABLED_ATTR_NAME;
                string CssClassNameSign = CustomSiteMapNodeInfo.CSS_CLASS_ATTR_NAME;
    
                string SpanCssClasses = string.Empty;
    
                // checks for separator
                if (string.IsNullOrEmpty(Node.Title) || Node.Title == ShellModuleInitializer.SEPARATOR)
                {
                    SpanCssClasses = MENU_SEPARATOR_CSS_CLASS_NAME;
                    Title = EMPTY_TEXT;
                }
    
                bool HasImage = !string.IsNullOrEmpty(Node[CssClassNameSign]);
                if (HasImage)
                {
                    SpanCssClasses += HAS_IMAGE_CSS_CLASS_NAME;
                }
    
                Result = string.Format("<span class=\"{0}\">{1}</span>", SpanCssClasses, Title);
    
                if (HasImage)
                {
                    Result = string.Format("<span class=\"{0}\">{1}</span>{2}", Node[CssClassNameSign], EMPTY_TEXT, Result);
                }
    
                // checks for disabled item
                if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "false", true) == 0)
                {
                    AClasses += string.Format(" {0}", DISABLED_CSS_CLASS_NAME);
                }
    
                // checks for enabled item
                if (!string.IsNullOrEmpty(Node[EnabledAttrSign]) && string.Compare(Node[EnabledAttrSign], "true", true) == 0)
                {
                    Result = string.Format("<a href=\"{0}\" class=\"{1}\">{2}</a>", GetFullUrl(Container), AClasses, Result);
                }
                else
                {
                    // cheks for non-clickable item
                    Result = string.Format("<a class=\"{0}\">{1}</a>", AClasses, Result);
                }
    
                return Result;
            }

    Valera, 18 Ноября 2009

    Комментарии (4)
  3. VisualBasic / Говнокод #1746

    −128.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
    Select Case Microsoft.VisualBasic.Right(FileLBL.Text.Trim, 3)
                        Case "pdf"
                            IconIMG.ImageUrl = "~/img/pdf.bmp"
                        Case "doc"
                            IconIMG.ImageUrl = "~/img/word.bmp"
                        Case "xls", "csv"
                            IconIMG.ImageUrl = "~/img/excel.bmp"
                        Case "rpt"
                            IconIMG.ImageUrl = "~/img/crystal.bmp"
                        Case "txt"
                            IconIMG.ImageUrl = "~/img/text.bmp"
                        Case Else
                            IconIMG.ImageUrl = "~/img/blank.bmp"
                    End Select

    Valera, 02 Сентября 2009

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

    −130.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
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    Public Overrides Sub OnViewInitialized()
                Dim userId As String = _guard.GetCurrentUserId()
    
                BindGroups()
                Bind()
                DoHackyStuff()
            End Sub
    
            Private Function GetUrls() As Dictionary(Of String, String)
    
                Dim dic As New Dictionary(Of String, String)
                For Each assembly In AppDomain.CurrentDomain.GetAssemblies()
                    For Each type In assembly.GetTypes.Where(Function(q) q.FullName.EndsWith("Url"))
                        Dim url = CType(_container.GetByType(type), IUrl).Page
                        Dim name = type.FullName.Split(".".ToCharArray)
    
                        dic.Add(url, name.Reverse.First + ", " + name.Reverse.Skip(1).First)
                    Next
                Next
                Return dic
    
            End Function
    
            Private Sub DoHackyStuff()
    
                Dim siteMap = _container.Get(Of ISiteMapGenerator)().GetSiteMap()
                Dim urls = GetUrls()
    
                Dim sb As New StringBuilder
                For Each top In siteMap.Nodes
    
                    sb.AppendLine(String.Format("<top display-name=""{0}"" id=""{1}"">", top.Name, urls(top.Url)))
                    For Each group In top.Nodes
                        sb.AppendLine(String.Format("<group display-name=""{0}"">", group.Name))
                        For Each item1 In group.Nodes
                            sb.AppendLine(String.Format("<item display-name=""{0}"" id=""{1}""/>", item1.Name, urls(item1.Url)))
                        Next
                        sb.Append("</group>")
                    Next
                    sb.Append("</top>")
                Next
    
            End Sub

    Быстро пытался сгенерить xml-ку по ран-тайм структуре.

    Valera, 24 Августа 2009

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