Exemplo n.º 1
0
        private PscCsv ReadLines <T>(IEnumerable <string> source)
        {
            PscCsv pscCsv = new PscCsv();

            if (source == null || source.Count() <= 0)
            {
                //Anti-pattern, new key work, refactor to an interface
                var error = new CsvErrorItem();
                error.Message = "Input string collection is null or empty";
                pscCsv.Errors.Error.Add(error);
            }

            using (IEnumerator <string> enumerator = source.GetEnumerator())
            {
                bool moreItems = enumerator.MoveNext();
                //Get the header line here
                if (moreItems)
                {
                    pscCsv.Headers.CsvHeaderLine = enumerator.Current;
                }

                int count = 0;
                while (moreItems)
                {
                    count++;
                    string stringLine = enumerator.Current;
                    //Do stuff
                    pscCsv.Data.Lines.Add(new CsvLineItem(stringLine, count, ""));
                    moreItems = enumerator.MoveNext();
                }
                //Take last line and add to csv footer...
            }

            return(pscCsv);
        }
Exemplo n.º 2
0
        private PscCsv ProcessCsv <T>(PscCsv pscCsv, ICsvLineSplitter CsvLineplitter /*Ilogger ?*/)
        {
            if (pscCsv.Data != null && pscCsv.Data.Lines != null)
            {
                //Set CSvHeader items from the first line - Add errors
                if (pscCsv.HasHeader)
                {
                    pscCsv.Headers.CsvHeaderLine = pscCsv.Data.Lines.First().Line ?? "";
                    //run method/s to calcualte header properties from T
                }
                else /*TODO: ? */ } {
                //Set footer items from last line items, remove last line - add errors
                if (pscCsv.HasFooter)
                {
                    /* Remove last line*/

                    if (pscCsv.Data.Lines.Last().Line
                        == pscCsv.Data.Lines.First().Line)
                    {
                        //TODO : can this be set to represent no data?
                    }
                    else
                    {
                        //Anti-pattern warning - footer needs an interface, be extensible for future requirements
                        var lastLine       = pscCsv.Data.Lines.Last().Line;
                        var footerElements = CsvLineplitter.CsvSplit(
                            lastLine, pscCsv.IsQuoted, true, pscCsv.Separator, pscCsv.Quote);
                        //Run footer get and set
                    }
                }
        }
Exemplo n.º 3
0
 public CsvHeaderItem GetHeaderItem(PscCsv pscCsv, int index)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 public IEnumerable <string> MakeCsv(PscCsv pscCsv)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public CsvHeader GetHeader(PscCsv pscCsv)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public CsvHeaderItem GetHeaderItem(PscCsv pscCsv, string fieldName)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
 public CsvLines GetCsvLines(PscCsv pscCsv)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
 public CsvErrorItem GetErrorItem(PscCsv pscCsv, int rowNo)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
 public CsvLineItem GetCsvLine(PscCsv pscCsv, int rowNo)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 10
0
 public CsvLines GetCsvLines(PscCsv pscCsv, int startRow, int endRow)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 11
0
 public CsvFooter GetCsvFooter(PscCsv pscCsv)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 12
0
 public CsvError GetCsvError(PscCsv pscCsv)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 13
0
 public IEnumerable <CsvColumn> GetCsvColumns(PscCsv pscCsv, IEnumerable <CsvHeaderItem> HeaderItems)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 14
0
 public IEnumerable <CsvColumn> GetCsvColumns(PscCsv pscCsv, IEnumerable <string> feildNames)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 15
0
 public CsvColumn GetCsvColumn(PscCsv pscCsv, int fieldName)
 {
     throw new NotImplementedException();
 }