Added some additional helper methods.
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MarketData.Utils;
|
||||
|
||||
namespace MarketDataLib.Utility
|
||||
{
|
||||
@@ -214,6 +212,33 @@ namespace MarketDataLib.Utility
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<int> LocateAllOccurrences(String strInput,String item)
|
||||
{
|
||||
List<int> itemIndices = new List<int>();
|
||||
|
||||
try
|
||||
{
|
||||
if(null==item||null==strInput)return null;
|
||||
List<String> sections=Sections.GetSections(strInput);
|
||||
if(null==sections||0==sections.Count)return null;
|
||||
for(int startIndex=0;startIndex<sections.Count;startIndex++)
|
||||
{
|
||||
String sectionItem=sections[startIndex];
|
||||
if(sectionItem.Contains(item))
|
||||
{
|
||||
itemIndices.Add(startIndex);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return itemIndices;
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String LocateItem(String strInput,String item,int maxDepth)
|
||||
{
|
||||
int startIndex=0;
|
||||
@@ -423,6 +448,18 @@ namespace MarketDataLib.Utility
|
||||
return strItem;
|
||||
}
|
||||
|
||||
public static String GetFirstNonEmptyItemInSection(List<String> sections, int startingIndex)
|
||||
{
|
||||
if(startingIndex>=sections.Count)return null;
|
||||
for(int index=startingIndex;index < sections.Count;index++)
|
||||
{
|
||||
String sectionItem = sections[index].Trim();
|
||||
if(String.IsNullOrEmpty(sectionItem))continue;
|
||||
return sectionItem;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String ScanSection(String strInput, ref int index)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user