Exemplo n.º 1
0
        public static Result <SisLine, Error> DeserializeSisLine(string line)
        {
            var cells = line.Split('\t');

            if (cells.Length < 5)
            {
                return(new Error($"Invalid tab count, cannot parse as SisLine: {line}"));
            }

            var pos = DiagramPosition.TryFrom(cells[0]);

            if (!int.TryParse(cells[1], out int qty))
            {
                return(new Error($"Could not parse line quantity: {line}"));
            }

            bool purch = cells[2].Contains("P");
            bool gp    = cells[2].Contains("G");
            bool ccr   = cells[2].Contains("C");

            var pn = PartNumber.Parse(cells[3]);

            var desc = PartDescription.Parse(cells[4]);

            return(pn
                   .CombineWith(desc)
                   .CombineWith(pos)
                   .Match(
                       ok => new SisLine(ok.Item1, ok.Item2, ok.Item3, qty, purch, gp, ccr),
                       err => Result.Error <SisLine, Error>(err)));
        }
Exemplo n.º 2
0
 public SisLine(
     PartNumber number,
     PartDescription description,
     DiagramPosition position,
     int quantity,
     bool purchasable  = true,
     bool isChildGroup = false,
     bool isCcrPart    = false)
 {
     Number       = number ?? throw new ArgumentNullException(nameof(number));
     Description  = description ?? throw new ArgumentNullException(nameof(description));
     Position     = position;
     Quantity     = Math.Max(1, quantity);
     Purchasable  = purchasable;
     IsChildGroup = isChildGroup;
     IsCcrPart    = isCcrPart;
 }