public bool ReadLine([NotNullWhen(true)] out ChildrenList_ParentNullableReadonlyRaw?childrenList_ParentNullableReadonlyRaw) { if (csvReader.IsEndOfFileReached()) { csvReader.Dispose(); childrenList_ParentNullableReadonlyRaw = null; return(false); } childrenList_ParentNullableReadonlyRaw = new ChildrenList_ParentNullableReadonlyRaw(); var firstLineChar = csvReader.ReadFirstLineChar(); if (firstLineChar == csvConfig.LineCharAdd) { childrenList_ParentNullableReadonlyRaw.RawState = RawStateEnum.Read; } else if (firstLineChar == csvConfig.LineCharUpdate) { childrenList_ParentNullableReadonlyRaw.RawState = RawStateEnum.Updated; } else if (firstLineChar == csvConfig.LineCharDelete) { childrenList_ParentNullableReadonlyRaw.RawState = RawStateEnum.Deleted; } else { throw new NotSupportedException($"Illegal first line character '{firstLineChar}' found in '{csvReader.GetPresentContent()}'."); } childrenList_ParentNullableReadonlyRaw.Key = csvReader.ReadInt(); childrenList_ParentNullableReadonlyRaw.Text = csvReader.ReadString(); csvReader.ReadEndOfLine(); return(true); }
public void Write(ChildrenList_ParentNullableReadonlyRaw childrenList_ParentNullableReadonlyRaw) { if (childrenList_ParentNullableReadonlyRaw.Key < 0) { throw new Exception($"ChildrenList_ParentNullableReadonlyRaw's key {childrenList_ParentNullableReadonlyRaw.Key} needs to be greater equal 0."); } if (childrenList_ParentNullableReadonlyRaw.Key <= lastKey) { throw new Exception($"ChildrenList_ParentNullableReadonlyRaw's key {childrenList_ParentNullableReadonlyRaw.Key} must be greater than the last written ChildrenList_ParentNullableReadonly's key {lastKey}."); } lastKey = childrenList_ParentNullableReadonlyRaw.Key; csvWriter.WriteFirstLineChar(csvConfig.LineCharAdd); csvWriter.Write(childrenList_ParentNullableReadonlyRaw.Key); csvWriter.Write(childrenList_ParentNullableReadonlyRaw.Text); csvWriter.WriteEndOfLine(); }