/// <summary> /// Get restful service resource unit. /// </summary> /// <param name="resourceKey">Resource key.</param> /// <returns>Restful service resource unit.</returns> public RestfulServiceResourceUnit GetResource(string resourceKey) { if (string.IsNullOrWhiteSpace(resourceKey)) { throw new ArgumentException("Resource key is null, empty or whitespace", "resourceKey"); } RestfulServiceConfig config = this.GetConfig(); if (config == null) { throw new OperationCanceledException(@"RestfulServiceConfig is null. Please check this config file."); } if (config.Resources == null || !config.Resources.Any()) { throw new OperationCanceledException(@"RestfulServiceConfig resources node is null. Please check this config file."); } return(config.Resources.FirstOrDefault(resource => string.Equals(resource.Key, resourceKey, StringComparison.OrdinalIgnoreCase))); }
/// <summary> /// Get restful service setting unit. /// </summary> /// <param name="settingKey">Setting key.</param> /// <returns>Restfu service setting unit.</returns> public RestfulServiceSettingUnit GetSetting(string settingKey) { if (string.IsNullOrWhiteSpace(settingKey)) { throw new ArgumentException("Setting key is null, empty or whitespace", "settingKey"); } RestfulServiceConfig config = this.GetConfig(); if (config == null) { throw new OperationCanceledException(@"RestfulServiceConfig is null. Please check this config file."); } if (config.SettingGroups == null || !config.SettingGroups.Any()) { throw new OperationCanceledException(@"RestfulServiceConfig settingGroups node is null. Please check this config file."); } return(config.SettingGroups.FirstOrDefault(setting => string.Equals(setting.Key, settingKey, StringComparison.OrdinalIgnoreCase))); }