/// <summary> /// Arguments to string. /// </summary> /// <param name="textFormat">The text format.</param> /// <param name="key">The key.</param> /// <param name="value">The value.</param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public string ArgumentToString(docScriptInstructionTextFormatEnum textFormat, docScriptArguments key, object value) { string output = ""; if (defaultInstruction[key].toStringSafe() == this[key].toStringSafe()) { return(output); } switch (textFormat) { case docScriptInstructionTextFormatEnum.unknown: case docScriptInstructionTextFormatEnum.none: return(""); break; case docScriptInstructionTextFormatEnum.meta: output = key.ToString() + "=" + this[key].toExpressionString(); break; case docScriptInstructionTextFormatEnum.cs_compose: output = "arg(" + key.toExpressionString() + ", " + this[key].toExpressionString() + ")"; return(output); break; case docScriptInstructionTextFormatEnum.xml: output = key.ToString() + "=" + this[key].toExpressionString() + ")"; return(output); break; case docScriptInstructionTextFormatEnum.json: output = key.ToString() + ":" + this[key].toExpressionString() + ";"; return(output); break; default: throw new ArgumentOutOfRangeException(); } return(output); }
/// <summary> /// To the string. /// </summary> /// <param name="textFormat">The text format.</param> /// <returns></returns> /// <exception cref="ArgumentOutOfRangeException"></exception> public string ToString(docScriptInstructionTextFormatEnum textFormat) { string output = ""; switch (textFormat) { case docScriptInstructionTextFormatEnum.unknown: case docScriptInstructionTextFormatEnum.none: return(""); break; case docScriptInstructionTextFormatEnum.meta: output = "" + type.toExpressionString() + ":"; foreach (docScriptArguments key in Keys) { output = output.add(ArgumentToString(textFormat, key, this[key]), ";"); } return(output); break; case docScriptInstructionTextFormatEnum.cs_compose: output = "script.add(" + type.toExpressionString() + ")"; foreach (docScriptArguments key in Keys) { output = output.add(ArgumentToString(textFormat, key, this[key]), "."); } return(output); break; case docScriptInstructionTextFormatEnum.xml: string tag = type.ToString(); output = "<" + tag + " "; foreach (docScriptArguments key in Keys) { output = output.add(ArgumentToString(textFormat, key, this[key]), " "); } output = output.add("/>", " "); return(output); break; case docScriptInstructionTextFormatEnum.json: output = type.ToString() + " {".newLine(); foreach (docScriptArguments key in Keys) { output = output.add(ArgumentToString(textFormat, key, this[key]), Environment.NewLine).newLine(); } output = output.add("}", "").newLine(); return(output); break; default: throw new ArgumentOutOfRangeException(); } return(""); }