public T GetConfigSecion <T>(string path, Action <T> onUpdate) where T : IICConfigSection { if (IICConfigurationManager.Loader == null) { throw new InvalidOperationException("No Loader Yet, You *MUST* call ServiceSettings.InitService() at First"); } try { IList <IICConfigItemBuffer> buffers = IICConfigurationManager.Loader.LoadConfigSection(path); T ret; if (buffers == null || buffers.Count == 0) { ret = IICConfigSection.CreateDefault <T>(); } else { IICIndex <IICConfigItemBuffer> index = new IICIndex <IICConfigItemBuffer>("Path", "Key", "Field"); index.BuildIndex(buffers); ret = LoadSection <T>(path, index); } if (onUpdate != null) { onUpdate(ret); } return(ret); } catch (Exception ex) { throw new ConfigurationFailedException(IICConfigType.Section, path, ex); } }
public IICConfigItemCollection <K, V> GetConfigItems <K, V>(string path, Action <IICConfigItemCollection <K, V> > onUpdate) where V : IICConfigItem { if (IICConfigurationManager.Loader == null) { throw new InvalidOperationException("No Loader Yet, You *MUST* call ServiceSettings.InitService() at First"); } try { IList <IICConfigItemBuffer> buffers = IICConfigurationManager.Loader.LoadConfigItem(path, ""); IICIndex <IICConfigItemBuffer> index = new IICIndex <IICConfigItemBuffer>("Path", "Key", "Field"); if (buffers != null) { index.BuildIndex(buffers); } IICConfigItemCollection <K, V> ret = (IICConfigItemCollection <K, V>)LoadCollection(path, typeof(K), typeof(V), typeof(IICConfigItemCollection <K, V>), index); if (onUpdate != null) { onUpdate(ret); } return(ret); } catch (Exception ex) { throw new ConfigurationFailedException(IICConfigType.ItemCollection, path, ex); } }