- 1
- 2
- 3
- 4
XmlNodeList list = xdoc.GetElementsByTagName("Customer");
for (int i = 0; i < list.Count; i++)
{
XmlElement cl = (XmlElement)xdoc.GetElementsByTagName("Customer")[i];
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+128
XmlNodeList list = xdoc.GetElementsByTagName("Customer");
for (int i = 0; i < list.Count; i++)
{
XmlElement cl = (XmlElement)xdoc.GetElementsByTagName("Customer")[i];
Написано расовым индусом.
http://www.c-sharpcorner.com/UploadFile/vimalkandasamy/Xml03032009055848AM/Xml.aspx - чисто индусский бложик. Там много подобного.
+125
if ((pen == true) || (brush == true))
{
mousePath = new System.Drawing.Drawing2D.GraphicsPath();
myPaths.Add(mousePath);
}
else
if ((rectangle == true) && (e.X > 0) && (e.Y > 0) && (e.X < pictureBox1.Width)
&& (e.Y < pictureBox1.Height))
{
if (Border == true)
{
PenForBrush.Width = trackBar1.Value;
if ((e.X >= rectX) && (e.Y >= rectY))
{
g.DrawRectangle(PenForBrush, rectX, rectY, e.X - rectX, e.Y - rectY);
}
else
if ((e.X <= rectX) && (e.Y <= rectY))
{
Rectangle R = new Rectangle(e.X, e.Y, rectX - e.X, rectY - e.Y);
g.DrawRectangle(PenForBrush, R);
}
else
if ((e.X <= rectX) && (e.Y >= rectY))
{
Rectangle R = new Rectangle(e.X, rectY, rectX - e.X, e.Y - rectY);
g.DrawRectangle(PenForBrush, R);
}
else
if ((e.X >= rectX) && (e.Y <= rectY))
{
Rectangle R = new Rectangle(rectX, e.Y, e.X - rectX, rectY - e.Y);
g.DrawRectangle(PenForBrush, R);
}
}
else if (FillBorder == true)
{
else
if ((e.X <= rectX) && (e.Y <= rectY))
{
Rectangle R = new Rectangle(e.X + width, e.Y + width,
rectX - e.X - trackBar1.Value, rectY - e.Y - trackBar1.Value);
g.FillRectangle(FillBrush, R);
g.DrawRectangle(PenForBrush, e.X, e.Y, rectX - e.X, rectY - e.Y);
}
else
if ((e.X <= rectX) && (e.Y >= rectY))
{
Rectangle R = new Rectangle(e.X + width, rectY + width,
rectX - e.X - trackBar1.Value, e.Y - rectY - trackBar1.Value);
g.FillRectangle(FillBrush, R);
g.DrawRectangle(PenForBrush, e.X, rectY, rectX - e.X, e.Y - rectY);
}
else
if ((e.X >= rectX) && (e.Y <= rectY))
{
Rectangle R = new Rectangle(rectX + width, e.Y + width,
e.X - rectX - trackBar1.Value, rectY - e.Y - trackBar1.Value);
g.FillRectangle(FillBrush, R);
g.DrawRectangle(PenForBrush, rectX, e.Y, e.X - rectX, rectY - e.Y);
}
}
else if ((mark == true) && (!IsMarkPaint)
&& (e.X - distance1 > 0) && (e.Y - distance2 > 0)
&& (e.X + distance3 < pictureBox1.Width) && (e.Y + distance4 < pictureBox1.Height))
{
if (Count == 0)
{
try
{
Rectangle R = new Rectangle(PreviousMarkPoint.X, PreviousMarkPoint.Y,
MarkRectangle.Width, MarkRectangle.Height);
SolidBrush s = new SolidBrush(Color.White);
g.FillRectangle(s, R);
Bitmap temp = new Bitmap(pictureBox1.Image.Width, pictureBox1.Image.Height);
temp = (Bitmap)pictureBox1.Image;
ImageClone = temp.Clone(MarkRectangle, PixelFormat.Format16bppArgb1555);
}
catch { }
if (myImages.Count > 35)
{
myImages.RemoveAt(0);
ImageNames.RemoveAt(0);
}
Графический редактор
+124
public object Data
{
get
{
return this._data;
}
set
{
(((value is byte ||
value is short ||
value is ushort ||
value is int ||
value is uint ||
value is long ||
value is ulong ||
value is decimal ||
value is double ||
value is float) && (DataType == JsonNodeDataType.Number)) ||
((value is string) && (DataType == JsonNodeDataType.String)) ||
((value is object[]) && (DataType == JsonNodeDataType.Array)) ||
((value is Json) && (DataType == JsonNodeDataType.SubObject)) ||
((value is bool) && (DataType == JsonNodeDataType.Boolean))).Assert();
this._data = value;
}
}
Изобретаю велосипед для работы с Json
+128
string a = 'a'+""+'b';
string b = ""+'a'+'b';
string c = 'a'+'b'+"";
никогда не воспроизводи говнокод по памяти
+145
string a = 'a'+""+'b';
string b = ""+'a'+'b';
может и боян
+129
IsDirty = InitialLoad ? false : true;
Классический индусокод, в исполнении расового полового индуса.
+956
private void SetDisplay(string Group)
{
string taxInt = "144";
switch (Group.ToLower())
{
case "bond":
taxInt = "141";
..............
break;
case "commodity":
taxInt = "329";
..............
break;
case "emarkets":
taxInt = "142";
..............
break;
default:
taxInt = "144";
..............
break;
}
SetItems(taxInt);
}
public void SetItems(string taxInt)
{
Trace.Write(taxInt);
int number;
bool result = Int32.TryParse(taxInt, out number);
if (result)
{
tid = number;
}
else
{
tid = 144;
this.lbHard.Style.Add("color", "#000");
}
Trace.Write(tid.ToString());
if (tid > 0)
{
..............
}
else
{
//здесь было пусто
}
}
Лишний код удалён, оставлена только самая важная часть кода))
+147
private void SetDisplay(string Group)
{
string taxInt = "144";
switch (Group.ToLower())
{
case "bond":
taxInt = "141";
..............
break;
case "commodity":
taxInt = "329";
..............
break;
case "emarkets":
taxInt = "142";
..............
break;
default:
taxInt = "144";
..............
break;
}
SetItems(taxInt);
}
public void SetItems(string taxInt)
{
Trace.Write(taxInt);
int number;
bool result = Int32.TryParse(taxInt, out number);
if (result)
{
tid = number;
}
else
{
tid = 144;
this.lbHard.Style.Add("color", "#000");
}
Trace.Write(tid.ToString());
if (tid > 0)
{
..............
}
else
{
//здесь было пусто
}
}
Лишний код удалён, оставлена только самая важная часть кода))
+964
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace DynUnloop
{ // Суммирование в цикле
class SumLooping
{ public int Summ(int valMax)
{ int result = 0;
for (int i = 0; i <= valMax; i++)
result += i;
return result;
}
}
// Плоское суммирование
class SumFlat
{ interface ISumCode
{ int ComputeSumm(int valMax);
}
void WriteCode(int valMax)
{ AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = "SumFlatAssembly";
AssemblyBuilder assemblyBuilder =
AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName, AssemblyBuilderAccess.Run);
ModuleBuilder moduleBuilder =
assemblyBuilder.DefineDynamicModule("SumFlatModule");
TypeBuilder typeBuilder =
moduleBuilder.DefineType("SumFlatClass"
, TypeAttributes.Public);
typeBuilder.AddInterfaceImplementation(typeof(ISumCode));
/// Задаём возвращаемое зачение и параметр
Type[] paramTypes = { typeof(int) };
Type returnType = typeof(int);
MethodBuilder methodBuilder =
typeBuilder.DefineMethod("ComputeSumm"
, MethodAttributes.Public
| MethodAttributes.Virtual
, returnType, paramTypes);
ILGenerator il = methodBuilder.GetILGenerator();
// Генерируем плоский код.
il.Emit(OpCodes.Ldc_I4, 0);
for (int i = 1; i <= valMax; i++)
{ il.Emit(OpCodes.Ldc_I4, i);
il.Emit(OpCodes.Add);
}
il.Emit(OpCodes.Ret);
// Перекрываем метод ComputeSumm и создаём тип SumFlatClass.
MethodInfo methodInfo =
typeof(ISumCode).GetMethod("ComputeSumm");
typeBuilder.DefineMethodOverride(methodBuilder, methodInfo);
typeBuilder.CreateType();
/// Код готов, создаём объект и берем его интерфейс.
code = (ISumCode)assemblyBuilder.CreateInstance("SumFlatClass");
}
public int Summ(int val)
{ if (this.code == null)
WriteCode(val);
return this.code.ComputeSumm(val);
}
ISumCode code;
}
Оригинальный стиль кода и комментарии сохранёны. (с), или как там.
В коде - разворачивание цикла в "плоский" IL код, который, как доказывается должен выигрывать по производительности.
+147
private void button5_Click(object sender, EventArgs e)
{
Application.Exit();
}
-.\\