- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
public static bool isSupportedFrameworkVersion()
{
try
{
string s = null;
string m = s + "";
}
catch
{
return false;
}
return true;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+4
public static bool isSupportedFrameworkVersion()
{
try
{
string s = null;
string m = s + "";
}
catch
{
return false;
}
return true;
}
Нашел в нашем проекте. Не поверил. Проверил. Взлолировал.
http://ideone.com/laV7up
0
if (html.Contains("The report you've designed is invalid. Please verify that everything is correct."))
Как проверить нет ли ошибок в только что сгенерированном отчете?
Теперь я знаю где работает Капитан Очевидность! ))))
(Из исходников одной популярной генерилки отчетов Кстати, локализованной на штук 8 языков)
+3
public class MyEnglishRadGridLocalizationProvider : RadGridLocalizationProvider
{
public override string GetLocalizedString(string id)
{
switch (id)
{
case RadGridStringId.ConditionalFormattingPleaseSelectValidCellValue: return "Please select valid cell value";
case RadGridStringId.ConditionalFormattingPleaseSetValidCellValue: return "Please set a valid cell value";
case RadGridStringId.ConditionalFormattingPleaseSetValidCellValues: return "Please set a valid cell values";
case RadGridStringId.ConditionalFormattingPleaseSetValidExpression: return "Please set a valid expression";
case RadGridStringId.ConditionalFormattingItem: return "Item";
case RadGridStringId.ConditionalFormattingInvalidParameters: return "Invalid parameters";
case RadGridStringId.FilterFunctionBetween: return "Between";
case RadGridStringId.FilterFunctionContains: return "Contains";
case RadGridStringId.FilterFunctionDoesNotContain: return "Does not contain";
case RadGridStringId.FilterFunctionEndsWith: return "Ends with";
case RadGridStringId.FilterFunctionEqualTo: return "Equals";
case RadGridStringId.FilterFunctionGreaterThan: return "Greater than";
case RadGridStringId.FilterFunctionGreaterThanOrEqualTo: return "Greater than or equal to";
case RadGridStringId.FilterFunctionIsEmpty: return "Is empty";
case RadGridStringId.FilterFunctionIsNull: return "Is null";
Зачем мне ресурсы и конфиги локализации, у меня нет времени чтобы ебаться с ними!
Лучше я захардкожу локализацию ещё раз!
http://docs.telerik.com/devtools/winforms/gridview/localization/localization
+3
namespace БиблиотекаКлассов
{
public class Картинки
{
public Vector2 Расположение_ЖивойКартинки;
public Vector2 Расположение_НеЖивойКартинки;
public Texture2D Объект_ЖиваяКартинка;
public Texture2D Объект_НеЖиваяКартинка;
public class ЖивыеКартинки : Картинки
{
private Point Переменная_Номер_Текущего_Кадра;
private int Переменная_Скорость_ЖивыхКартинок;
private double Переменная_ВремяРаботыКадра;
private double Переменная_ВремяОтНачалаРаботыВсехКадров;
private Rectangle Объект_Кадр;
private float Переменная_Поворот_ЖивойКартинки;
private Vector2 Переменная_Центр_Поворота;
private int Переменная_Количество_Строк;
private int Переменная_Количество_Столбцов;
public int Переменная_Ширина_Кадра_ЖивыхКартинок;
public int Переменная_Высота_Кадра_ЖивыхКартинок;
// Метод создания живых картинок с параметрами
public ЖивыеКартинки(int ЗАДАТЬ_Количество_Строк, int ЗАДАТЬ_Количество_Столбцов, double ЗАДАТЬВремяРаботыКадраВСекунду, int ЗАДАТЬ_СкоростьКартинок)
{
Переменная_Количество_Строк = ЗАДАТЬ_Количество_Строк;
Переменная_Количество_Столбцов = ЗАДАТЬ_Количество_Столбцов;
Переменная_ВремяРаботыКадра = (float)1 / ЗАДАТЬВремяРаботыКадраВСекунду;
Переменная_ВремяОтНачалаРаботыВсехКадров = 0;
Переменная_Номер_Текущего_Кадра = new Point(0, 0);
Переменная_Скорость_ЖивыхКартинок = ЗАДАТЬ_СкоростьКартинок;
}
public void Метод_ПереходПоКадрам(double ПройденноеВремя)
{
Переменная_ВремяОтНачалаРаботыВсехКадров += ПройденноеВремя;
if (Переменная_ВремяОтНачалаРаботыВсехКадров > Переменная_ВремяРаботыКадра)
{
++Переменная_Номер_Текущего_Кадра.X;
if (Переменная_Номер_Текущего_Кадра.X >= Переменная_Количество_Столбцов)
{
Переменная_Номер_Текущего_Кадра.X = 0;
++Переменная_Номер_Текущего_Кадра.Y;
if (Переменная_Номер_Текущего_Кадра.Y >= Переменная_Количество_Строк)
{
Переменная_Номер_Текущего_Кадра.Y = 0;
}
}
Переменная_ВремяОтНачалаРаботыВсехКадров -= Переменная_ВремяРаботыКадра;
}
}
public void Метод_КОМП_ДвижениеЖивыхКартинок()
{
}
public void Метод_ЗАГРУЗКА_ЖивойКартинки(ContentManager Переменная_ContentManager, String Переменная_ДляХраненияПутиКартинки)
{
Объект_ЖиваяКартинка = Переменная_ContentManager.Load<Texture2D>(Переменная_ДляХраненияПутиКартинки);
}
// Рисование Картинки
public void Метод_РИСОВАНИЕ_ЖивойКартинки(SpriteBatch Переменная_SpriteBatch, int x) // x - Помогает задать центр поворота картинки
{
Переменная_Ширина_Кадра_ЖивыхКартинок = Объект_ЖиваяКартинка.Width / Переменная_Количество_Столбцов;
Переменная_Высота_Кадра_ЖивыхКартинок = Объект_ЖиваяКартинка.Height / Переменная_Количество_Строк;
if (x != 0)
{
Переменная_Центр_Поворота = Vector2.Zero;
}
if (x == 0)
{
Переменная_Центр_Поворота = new Vector2(Переменная_Ширина_Кадра_ЖивыхКартинок / 2, Переменная_Высота_Кадра_ЖивыхКартинок / 2);
}
Объект_Кадр = new Rectangle(Переменная_Номер_Текущего_Кадра.X * Переменная_Ширина_Кадра_ЖивыхКартинок, Переменная_Номер_Текущего_Кадра.Y * Переменная_Высота_Кадра_ЖивыхКартинок, Переменная_Ширина_Кадра_ЖивыхКартинок, Переменная_Высота_Кадра_ЖивыхКартинок);
Переменная_SpriteBatch.Draw(Объект_ЖиваяКартинка, Расположение_ЖивойКартинки, Объект_Кадр, Color.White, Переменная_Поворот_ЖивойКартинки, Переменная_Центр_Поворота, 1, SpriteEffects.None, 0);
}
}
public class НеЖивыеКартинки : Картинки
{
private Vector2 Переменная_Центр_Поворота;
// private Rectangle Объект_Кадр;
public int Переменная_Ширина_НеЖивыхКартинок;
http://www.gamedev.ru/code/forum/?id=208792
+5
Action doItWrong;
var filename = "sdf";
using (var fileStream = new FileStream(filename,FileMode.Create))
{
doItWrong=()=>
{
for(int i = 0; i < 10; i++)
{
fileStream.WriteByte(255);
}
};
}
doItWrong();
Интересно, почему такое вообще не запрещают компилировать?
0
public enum EventType {
Error,
Notification,
Success
}
...
String sEventType = String.Empty;
switch (eType) {
case EventType.Error:
sEventType = "Error: ";
break;
case EventType.Notification:
sEventType = "Notification: ";
break;
case EventType.Success:
sEventType = "Success: ";
break;
}
+1
if (collection == null) collection = Rows.Where(r => r.ParentId == 0);
foreach (var row in collection.Where(r => r.ParentId > 0))
{
//немного кода
}
Сам писал. Вчера. Трезвый.
Сейчас вот думаю, а чо эта оно не работает?
+3
public class Man
{
public Man(string id, string name, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, year)
{
this.Name = name;
this.Brothers = brothers;
this.Id = id;
this.Age = age;
}
public Man(string id, string name, string note, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, note, year)
{
this.Name = name;
this.Brothers = brothers;
this.Id = id;
this.Age = age;
}
public Man(string id, string name, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, year)
{
this.Name = name;
this.Brothers = brothers;
this.Id = id;
this.Age = age;
}
public Man(string id, string name, string note, IEnumerable<Brother> brothers, Guid id, int year, int age) : base(id, note, year)
{
this.Name = name;
this.Brothers = brothers;
this.Id = id;
this.Age = age;
}
public Man(string id, string name, Guid id, int year, int age) : base(id, year)
{
this.Name = name;
this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
this.Id = id;
this.Age = age;
}
public Man(string id, string name, string note, Guid id, int year, int age) : base(id, note, year)
{
this.Name = name;
this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
this.Id = id;
this.Age = age;
}
public Man(string id, string name, Guid id, int year, int age) : base(id, year)
{
this.Name = name;
this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
this.Id = id;
this.Age = age;
}
public Man(string id, string name, string note, Guid id, int year, int age) : base(id, note, year)
{
this.Name = name;
this.Id = id;
this.Brothers = new List<Brother>() { new Brother(Guid.NewGuid().ToString()) };
this.Age = age;
}
public string Name { get; }
public Guid Id { get; }
public IEnumerable<Brother> Brothers { get; }
public int Age { get; }
}
Человек знал, но нехотел использовать значение параметра конструктора по умолчанию, потому что это усложняет структуру.
Переменные переназвал почеловечнее.
+1
// 1188 references
internal static string CombinePaths(string firstPath, string secondPath)
{
return Path.Combine(firstPath, secondPath);
}
- Шо это было?!!
- Cэкономили точку. 1188 раз )))))
+1
public class FileStorage {
public FileStorage() {
try {
if (String.IsNullOrEmpty(Common.GlobalVariables.FileStorage)) {
throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorage", String.Empty));
}
if (!Directory.Exists(Common.GlobalVariables.FileStorage)) {
DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage);
if (!di.Exists) {
throw new Exception(Common.GuiHelper.ShowErrorMessage("FileStorageDir", String.Empty));
}
}
} catch (Exception er) {
throw new Exception(er.Message);
}
}
public String CreateFileDirectory() {
try {
int iIdx = 0;
Boolean bIsCreated = false;
while (!bIsCreated && iIdx < 10) {
String sDir = Guid.NewGuid().ToString("N").ToLower();
sDir = sDir.Substring(0, 2);
if (!Directory.Exists(Common.GlobalVariables.FileStorage + sDir + @"\")) {
DirectoryInfo di = Directory.CreateDirectory(Common.GlobalVariables.FileStorage + sDir + @"\");
if (di.Exists) {
return Common.GlobalVariables.FileStorage + sDir + @"\";
}
}
iIdx++;
}
return null;
} catch (Exception er) {
throw new Exception(er.Message);
}
}
}
может я чего не понимаю, но зачем?