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

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