Alexandria.Engines.GoldBox.Resources.ScriptOperand.ToString C# (CSharp) Méthode

ToString() public méthode

public ToString ( ) : string
Résultat string
        public override string ToString()
        {
            string validString = IsValid ? "" : "!!INVALID!!";
            string text = "";

            switch (Type) {
                case ScriptOperandType.Value:
                    text = string.Format("{0}", CoreIntegerValue);
                    if (CoreIntegerValue > 9)
                        text += string.Format("/{0:X2}h", CoreIntegerValue);
                    if (CoreIntegerValue > 127)
                        text += string.Format("/{0}", (sbyte)CoreIntegerValue);
                    return text;

                case ScriptOperandType.Address:
                    return string.Format("[{0:X}h]", AsAddress);

                case ScriptOperandType.String:
                    return "\"" + CoreStringValue + "\"" + validString;

                case ScriptOperandType.StringVariable:
                    return string.Format("String({0:X}h)", CoreIntegerValue);

                case ScriptOperandType.Opcode:
                    if (typeof(ScriptOpcode).IsEnumDefined((ScriptOpcode)CoreIntegerValue))
                        return ((ScriptOpcode)CoreIntegerValue).ToString() + validString;
                    return string.Format("!!!UnknownOpcode!!!:{0:X2}{1}", CoreIntegerValue, validString);

                case ScriptOperandType.Variable:
                    return string.Format("({0:X}h)", CoreIntegerValue);

                case ScriptOperandType.UnknownVariable:
                    return string.Format("UnknownVariable({0:X}h)", CoreIntegerValue);

                case ScriptOperandType.Comparison:
                    switch (AsComparison) {
                        case ScriptComparison.Equal: return "==";
                        case ScriptComparison.NotEqual: return "!=";
                        default: return string.Format("Comparison({0:X2}h)!!!!!!!!", CoreIntegerValue);
                    }

                case ScriptOperandType.None:
                    return "!!!None!!!";

                default:
                    throw new NotImplementedException();
            }
        }