public virtual string ToYaml(int indent = 0) { StringBuilder stringBuilder = new StringBuilder("\n"); FieldInfo[] fields = base.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic); string indet = MappingObject.GetIndet(indent); stringBuilder.AppendLine(string.Concat(new string[] { indet, "type: ", base.GetType().FullName, ", ", base.GetType().Assembly.GetName().Name })); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.StartsWith("_")) { string str = fieldInfo.Name.Substring(1); object value = fieldInfo.GetValue(this); string value2 = MappingObject.ObjectToYaml(value, indent + 1); stringBuilder.Append(indet); stringBuilder.Append(str + ":"); stringBuilder.AppendLine(value2); } } return(stringBuilder.ToString()); }
public static string ArrayToYaml(Array list, int indent = 0) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("\n"); foreach (object ovalue in list) { stringBuilder.Append(MappingObject.GetIndet(indent) + "-"); stringBuilder.AppendLine(MappingObject.ObjectToYaml(ovalue, indent + 1)); } return(stringBuilder.ToString()); }