1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4-
51using LogExpert ;
62
73using Newtonsoft . Json ;
@@ -31,11 +27,11 @@ public virtual void Selected (ILogLineColumnizerCallback callback)
3127 ColumnList . Clear ( ) ;
3228 ColumnSet . Clear ( ) ;
3329
34- ILogLine line = callback . GetLogLine ( 0 ) ;
30+ var line = callback . GetLogLine ( 0 ) ;
3531
3632 if ( line != null )
3733 {
38- JObject json = ParseJson ( line ) ;
34+ var json = ParseJson ( line ) ;
3935 if ( json != null )
4036 {
4137 var fieldCount = json . Properties ( ) . Count ( ) ;
@@ -87,7 +83,7 @@ public virtual string[] GetColumnNames ()
8783 {
8884 var names = new string [ GetColumnCount ( ) ] ;
8985 var i = 0 ;
90- foreach ( JsonColumn column in ColumnList )
86+ foreach ( var column in ColumnList )
9187 {
9288 names [ i ++ ] = column . Name ;
9389 }
@@ -97,7 +93,7 @@ public virtual string[] GetColumnNames ()
9793
9894 public virtual IColumnizedLogLine SplitLine ( ILogLineColumnizerCallback callback , ILogLine line )
9995 {
100- JObject json = ParseJson ( line ) ;
96+ var json = ParseJson ( line ) ;
10197
10298 if ( json != null )
10399 {
@@ -106,7 +102,7 @@ public virtual IColumnizedLogLine SplitLine (ILogLineColumnizerCallback callback
106102
107103 var cLogLine = new ColumnizedLogLine { LogLine = line } ;
108104
109- Column [ ] columns = Column . CreateColumns ( ColumnList . Count , cLogLine ) ;
105+ var columns = Column . CreateColumns ( ColumnList . Count , cLogLine ) ;
110106
111107 columns . Last ( ) . FullValue = line . FullLine ;
112108
@@ -142,7 +138,7 @@ public virtual void PushValue (ILogLineColumnizerCallback callback, int column,
142138
143139 public virtual Priority GetPriority ( string fileName , IEnumerable < ILogLine > samples )
144140 {
145- Priority result = Priority . NotSupport ;
141+ var result = Priority . NotSupport ;
146142 if ( fileName . EndsWith ( "json" , StringComparison . OrdinalIgnoreCase ) )
147143 {
148144 result = Priority . WellSupport ;
@@ -159,7 +155,8 @@ protected static JObject ParseJson (ILogLine line)
159155 {
160156 return JsonConvert . DeserializeObject < JObject > ( line . FullLine , new JsonSerializerSettings ( )
161157 {
162- Error = ( sender , args ) => { args . ErrorContext . Handled = true ; } //We ignore the error and handle the null value
158+ //We ignore the error and handle the null value
159+ Error = ( sender , args ) => args . ErrorContext . Handled = true
163160 } ) ;
164161 }
165162
@@ -179,7 +176,7 @@ protected virtual IColumnizedLogLine SplitJsonLine (ILogLine line, JObject json)
179176
180177 var columns = json . Properties ( ) . Select ( property => new ColumnWithName { FullValue = property . Value . ToString ( ) , ColumnName = property . Name . ToString ( ) , Parent = cLogLine } ) . ToList ( ) ;
181178
182- foreach ( ColumnWithName jsonColumn in columns )
179+ foreach ( var jsonColumn in columns )
183180 {
184181 // When find new column in a log line, add a new column in the end of the list.
185182 if ( ! ColumnSet . Contains ( jsonColumn . ColumnName ) )
@@ -195,13 +192,13 @@ protected virtual IColumnizedLogLine SplitJsonLine (ILogLine line, JObject json)
195192 }
196193
197194 //
198- // Always rearrage the order of all json fields within a line to follow the sequence of columnNameList.
195+ // Always rearrange the order of all json fields within a line to follow the sequence of columnNameList.
199196 // This will make sure the log line displayed correct even the order of json fields changed.
200197 //
201198 List < IColumn > returnColumns = [ ] ;
202- foreach ( JsonColumn column in ColumnList )
199+ foreach ( var column in ColumnList )
203200 {
204- ColumnWithName existingColumn = columns . Find ( x => x . ColumnName == column . Name ) ;
201+ var existingColumn = columns . Find ( x => x . ColumnName == column . Name ) ;
205202 if ( existingColumn != null )
206203 {
207204 returnColumns . Add ( new Column ( ) { FullValue = existingColumn . FullValue , Parent = cLogLine } ) ;
0 commit comments