using System.Collections.Generic; using System.ComponentModel; using System.IO; using Helper; namespace Component { public class ConfigManager : ISupportInitialize, IConfigInitialize where T : IType { protected readonly Dictionary dict = new Dictionary(); public T this[int type] { get { return dict[type]; } } public Dictionary GetAll() { return this.dict; } public void Init(string dir) { foreach (var file in Directory.GetFiles(dir)) { var t = MongoHelper.FromJson(File.ReadAllText(file)); this.dict.Add(t.Type, t); } } public void BeginInit() { } public void EndInit() { } } }