コード例 #1
0
        public bool ReadLine([NotNullWhen(true)] out ChildrenList_ParentNullableRaw?childrenList_ParentNullableRaw)
        {
            if (csvReader.IsEndOfFileReached())
            {
                csvReader.Dispose();
                childrenList_ParentNullableRaw = null;
                return(false);
            }
            childrenList_ParentNullableRaw = new ChildrenList_ParentNullableRaw();
            var firstLineChar = csvReader.ReadFirstLineChar();

            if (firstLineChar == csvConfig.LineCharAdd)
            {
                childrenList_ParentNullableRaw.RawState = RawStateEnum.Read;
            }
            else if (firstLineChar == csvConfig.LineCharUpdate)
            {
                childrenList_ParentNullableRaw.RawState = RawStateEnum.Updated;
            }
            else if (firstLineChar == csvConfig.LineCharDelete)
            {
                childrenList_ParentNullableRaw.RawState = RawStateEnum.Deleted;
            }
            else
            {
                throw new NotSupportedException($"Illegal first line character '{firstLineChar}' found in '{csvReader.GetPresentContent()}'.");
            }
            childrenList_ParentNullableRaw.Key  = csvReader.ReadInt();
            childrenList_ParentNullableRaw.Text = csvReader.ReadString();
            csvReader.ReadEndOfLine();
            return(true);
        }
コード例 #2
0
 public void Write(ChildrenList_ParentNullableRaw childrenList_ParentNullableRaw)
 {
     if (childrenList_ParentNullableRaw.Key < 0)
     {
         throw new Exception($"ChildrenList_ParentNullableRaw's key {childrenList_ParentNullableRaw.Key} needs to be greater equal 0.");
     }
     if (childrenList_ParentNullableRaw.Key <= lastKey)
     {
         throw new Exception($"ChildrenList_ParentNullableRaw's key {childrenList_ParentNullableRaw.Key} must be greater than the last written ChildrenList_ParentNullable's key {lastKey}.");
     }
     lastKey = childrenList_ParentNullableRaw.Key;
     csvWriter.WriteFirstLineChar(csvConfig.LineCharAdd);
     csvWriter.Write(childrenList_ParentNullableRaw.Key);
     csvWriter.Write(childrenList_ParentNullableRaw.Text);
     csvWriter.WriteEndOfLine();
 }