Exemple #1
0
            public static Instruction FromScriptCommand(ScriptCommand scriptCommand)
            {
                var item = new Instruction();

                item.mnemonic    = scriptCommand.ToString();
                item.description = ProgrammableChip.GetCommandDescription(scriptCommand);
                item.example     = ProgrammableChip.GetCommandExample(scriptCommand);

                return(item);
            }
Exemple #2
0
        private static void AddScriptCommand(ScriptCommand scriptCommand, XmlDocument xmlDocument, XmlNode root)
        {
            var element = xmlDocument.CreateElement("Instruction");
            var example = ProgrammableChip.GetCommandExample(scriptCommand);

            var instructionAttribute = xmlDocument.CreateAttribute("instruction");

            instructionAttribute.Value = scriptCommand.ToString();
            element.Attributes.Append(instructionAttribute);

            var exampleAttribute = xmlDocument.CreateAttribute("example");

            exampleAttribute.Value = example;
            element.Attributes.Append(exampleAttribute);

            var description = ProgrammableChip.GetCommandDescription(scriptCommand);

            var textNode = xmlDocument.CreateTextNode(description);

            element.AppendChild(textNode);

            root.AppendChild(element);
        }
Exemple #3
0
 public static string ToDescriptionString(this ScriptCommand val)
 {
     DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false);
     return(attributes.Length > 0 ? attributes[0].Description : string.Empty);
 }