public override bool Serialize(StringBuilder sb, int indent) { bool bSerializeSuc = false; bool bShowKeyName = ShowKeyName(); if (bShowKeyName) { ToLuaText.AppendIndent(sb, indent); sb.Append(strKeyNameInNestedTable); sb.Append(" = \n"); } indent = bShowKeyName ? indent + 1 : indent; if (VariationalSerialize(sb, indent)) { bSerializeSuc = true; } else if (bNestInArray) { ToLuaText.AppendIndent(sb, indent); sb.Append("{}"); bSerializeSuc = true; } return(bSerializeSuc); }
protected override bool VariationalSerialize(StringBuilder sb, int indent) { bool bSerializeSuc = false; ToLuaText.AppendIndent(sb, indent); sb.AppendFormat("--Key代表{0}\n", Desc); if (ToLuaText.TransferDic(nodeContainer, sb, indent)) { bSerializeSuc = true; } return(bSerializeSuc); }
public override bool Serialize(StringBuilder sb, int indent) { bool bSerializeSuc = false; bool bInvalidKeyName = string.IsNullOrEmpty(strKeyNameInNestedTable); bool bCellInValid = bInvalidData || (bInvalidKeyName && (cellType == null || !bNestInArray)); bool bShowKeyName = ((bNestInTable && !bNestInArray) || bColumnHead) && !bInvalidKeyName && !bSkipCurNest; if (bCellInValid && !bColumnHead) { return(bSerializeSuc); } ToLuaText.AppendIndent(sb, indent); if (bShowKeyName) { sb.Append(strKeyNameInNestedTable); sb.Append(" = "); } if (bContainsArray) { var tempStringArray = originalData.Split(cellArrayTag[0]); var convertMethod = convertArrayDataGenericMethod.MakeGenericMethod(new Type[] { cellType }); var transferMethod = ToLuaText.MakeGenericArrayTransferMethod(cellType); try { var dataArray = convertMethod.Invoke(this, new object[] { tempStringArray }); transferMethod.Invoke(dataArray, new object[] { dataArray, sb, 0 }); bSerializeSuc = true; } catch (System.Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("ConvertStringFillToArray ::src =" + originalData + " " + e.Message); } } else { ToLuaText.AppendValue(cellType, originalData, sb); bSerializeSuc = true; } string descFormatStr = "--{0}"; if (bColumnHead && bInvalidData) { sb.Remove(sb.Length - 2, 2); } else if (bInvalidData) { bSerializeSuc = false; } /// 加上bColumnHead判断是避免没写Desc和有效数据(originalData为空)导致序列化出错 if (!string.IsNullOrEmpty(Desc) || bColumnHead) { sb.AppendFormat(descFormatStr, Desc); } return(bSerializeSuc); }