// Copyright (c) 2007 Omer Rauchwerger (a.k.a rauchy) (omer@rauchy.net)
// All rights reserved.
//
// This file is part of Regionerate.
//
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
using System;
using System.Text;
using Rauchy.Regionerate.Domain.Entities;
namespace Rauchy.Regionerate.Shared.Components.Rendering
{
public class ContainerTypeRenderer : ICodeRenderer
{
#region Fields (1)
private readonly CodeLayout.Configuration _configuration;
#endregion Fields
#region Constructors (1)
///
/// Initializes a new instance of the class.
///
/// The configuration.
public ContainerTypeRenderer( CodeLayout.Configuration configuration )
{
_configuration = configuration;
}
#endregion Constructors
#region Methods (1)
// Public Methods (1)
// [rgn] Public Methods (1)
///
/// Creates a string representation for the provided .
///
///
/// Thrown when containerTypeCode is null.
///
public string Render( ContainerTypeCode containerTypeCode )
{
if ( containerTypeCode == null )
{
throw new ArgumentNullException( "containerTypeCode" );
}
StringBuilder builder = new StringBuilder();
builder.Append( containerTypeCode.Header.TrimEnd() );
builder.AppendLine();
StringBuilder memberBuilder = new StringBuilder();
foreach ( Code member in containerTypeCode.Members )
{
string memberText = RenderingCentral.Render( member, _configuration );
memberBuilder.Append( memberText );
}
builder.Append( memberBuilder.ToString().TrimNewLinesFromEnd() );
builder.Append( containerTypeCode.Footer.TrimNewLinesFromStart() );
return builder.ToString();
}
#endregion Methods
}
}