public override bool Equals(object obj) { AlgorithmInfo other = obj as AlgorithmInfo; if (other == null) { return(false); } return(this.Type == other.Type && this.Parameters.Equals(other.Parameters)); }
public override bool TryParseValue <ParsedType>(object value, out ParsedType parsedValue) { parsedValue = default(ParsedType); // Will return will if unsuccessful IAlgorithm algValue = null; Type typeOfValue = value.GetType(); bool valueOk = base.TryParseValue(value, out parsedValue); if (!valueOk) { return(false); } // If the value is an info for some reason, instantiate it if (typeOfValue == typeof(AlgorithmInfo)) { AlgorithmInfo infoVal = value as AlgorithmInfo; if (infoVal != null) { algValue = infoVal.ToInstance(); valueOk = true; } } // The new value passed is an actual Algorithm if (typeof(IAlgorithm).IsAssignableFrom(typeOfValue)) { valueOk = BaseType.IsAssignableFrom(typeOfValue) && AlgorithmBaseType.IsAssignableFrom(typeOfValue) && !typeOfValue.IsAbstract; if (!valueOk) { return(false); } algValue = value as IAlgorithm; } parsedValue = (ParsedType)algValue; return(valueOk); }
public static IAlgorithm ToInstance(this AlgorithmInfo info) { return(info.CreateInstance()); }