nHydrate.Generator.Common.GeneratorFramework.GeneratorHelper.GetGeneratorsImpl C# (CSharp) Method

GetGeneratorsImpl() private method

private GetGeneratorsImpl ( object parent ) : List
parent object
return List
        private List<Type> GetGeneratorsImpl(object parent)
        {
            try
            {
                if (_detGeneratorsImplCache.ContainsKey(parent))
                {
                    return _detGeneratorsImplCache[parent];
                }

                var returnVal = new List<Type>();
                Type[] generatorTypes = null;
                if (ReflectionHelper.ImplementsInterface(parent, typeof(IGenerator)))
                {
                    generatorTypes = ReflectionHelper.GetCreatableObjectImplementsInterface(typeof(IProjectGenerator), AddinAppData.Instance.ExtensionDirectory);
                }
                else
                {
                    generatorTypes = ReflectionHelper.GetCreatableObjectImplementsInterface(typeof(IProjectItemGenerator), AddinAppData.Instance.ExtensionDirectory);
                }

                if (generatorTypes.Length == 0)
                {
                    MessageBox.Show("There are no generators installed or there was an error loading the installed generators from the following path. '" + AddinAppData.Instance.ExtensionDirectory + "'", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                foreach (var type in generatorTypes)
                {
                    var genItemAttribute = (GeneratorItemAttribute)ReflectionHelper.GetSingleAttribute(typeof(GeneratorItemAttribute), type);
                    if (genItemAttribute != null && genItemAttribute.ParentType == parent.GetType())
                    {
                        returnVal.Add(type);
                    }
                }

                //Cache this for next time
                _detGeneratorsImplCache.Add(parent, returnVal);
                return returnVal;

            }
            catch (Exception ex)
            {
                throw;
            }
        }