Beispiel #1
0
 private string SearchCode(CodeDataGeneratorParam param)
 {
     foreach (var code in Codes)
     {
         int beginInd = code.IndexOf(param.KeyBegin);
         if (beginInd != -1)
         {
             int i = beginInd + param.KeyBegin.Length;
             while (i < code.Length && char.IsWhiteSpace(code[i]))
             {
                 i++;
             }
             i--;
             while (i >= 0 && char.IsWhiteSpace(code[i]) && code[i] != '\r' && code[i] != '\n')
             {
                 i--;
             }
             beginInd = i + 1;
             int endInd = code.IndexOf(param.KeyEnd, beginInd);
             if (endInd != -1)
             {
                 return(code.Substring(beginInd, endInd - beginInd).TrimEnd());
             }
         }
     }
     return(null);
 }
Beispiel #2
0
        private void SubstituteParam(StringBuilder source, CodeDataGeneratorParam p)
        {
            if (p.Value != null)
            {
                int beginInd = source.IndexOf(p.KeyBegin);
                if (beginInd != -1)
                {
                    int endInd = source.IndexOf(p.KeyEnd, beginInd);

                    int ind, length;
                    if (!p.SaveKey)
                    {
                        ind    = beginInd;
                        length = endInd + p.KeyEnd.Length - ind;
                    }
                    else
                    {
                        ind    = beginInd + p.KeyBegin.Length;
                        length = endInd - ind;
                    }
                    source = source.Remove(ind, length);

                    if (!IgnoreIndents)
                    {
                        source = InsertWithIndents(source, ind, p.Value);
                    }
                    else
                    {
                        source = source.Insert(ind, p.Value);
                    }
                }
            }
        }
        private void SubstituteParam(StringBuilder source, CodeDataGeneratorParam p)
        {
            if (p.Value != null)
            {
                int beginInd = source.IndexOf(p.KeyBegin);
                if (beginInd != -1)
                {
                    int endInd = source.IndexOf(p.KeyEnd, beginInd);

                    int ind, length;
                    if (!p.SaveKey)
                    {
                        ind = beginInd;
                        length = endInd + p.KeyEnd.Length - ind;
                    }
                    else
                    {
                        ind = beginInd + p.KeyBegin.Length;
                        length = endInd - ind;
                    }
                    source = source.Remove(ind, length);

                    if (!IgnoreIndents)
                        source = InsertWithIndents(source, ind, p.Value);
                    else
                        source = source.Insert(ind, p.Value);
                }
            }
        }
 private string SearchCode(CodeDataGeneratorParam param)
 {
     foreach (var code in Codes)
     {
         int beginInd = code.IndexOf(param.KeyBegin);
         if (beginInd != -1)
         {
             int i = beginInd + param.KeyBegin.Length;
             while (i < code.Length && char.IsWhiteSpace(code[i]))
                 i++;
             i--;
             while (i >= 0 && char.IsWhiteSpace(code[i]) && code[i] != '\r' && code[i] != '\n')
                 i--;
             beginInd = i + 1;
             int endInd = code.IndexOf(param.KeyEnd, beginInd);
             if (endInd != -1)
                 return code.Substring(beginInd, endInd - beginInd).TrimEnd();
         }
     }
     return null;
 }