Ejemplo n.º 1
0
        /// <summary>
        /// Instantiates the specified analyzer and places it in the analyzer dict.
        /// </summary>
        /// <param name="color">The color that this analyzer has been assigned.</param>
        /// <param name="dll">The assembly where this analyzer exists.</param>
        /// <param name="id">The unique id of this analyzer.</param>
        private static void AddToAnalyzerDict(DRAW.Color color, string dll, string id)
        {
            ISpriteAnalyzer analyzer = LoadAnalyzer(dll, id);

            if (analyzer != null)
            {
                m_analyzerDict[color] = analyzer;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Instantiates the specified analyzer and returns it
        /// </summary>
        /// <param name="dll">The dll where this analyzer resides.</param>
        /// <param name="id">The id of this analyzer (in case there are more than
        /// one analyzer in the same assembly).</param>
        /// <returns>A reference to the new analyzer.</returns>
        private static ISpriteAnalyzer LoadAnalyzer(string dll, string id)
        {
            string installDir = string.Empty;

            installDir = Constants.Path.InstallDir;

            string   assemblyPath = Constants.Path.AnalyzerDir + dll;
            Assembly assembly     = null;

            //Check to see if this assembly has already been loaded and put in the
            //assembly dictionary.
            if (!m_assebmlyDict.TryGetValue(assemblyPath, out assembly))
            {
                //Assembly was not in the assembly dictionary - load it from the
                //analyzer directory
                assembly = Assembly.LoadFile(assemblyPath);
            }

            foreach (Type type in assembly.GetExportedTypes())
            {
                ISpriteAnalyzer analyzer =
                    Activator.CreateInstance(type) as ISpriteAnalyzer;
                //Perform a null check - only types that implement ISpriteAnalyzer will
                //not be null
                if (analyzer != null)
                {
                    //Check if this is the specific analyzer we want by comparing its id
                    if (analyzer.ID == id)
                    {
                        //We found it, return it
                        return(analyzer);
                    }
                }
            }

            return(null);
        }