Ejemplo n.º 1
0
        /// <summary>
        /// Returns a map of instruction types the processor accepts.
        /// </summary>
        /// <param name="processor">The specific processor.</param>
        /// <returns>Returns a Dictionary in which the keys are the instruction names and the values are the instruction types.</returns>
        public static Dictionary <string, Type> GetInstructionMap(this IProcessor processor)
        {
            var instTypes = new Dictionary <string, Type>();

            object[] attributes = processor.GetType().GetCustomAttributes(true);

            foreach (object attribute in attributes)
            {
                InstructionAttribute instAttribute = attribute as InstructionAttribute;

                if (instAttribute != null)
                {
                    instTypes.Add(instAttribute.Name, instAttribute.InstructionType);
                }
            }

            return(instTypes);
        }