FreakySources.CodeDataGenerator.SubstituteParam C# (CSharp) Method

SubstituteParam() private method

private SubstituteParam ( StringBuilder source, CodeDataGeneratorParam p ) : void
source StringBuilder
p CodeDataGeneratorParam
return void
        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);
                }
            }
        }