- 1
private static readonly Dictionary<FloorCeilingSortOptions, Func<IOrderedEnumerable<FloorCeilingSystemPage>, Func<FloorCeilingSystemPage, int>, IOrderedEnumerable<FloorCeilingSystemPage>>> DefaultSortOrder
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+134
private static readonly Dictionary<FloorCeilingSortOptions, Func<IOrderedEnumerable<FloorCeilingSystemPage>, Func<FloorCeilingSystemPage, int>, IOrderedEnumerable<FloorCeilingSystemPage>>> DefaultSortOrder
+107
public Quote[] ParseQuotesFromFile(string p){
HtmlDocument d = new HtmlDocument();
d.Load(p, new UTF8Encoding());
#if !DEBUG
return
#endif
#if DEBUG
var v1 =
#endif
d.GetElementbyId("body")//main div
#if DEBUG
; var v2 = v1
#endif
.ChildNodes//subnodes
#if DEBUG
; var v3 = v2
#endif
.Where(a => a.Attributes.Contains("class"))//nodes with classes
#if DEBUG
; var v4 = v3
#endif
.Where(a => a.Attributes["class"].Value == "quote")//quotes
#if DEBUG
; var v5 = v4
#endif
.Where(a => a.ChildNodes.Any(b => b.Attributes.Contains("class")))//only real quotes
#if DEBUG
; var v6 = v5
#endif
.Select(a => a.ChildNodes.Where(b => b.Attributes.Contains("class")).ToArray())//only usable
#if DEBUG
; var v7 = v6
#endif
.Where(a => a.Length == 2)//drop ads
#if DEBUG
; var v8 = v7
#endif
.Select(a => new Quote()
{
Text = conv.HtmlSpecialCharsDecode(a.First(b => b.Attributes["class"].Value == "text").InnerHtml.Replace("<br>", "\r\n"),StringTools.ReplaceType.Both),
ID=BadParse(GetIdString(a)),
Score=BadParse(GetScoreString(a))})
#if DEBUG
; var v9 = v8
#endif
.ToArray();
#if DEBUG
return v9;
#endif
} private static string GetScoreString(HtmlNode[] a){
#if !DEBUG
return
#endif
#if DEBUG
var v1 =
#endif
a.First(b => b.Attributes["class"].Value == "actions")
#if DEBUG
; var v2 = v1
#endif
.ChildNodes.Where(b => b.Name != "#text")
#if DEBUG
; var v3 = v2
#endif
.First(b => b.Attributes["class"].Value == "rating-o")
#if DEBUG
; var v4 = v3
#endif
.FirstChild
#if DEBUG
; var v5 = v4
#endif
.InnerText;
#if DEBUG
return v5;
#endif
} private static string GetIdString(HtmlNode[] a) {
#if !DEBUG
return
#endif
#if DEBUG
var v1=
#endif
a.First(b => b.Attributes["class"].Value == "actions")
#if DEBUG
; var v2 = v1
#endif
.ChildNodes.Where(b => b.Name != "#text")
#if DEBUG
; var v3 = v2
#endif
.First(b => b.Attributes["class"].Value == "id")
#if DEBUG
; var v4 = v3
#endif
.InnerText.Replace("#", "");
#if DEBUG
return v4;
#endif
}
Это должен был быть парсер bash.org.ru
Самоое странное, что код даже работает
+138
code = _factorCodeMax[factorUnid];
code++;
_factorCodeMax[factorUnid] = code;
return code;
+139
var priorities = Repository.Get<IIncidentPriority>().Query().OrderBy(x => x.Priority)
.Select(x => new InputItem { Id = x.Id.ToString(CultureInfo.InvariantCulture), Value = x.LocalizationValue })
.ToList();
priorities.Add(new InputItem { Id = "-1", Value = Localizator.Get("X4.Incident.Undefined") });
priorities.Reverse();
тру хацкеры презирают метод Insert )
+134
private void LettersOnChanged(object sender, EventArgs eventArgs)
{
this._lettersBinding.Clear();
this._lettersBinding.AddRange(this._letters);
this.MailAgentGridControl.ResetBindings();
this.MailAgentGridControl.RefreshDataSource();
_bindingSourceLetters.ResetCurrentItem();
_bindingSourceLetters.ResetBindings(false);
int pos = _bindingSourceLetters.Position;
this.MailAgentGridControl.DataSource = null;
this.MailAgentGridControl.DataSource = _bindingSourceLetters;
if (_bindingSourceLetters.Current == null)
{
_guiCtrl.CurrentLetter = null;
return;
}
if (pos > _bindingSourceLetters.Count - 1)
pos = _bindingSourceLetters.Count - 1;
if (pos < 0)
return;
_bindingSourceLetters.Position = pos;
MailAgentGridControlTableView.UnselectRow(MailAgentGridControlTableView.GetRowHandle(0));
MailAgentGridControlTableView.SelectRow(pos);
}
Все ради того,чтоб при изменении датабинда в гриде менялась строка выделения.
+131
if (Cache[articlesRssData] != null)
{
return Cache[articlesRssData] as ArticleRssData?;
}
return null;
+137
private static Tag GetTopic(Guid tagId)
{
var tag = DataService.PerThread.TagSet.SingleOrDefault(x => x.Id == tagId);
if (tag == null && tag.GroupId != null)
return null;
if (tag.TopicState != (byte)TopicState.GroupTopic)
return null;
return tag;
}
+142
while (true)
{
try
{
ProductService.Invoke(method);
return;
}
catch(Exception ex)
{
if (ex is System.ServiceModel.CommunicationException)
{
if (currentRetryCount == RetryCount)
throw new CommunicationException(CommunicationFailureMessage, ex);
System.Threading.Thread.Sleep(RetryWait);
currentRetryCount++;
}
}
}
+140
FileInfo file = new FileInfo(fileName);
FileSecurity fSecurity = File.GetAccessControl(fileName);
foreach (FileSystemAccessRule permissions in fSecurity.GetAccessRules(true, true, typeof(NTAccount)))
{
string login = permissions.IdentityReference.Translate(typeof(NTAccount)).Value.ToString();
string permiss = permissions.FileSystemRights.ToString();
if ((login != "логин") && (login != "логин") && (login != "логин"))
{
fSecurity.SetAccessRuleProtection(true, false);
fSecurity.RemoveAccessRule(new FileSystemAccessRule(login, permissions.FileSystemRights, AccessControlType.Allow));
}
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
fSecurity.AddAccessRule(new FileSystemAccessRule("логин", FileSystemRights.FullControl, AccessControlType.Allow));
}
File.SetAccessControl(fileName, fSecurity);
+141
foreach (var item in text.Split(' ')) {
if (!string.IsNullOrEmpty(item)) {
text = item;
break;
}
}
переменная text всегда содержит несколько пробелов и затем идентификатор.