Deutsch
Germany.ruФорумы → Архив Досок→ Программирование

Веселая фича

17.01.13 16:09
Re: Веселая фича
 
  Posmotrim завсегдатай
Posmotrim
в ответ Murr 17.01.13 16:06, Последний раз изменено 17.01.13 16:15 (Posmotrim)
В ответ на:
Так скопы-пасть код - он упадет и вопросов не будет...

так приведи минимальный код, который я смогу скомпилировать.
давай я тебе помогу:
using System;
using System.Collections.Generic;
namespace ConsoleApplication18
{
public class TTemplatesDll
{
string templateDir;
private TTemplatesDll()
{
}
private static TTemplatesDll instance;
public static TTemplatesDll Instance
{
get
{
if (instance == null)
{
instance = new TTemplatesDll();
instance.templateDir = "uhhaha!!!";
}
return instance;
}
}
public static string TemplateDir
{
set
{
Instance.templateDir = value;
new TModules(value);
System.Diagnostics.Debug.WriteLine("TemplatesDir seted as " + value);
}
get
{
if (Instance.templateDir == null || Instance.templateDir == string.Empty)
{
throw new Exception("Pointer to Template's directory not initialized");
}
return Instance.templateDir;
}
}
}
public class TModules : List<TAbc>
{
private static string DefaultCstFolder = TTemplatesDll.TemplateDir;
public TModules(string pTemplatesDir)
{
/// обрезано
}
public int Remove() // падает с Ехцептионом на вызове этого метода. Сам метод - не выполняется.
{
return base.RemoveAll(x => !x.Exists());
}
}
public class TAbc
{
public bool Exists()
{
return true;
}
}
class Program
{
static void Main(string[] args)
{
System.Console.WriteLine(TTemplatesDll.TemplateDir);
}
}
}


вывод:

uhhaha!!!
Drücken Sie eine beliebige Taste . . .


 

Перейти на