public System.String getReplacedLine(System.String strLine, System.String strFindWhat, System.String strReplaceWith) { System.String strReplacedLine; ECheckContainKey nECheckContainKey; //m_strCurrentLine = strLine; m_strFindWhat = strFindWhat; m_strReplaceWith = strReplaceWith; strReplacedLine = strLine; nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey; m_LineCheckContainKey.resetValue(strReplacedLine, strFindWhat); nECheckContainKey = m_LineCheckContainKey.checkContainKeyType(); while (true) { strReplacedLine = _CheckAndGetReplacedLine(strReplacedLine, nECheckContainKey); nECheckContainKey = ECheckContainKey.ECheckContainKey_NoKey; m_LineCheckContainKey.resetValue(strReplacedLine, strFindWhat); nECheckContainKey = m_LineCheckContainKey.checkContainKeyType(); if (ECheckContainKey.ECheckContainKey_NoKey == nECheckContainKey) { break;//while } } return(strReplacedLine); }
public System.Boolean checkContainKey() { System.Boolean bCheckRes = false; System.IO.StreamReader fileReadHander = null; //System.IO.FileInfo fileinfo = new System.IO.FileInfo(strDataSrcFile); fileReadHander = new System.IO.StreamReader(m_strFileName); System.String strGetLineSrc = System.String.Empty; // Read and display lines from the file until the end of // the file is reached. while ((strGetLineSrc = fileReadHander.ReadLine()) != null) { //check each line m_LineCheckContainKey.resetValue(strGetLineSrc, m_strKey); bCheckRes = m_LineCheckContainKey.checkContainKey(); if (bCheckRes) { break; } } fileReadHander.Close(); return(bCheckRes); }
public void _ProcessEachLine(System.String strLineSrc, System.IO.StreamWriter fileWriterHander) { System.Boolean bCheckContainKey = false; System.String strLineDest = System.String.Empty; EProcessLineWorkType nProcessLineWorkType = EProcessLineWorkType.LineWorkType_Copy; //log4net.LogManager.GetLogger("ExeLogger").Info(System.String.Format("_ProcessEachLine strLineSrc={0}", strLineSrc)); bCheckContainKey = false; m_pLineCheckContainKey.resetValue(strLineSrc, m_pDataChangeUserDefType.m_strFindWhat); bCheckContainKey = m_pLineCheckContainKey.checkContainKey(); nProcessLineWorkType = EProcessLineWorkType.LineWorkType_Copy; if (bCheckContainKey) { nProcessLineWorkType = EProcessLineWorkType.LineWorkType_ChangeUserDefType; } switch (nProcessLineWorkType) { case EProcessLineWorkType.LineWorkType_Copy: { strLineDest = strLineSrc; fileWriterHander.WriteLine(strLineDest); break; } case EProcessLineWorkType.LineWorkType_ChangeUserDefType: { //process //strLineDest = "//"; //strLineDest += strLineSrc; //fileWriterHander.WriteLine(strLineDest); strLineDest = strLineSrc; strLineDest = m_pLineOperChangeUserDefType.getReplacedLine( strLineSrc, m_pDataChangeUserDefType.m_strFindWhat, m_pDataChangeUserDefType.m_strReplaceWith); fileWriterHander.WriteLine(strLineDest); break; } default: { //copy strLineDest = strLineSrc; fileWriterHander.WriteLine(strLineDest); break; } }//switch return; }