|
1 | | -# <img src="https://github.com/CodeShayk/parsley.net/blob/master/Images/ninja-icon-16.png" alt="ninja" style="width:30px;"/> Parsley.Net v1.0.1 |
| 1 | +# <img src="https://github.com/CodeShayk/parsley.net/blob/master/Images/ninja-icon-16.png" alt="ninja" style="width:30px;"/> Parsley.Net v1.1.0 |
2 | 2 | [](https://badge.fury.io/nu/Parsley.Net) [](https://github.com/CodeShayk/Parsley.Net/blob/master/LICENSE.md) |
3 | 3 | [](https://github.com/CodeShayk/Parsley.Net/releases/latest) |
4 | 4 | [](https://github.com/CodeShayk/parsley.net/actions/workflows/Master-Build.yml) |
@@ -36,16 +36,78 @@ NuGet\Install-Package Parsley.Net |
36 | 36 | ``` |
37 | 37 | ### ii. Implementation: Using Parsley.Net |
38 | 38 | #### <ins>Step 1<ins>. Initialise and use Parser class. |
39 | | -`Parser` is an implementation of `IParser` interface that provides methods for |
| 39 | +`Parser` is an implementation of `IParser` interface that provides sync and async methods for |
40 | 40 | - parsing content of a file by specifying the file path |
41 | 41 | - parsing an array of delimiter separated strings |
| 42 | +- parsing a stream of delimiter separated strings |
| 43 | +- parsing byte array of delimiter separated strings |
42 | 44 |
|
43 | 45 | Please see below. |
44 | 46 | ``` |
45 | 47 | public interface IParser |
46 | 48 | { |
47 | | - public T[] Parse<T>(string filepath) where T : IFileLine, new(); |
48 | | - public T[] Parse<T>(string[] lines) where T : IFileLine, new(); |
| 49 | + /// <summary> |
| 50 | + /// Parses a file at the specified filepath into an array of objects of type T. |
| 51 | + /// </summary> |
| 52 | + /// <typeparam name="T"></typeparam> |
| 53 | + /// <param name="filepath"></param> |
| 54 | + /// <returns></returns> |
| 55 | + T[] Parse<T>(string filepath) where T : IFileLine, new(); |
| 56 | +
|
| 57 | + /// <summary> |
| 58 | + /// Parses an array of delimiter seperated strings into an array of objects of type T. |
| 59 | + /// </summary> |
| 60 | + /// <typeparam name="T"></typeparam> |
| 61 | + /// <param name="lines"></param> |
| 62 | + /// <returns></returns> |
| 63 | + T[] Parse<T>(string[] lines) where T : IFileLine, new(); |
| 64 | +
|
| 65 | + /// <summary> |
| 66 | + /// Parses a stream of delimiter separated records into an array of objects of type T. |
| 67 | + /// </summary> |
| 68 | + /// <typeparam name="T"></typeparam> |
| 69 | + /// <param name="stream"></param> |
| 70 | + /// <returns></returns> |
| 71 | + T[] Parse<T>(Stream stream) where T : IFileLine, new(); |
| 72 | +
|
| 73 | + /// <summary> |
| 74 | + /// Parses an array of bytes of delimiter separated records into an array of objects of type T. |
| 75 | + /// </summary> |
| 76 | + /// <typeparam name="T"></typeparam> |
| 77 | + /// <param name="bytes"></param> |
| 78 | + /// <returns></returns> |
| 79 | + T[] Parse<T>(byte[] bytes) where T : IFileLine, new(); |
| 80 | +
|
| 81 | + /// <summary> |
| 82 | + /// Asynchronously parses a file at the specified filepath into an array of objects of type T. |
| 83 | + /// </summary> |
| 84 | + /// <typeparam name="T"></typeparam> |
| 85 | + /// <param name="filepath"></param> |
| 86 | + /// <returns></returns> |
| 87 | + Task<T[]> ParseAsync<T>(string filepath) where T : IFileLine, new(); |
| 88 | +
|
| 89 | + /// <summary> |
| 90 | + /// Asynchronously parses an array of delimiter separated strings into an array of objects of type T. |
| 91 | + /// </summary> |
| 92 | + /// <typeparam name="T"></typeparam> |
| 93 | + /// <param name="lines"></param> |
| 94 | + /// <returns></returns> |
| 95 | + Task<T[]> ParseAsync<T>(string[] lines) where T : IFileLine, new(); |
| 96 | +
|
| 97 | + /// <summary> |
| 98 | + /// Asynchronously parses a stream of delimiter separated strings into an array of objects of type T. |
| 99 | + /// </summary> |
| 100 | + /// <typeparam name="T"></typeparam> |
| 101 | + /// <param name="stream"></param> |
| 102 | + /// <returns></returns> |
| 103 | + Task<T[]> ParseAsync<T>(Stream stream) where T : IFileLine, new(); |
| 104 | + /// <summary> |
| 105 | + /// Asynchronously parses an array of bytes of delimiter separated records into an array of objects of type T. |
| 106 | + /// </summary> |
| 107 | + /// <typeparam name="T"></typeparam> |
| 108 | + /// <param name="bytes"></param> |
| 109 | + /// <returns></returns> |
| 110 | + Task<T[]> ParseAsync<T>(byte[] bytes) where T : IFileLine, new(); |
49 | 111 | } |
50 | 112 | ``` |
51 | 113 | To initialise `Parser` class you could do it manually or use dependency injection as shown below. The parser class has parameterised constructor that takes the delimiter character to initialise the instance. Default character is ',' (comma) to initialise the parser for a CSV file parsing. |
|
0 commit comments