private void RefactorFieldNamesInFieldReferences(CodeExpression expression, string newName)
{
// Do we have a field reference in the expression we are given?
if(typeof(CodeFieldReferenceExpression) != expression.GetType())
{
return;
}
CodeFieldReferenceExpression frefStatement = (CodeFieldReferenceExpression)expression;
// Is target object of field reference referring to a variable declaration?
if (typeof(CodeVariableReferenceExpression) == frefStatement.TargetObject.GetType())
{
CodeVariableReferenceExpression vrefStatement = (CodeVariableReferenceExpression)frefStatement.TargetObject;
// Get a reference to the variable declaration statement.
CodeVariableDeclarationStatement vdeclStatement = stackVariables[vrefStatement.VariableName];
// Is this a variable of type we are modifying now?
if (vdeclStatement.Type.BaseType == newName)
{
// Then we can convert the field names to PascalCase.
frefStatement.FieldName = PascalCaseConverterHelper.GetPascalCaseName(frefStatement.FieldName);
}
}
}