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

    Всего: 2

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

    −16

    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
    public static class Md5Helper
    {
            private static readonly char[] Chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
    
            public static string Md5Hash(this string source)
            {
                byte[] hash;
                using (var hasher = MD5.Create())
                {
                    hash = hasher.ComputeHash(Encoding.UTF8.GetBytes(source));
                }
    
                var length = hash.Length << 1;
                var result = new char[length];
                for (var i = 0; i < length; i += 2)
                {
                    var b = hash[i >> 1];
                    result[i] = Chars[b >> 4];
                    result[i + 1] = Chars[b & 15];
                }
    
                return new string(result, 0, result.Length);
            }
    }

    Avance, 11 Января 2017

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

    +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
    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
    public bool Read_XMl_File (XDocument Xml_Document, ref game_data Game_Data) { 
                bool Is_Success=false;          /* Captures this function's result */
    
                try { 
                    this.Xml_Data = (game_data)Game_Data;
    /*              Recursively read through entire XML Document */ 
                    Xml_Document.Root.RecursivelyProcess ( 
                        Process_Child_Element,
                        Process_Parent_Element_Open,
                        Process_Parent_Element_Close);
                    Is_Success = true;
                    }
    
                catch (Exception ex) { throw ex; }
    
                Game_Data = this.Xml_Data;    /* Pass the data back to Xml_Data */
                return Is_Success;
                }
     public static void RecursivelyProcess (
                    this XElement element,
                    Action<XElement, int> childAction,
                    Action<XElement, int> parentOpenAction,
                    Action<XElement, int> parentCloseAction) {  
                if (element == null) { throw new ArgumentNullException ("element"); } 
                element.RecursivelyProcess (0, childAction, parentOpenAction, parentCloseAction);  
                }  
    
     private static void RecursivelyProcess (  
                this XElement element,  
                int depth,  
                Action<XElement, int> childAction,  
                Action<XElement, int> parentOpenAction,  
                Action<XElement, int> parentCloseAction)  { 
     
                if (element == null)  { throw new ArgumentNullException ("element"); } 
                if (!element.HasElements) {         /* Reached the deepest child */
                    if (childAction != null) { childAction (element, depth); }  
                    }  
                else  {                             /* element has children */
                    if (parentOpenAction != null)  { parentOpenAction (element, depth); }  
                    depth++;  
                   
                    foreach (XElement child in element.Elements ())  {  
                        child.RecursivelyProcess ( depth,  childAction,  parentOpenAction,  parentCloseAction );  
                        }     
                    depth--;  
                    
                    if (parentCloseAction != null)  {  parentCloseAction (element, depth);  }
                    }  
                }
            }

    Avance, 29 Апреля 2011

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