// XmlProjectSettings.cpp
//
#include "stdafx.h"
#include "XmlProjectSettings_CSharp.h"

CXmlProjectSettings_CSharp::CXmlProjectSettings_CSharp():
	enabled_(false)
{}

CXmlProjectSettings_CSharp::~CXmlProjectSettings_CSharp()
{}

bool CXmlProjectSettings_CSharp::BuildFromXml(IXMLDOMNode* node)
{
	Clear();

	ExtractMemberNode(node, _T("GenerationPath"), generationPath_);
	ExtractMemberNode(node, _T("ClassPrefix"), classPrefix_);
	ExtractMemberNode(node, _T("Enabled"), enabled_);
	ExtractMemberNode(node, CXmlProjectPostGen::GetXmlNodeName(), postGen_);

	return true;
}

bool CXmlProjectSettings_CSharp::AppendToDOMDocument(IXMLDOMDocument2* xmlDoc, IXMLDOMElement* parentElement)
{
	IXMLDOMElement* newElement;
	HRESULT hr;

	hr = xmlDoc->createElement(CComBSTR((const TCHAR*)GetXmlNodeName()), &newElement);
  
	AppendMemberNode(_T("GenerationPath"), generationPath_, newElement, xmlDoc);
	AppendMemberNode(_T("ClassPrefix"), classPrefix_, newElement, xmlDoc);
	AppendMemberNode(_T("Enabled"), enabled_, newElement, xmlDoc);

	postGen_.AppendToDOMDocument(xmlDoc, newElement);

	if (parentElement)
		hr = parentElement->appendChild(newElement, NULL);
	else
		hr = xmlDoc->appendChild(newElement, NULL);
	
	return true;
}

cmString CXmlProjectSettings_CSharp::GetGenerationPath() const
{
	return generationPath_;	
}

void CXmlProjectSettings_CSharp::SetGenerationPath(const cmString& generationPath)
{
	generationPath_ = generationPath;
}

cmString CXmlProjectSettings_CSharp::GetClassPrefix() const
{
	return classPrefix_;
}

void CXmlProjectSettings_CSharp::SetClassPrefix(const cmString& classPrefix)
{
	classPrefix_ = classPrefix;
}

void CXmlProjectSettings_CSharp::SetDefaults()
{}

void CXmlProjectSettings_CSharp::Clear()
{}

bool CXmlProjectSettings_CSharp::GetEnabled() const
{
	return enabled_;
}

void CXmlProjectSettings_CSharp::SetEnabled(bool enabled)
{
	enabled_ = enabled;
}

CXmlProjectPostGen* CXmlProjectSettings_CSharp::GetPostGenerationStep()
{
	return &postGen_;
}