Example #1
0
        public override IEnumerable <string> Serialize(ConfigSerializer serializer, FieldInfo fieldInfo, SerializationInfo serializationInfo, int currentIndentation, int currentObjectDepth,
                                                       EFormatOption keyFormatOption, EFormatOption valueFormatOption)
        {
            IEnumerable <string> dataLines;

            keyFormatOption   = GetKeyFormatOption(keyFormatOption);
            valueFormatOption = GetValueFormatOption(valueFormatOption);

            if (serializationInfo.eDataType.IsSingleValueType())
            {
                string declarationString = ConfigSerializer.SerializeValueAssignmentDeclaration(name ?? fieldInfo.Name, currentIndentation + indentation, currentObjectDepth, keyFormatOption);
                string dataString        = ConfigSerializer.SerializeSingleValueType(serializationInfo, valueFormatOption);
                dataLines = new[] { declarationString + dataString };
            }
            else
            {
                string declarationString = ConfigSerializer.SerializeObjectAssignmentDeclaration(name ?? fieldInfo.Name, currentIndentation + indentation, currentObjectDepth, keyFormatOption);
                dataLines = new[] { declarationString }
                .Concat(serializer.SerializeMultiValueType(serializationInfo, currentIndentation + indentation, currentObjectDepth + 1, keyFormatOption, valueFormatOption));
            }
            return(Enumerable.Repeat("", emptyLinesAbove)
                   .Concat(comments.Select(comment => new string('\t', currentIndentation + indentation) + SpecialCharacters.singleLineComment + " " + comment))
                   .Concat(dataLines));
        }