Exemple #1
0
        /// <summary>
        /// Gets the property's value with the specified name. This is a case-insensitve search.
        /// </summary>
        /// <param name="name">The property name to access</param>
        /// <returns>object value of BaseData</returns>
        public object GetProperty(string name)
        {
            // check to see if the requested name matches one of the algorithm registered data types and if
            // so, we'll return a new empty list. this precludes us from always needing to check HasData<T>
            Type type;

            if (_registeredTypes.TryGetType(name, out type))
            {
                IReadOnlyList <BaseData> data;
                if (_cache.TryGetValue(type, out data))
                {
                    return(data);
                }

                var listType = GetGenericListType(type);
                return(Activator.CreateInstance(listType));
            }

            throw new KeyNotFoundException($"Property with name '{name}' does not exist.");
        }