Microsoft.Zing.Splicer.GetWriterStatement C# (CSharp) Method

GetWriterStatement() private method

private GetWriterStatement ( string prefix, TypeNode type, Identifier varName ) : Statement
prefix string
type TypeNode
varName Identifier
return Statement
        private Statement GetWriterStatement(string prefix, TypeNode type, Identifier varName)
        {
            Expression fullName;
            Statement writeStmt = null;

            TypeClassification typeClass = GetTypeClassification(type);

            if (prefix != null)
            {
                if (prefix == "this")
                {
                    fullName = Templates.GetExpressionTemplate("SimpleFieldRef");
                    Replacer.Replace(fullName, "_fieldName", varName);
                }
                else
                    fullName = (Expression)new QualifiedIdentifier(new Identifier(prefix), varName);
            }
            else
                fullName = (Expression)varName;

            switch (typeClass)
            {
                case TypeClassification.Simple:
                    // TODO: Sriram -- Clean this up and make this part of the classification
                    if (type.FullName == "System.String")
                        writeStmt = Templates.GetStatementTemplate("ConditionalWriter");
                    else
                        writeStmt = Templates.GetStatementTemplate("SimpleWriter");
                    break;

                case TypeClassification.Enum:
                    writeStmt = Templates.GetStatementTemplate("EnumWriter");
                    break;

                case TypeClassification.Struct:
                    writeStmt = Templates.GetStatementTemplate("StructWriter");
                    break;

                case TypeClassification.Heap:
                    writeStmt = Templates.GetStatementTemplate("ComplexWriter");
                    break;
            }

            Replacer.Replace(writeStmt, "_Name", fullName);

            return writeStmt;
        }