Example #1
0
        public IICConfigFieldBuffer LoadConfigField(string key)
        {
            string value;

            if (_appSettings.TryGetValue(key, out value))
            {
                IICConfigFieldBuffer buffer = new IICConfigFieldBuffer();
                buffer.Key     = key;
                buffer.Value   = value;
                buffer.Version = DateTime.Now;
                return(buffer);
            }
            else
            {
                throw new ConfigurationNotFoundException(IICConfigType.Field, key);
            }
        }
Example #2
0
        public T GetConfigField <T>(string key, Action <T> onUpdate)
        {
            if (IICConfigurationManager.Loader == null)
            {
                throw new InvalidOperationException("No Loader Yet, You *MUST* call ServiceSettings.InitService() at First");
            }

            IICConfigFieldBuffer buffer = IICConfigurationManager.Loader.LoadConfigField(key);

            try {
                T ret = ObjectHelper.ConvertTo <T>(buffer.Value);

                if (onUpdate != null)
                {
                    onUpdate(ret);
                }

                return(ret);
            } catch (Exception ex) {
                throw new ConfigurationFailedException(IICConfigType.Field, key, ex);
            }
        }
 public IICConfigFieldBuffer LoadConfigField(string key)
 {
     string value;
     if (_appSettings.TryGetValue(key, out value)) {
         IICConfigFieldBuffer buffer = new IICConfigFieldBuffer();
         buffer.Key = key;
         buffer.Value = value;
         buffer.Version = DateTime.Now;
         return buffer;
     } else {
         throw new ConfigurationNotFoundException(IICConfigType.Field, key);
     }
 }