Common.Config initial commit

main
Inga 🏳‍🌈 14 years ago
parent 8c003eed2c
commit 87849291b8
  1. 1
      Common/Common.csproj
  2. 20
      Core/Config.cs

@ -45,6 +45,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>

@ -7,26 +7,24 @@ namespace FLocal.Core {
public class Config<T> where T : Config<T> {
private static Config<T> _instance;
private static T _instance;
public static Config<T> instance {
public static T instance {
get {
if(_instance == null) throw new FLocalException("not initialized");
return _instance;
}
private set {
lock(_instance) {
if(_instance != null) throw new FLocalException("already initialized");
_instance = value;
}
}
}
private Config() {
protected Config() {
}
public static void doInit(Config<T> config) {
_instance = config;
protected static void doInit(Func<T> configCreator) {
if(_instance != null) throw new FLocalException("already initialized");
lock(_instance) {
if(_instance != null) throw new FLocalException("already initialized");
_instance = configCreator();
}
}
}

Loading…
Cancel
Save