/// <summary> /// Gets a collection of all known types that have Parameter tags associated /// with them, for the purposes of serialization. /// </summary> public static IEnumerable <Type> GetKnownTypes() { List <Type> knownTypes = new List <Type>() { typeof(int), // IntegerAlgorithmParamInfo typeof(double), // DecimalAlgorithmParamInfo typeof(bool), // BooleanAlgorithmParamInfo typeof(SerializableType), // AlgorithmAlgorithmParamInfo }; // Reflect through every Algorithm type loaded, to identify all // enumerations we need to know about for SelectionAlgorithmParameterInfo foreach (var assy in AppDomain.CurrentDomain.GetAssemblies()) { // Linq is so handy but seriously it's garbage to debug those nested .Where().Select() calls Type[] types = assy.GetTypes(); // Of all the loaded Algorithms... types = types.Where(t => typeof(IAlgorithm).IsAssignableFrom(t)).ToArray(); IEnumerable <PropertyInfo> props = types.SelectMany(t => t.GetProperties().AsEnumerable()); // ... We want Enum-based properties that are marked as an Algorithm Parameter props = props.Where(p => p.PropertyType.IsEnum && p.PropertyType.GetCustomAttributes <Parameter>(true) != null); knownTypes.AddRange(props.Select(p => p.PropertyType)); } // Add all known algorithms so we can handle composite algorithms, // or algorithms taking other algs as parameters. knownTypes.AddRange(AlgorithmBase.GetKnownTypes()); // Transform it to a set and back, to remove duplicates return(knownTypes.Distinct().ToList()); }
public static IEnumerable <Type> GetKnownTypes() { IEnumerable <Type> knownTypes = AlgorithmBase.GetKnownTypes(); knownTypes.Concat(CompositeAlgorithm.GetKnownTypes()); return(knownTypes); }
public static IEnumerable <Type> GetKnownTypes() { return(AlgorithmBase.GetKnownTypes()); }