Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public static IAlgorithm ToInstance(this AlgorithmInfo info)
 {
     return(info.CreateInstance());
 }