/// <summary> /// Fills the object collection. /// </summary> /// <param name="container">The container.</param> /// <param name="coreComponentVersion">The core component version.</param> /// <param name="configurationRawItem">The configuration raw item.</param> /// <param name="sourceAssembly">The source assembly.</param> /// <param name="readerType">Type of the reader.</param> /// <param name="throwException">if set to <c>true</c> [throw exception].</param> protected static void FillObjectCollection(IDictionary <string, RuntimeConfigurationItem> container, Version coreComponentVersion, ConfigurationRawItem configurationRawItem, string sourceAssembly, string readerType, bool throwException = false) { try { container.CheckNullObject(nameof(container)); configurationRawItem.CheckNullObject(nameof(configurationRawItem)); configurationRawItem.Key.CheckEmptyString(nameof(configurationRawItem.Key)); var runtimeConfigurationItem = RuntimeConfigurationItem.FromRaw(sourceAssembly, readerType, coreComponentVersion, configurationRawItem); runtimeConfigurationItem.CheckNullObject(nameof(runtimeConfigurationItem)); container.Merge(runtimeConfigurationItem.Key, runtimeConfigurationItem); } catch (Exception ex) { if (throwException) { throw ex.Handle(data: new { coreComponentVersion, configurationRawItem, sourceAssembly, readerType }); } } }
/// <summary> /// Froms the raw. /// </summary> /// <param name="sourceAssembly">The source assembly.</param> /// <param name="readerType">Type of the reader.</param> /// <param name="coreComponentVersion">The core component version.</param> /// <param name="configurationItem">The configuration item.</param> /// <returns></returns> public static RuntimeConfigurationItem FromRaw(string sourceAssembly, string readerType, Version coreComponentVersion, ConfigurationRawItem configurationItem) { try { configurationItem.CheckNullObject(nameof(configurationItem)); configurationItem.Type.CheckEmptyString(nameof(configurationItem.Type)); var result = new RuntimeConfigurationItem(configurationItem) { Assembly = sourceAssembly, ReaderType = readerType, RuntimeType = ReflectionExtension.SmartGetType(configurationItem.Type, false) ?? ReflectionExtension.SmartGetType(configurationItem.Type, true) }; result.IsActive = JudgeActive(coreComponentVersion, result.MinComponentVersionRequired, result.MaxComponentVersionLimited); result.Value = RawStringToObject(configurationItem.Value, result.RuntimeType); return(result); } catch (Exception ex) { throw ex.Handle(); } }