/// <summary> /// Determines whether the incoming type is valid /// </summary> /// <param name="type">The incoming type</param> /// <returns>true if the type is attributed correctly and /// implements the Xml interface</returns> private bool _isValidType(Type type) { PipelineXmlOriginatorAttribute attr = type.GetCustomAttribute( typeof(PipelineXmlOriginatorAttribute)) as PipelineXmlOriginatorAttribute; if (attr == null) { return(false); } return(type.GetInterfaces().Any(x => x == typeof(IPipelineXmlInterpreter))); }
/// <summary> /// Registers the incoming valid type in this repo /// </summary> /// <param name="type">The type to register</param> private void _registerType(Type type) { try { PipelineXmlOriginatorAttribute attr = type.GetCustomAttribute( typeof(PipelineXmlOriginatorAttribute)) as PipelineXmlOriginatorAttribute; Type pluginType = attr.PluginType; AlgorithmAttribute pluginAttr = pluginType.GetCustomAttribute(typeof(AlgorithmAttribute)) as AlgorithmAttribute; string pluginID = pluginAttr.PluginName; IPipelineXmlInterpreter interpreter = Activator.CreateInstance(type) as IPipelineXmlInterpreter; _interpreters.Add(pluginID, interpreter); } catch (Exception e) { } }