In This Topic
#include "StdAfx.h"
#pragma warning (push)
#pragma warning (disable:4251)
#pragma warning (disable:4786)
#include "../SimpleHierarchyLib.h"
#include "../SimpleHierarchyLib/Invoice.h"
namespace SimpleHierarchyLib
{
LtXmlLib20Data::CParentElementInfo* CInvoice::ms_pParentElementInfo = NULL;
LtXmlLib20Data::CAttributeInfo** CInvoice::ms_ppAttributeInfo = NULL;
LtXmlLib20Data::CElementInfo** CInvoice::ms_ppElementInfo = NULL;
CInvoicePtr CInvoice::CreateInstance(LPCTSTR lpctElementName)
{
return new SimpleHierarchyLib::CInvoice(lpctElementName);
}
CInvoice::CInvoice(LPCTSTR lpctElementName)
: CInstanceMonitor(_T("CInvoice"))
{
m_elementName = lpctElementName;
Init();
}
CInvoice::~CInvoice()
{
Cleanup();
}
void CInvoice::Cleanup()
{
// unregister for any events we have asked for
// cos there'll be no one left to hear soon
this->m_Item = NULL;
}
void CInvoice::OnEvent(LtXmlLib20::CXmlObjectBase* pMsgSource, LtXmlLib20::IEventSink::MsgType eMsgType, void* pData)
{
if (eMsgType == LtXmlLib20::IEventSink::MT_CollectionChangeEvent)
{
}
}
void CInvoice::Init()
{
Cleanup();
this->m_InvoiceNo = 0;
this->m_DeliveryAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CAddressType, _T("DeliveryAddress")).Ptr());
this->m_BillingAddress = NULL;
this->m_Item = dynamic_cast<SimpleHierarchyLib::CItemTypeCol*>(SimpleHierarchyLib::CClassFactory::CreateClassCollection(SimpleHierarchyLib::CClassFactory::ClsName_CItemTypeCol, _T("Item"), _T(""), 1, -1).Ptr());
this->m_Payment = dynamic_cast<SimpleHierarchyLib::CPayment*>(SimpleHierarchyLib::CClassFactory::CreateClass(SimpleHierarchyLib::CClassFactory::ClsName_CPayment, _T("Payment")).Ptr());
}
void CInvoice::AccessProperty(int iPropertyIndex, bool bRead, LtXmlLib20::LtVariant& rValue)
{
if (bRead)
{
switch(iPropertyIndex)
{
case 1:
rValue.SetUI4(GetInvoiceNo());
break;
case 2:
rValue.SetXmlObject(GetDeliveryAddress().Ptr());
break;
case 3:
rValue.SetXmlObject(GetBillingAddress().Ptr());
break;
case 4:
rValue.SetXmlCollection(GetItem().Ptr());
break;
case 5:
rValue.SetXmlObject(GetPayment().Ptr());
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
};
}
else
{
switch(iPropertyIndex)
{
case 1:
SetInvoiceNo(rValue.GetUI4());
break;
case 2:
SetDeliveryAddress(dynamic_cast<SimpleHierarchyLib::CAddressType*>(rValue.GetXmlObject().Ptr()));
break;
case 3:
SetBillingAddress(dynamic_cast<SimpleHierarchyLib::CAddressType*>(rValue.GetXmlObject().Ptr()));
break;
case 4:
throw LtXmlLib20::CLtException(_T("Collections can not be set"));
break;
case 5:
SetPayment(dynamic_cast<SimpleHierarchyLib::CPayment*>(rValue.GetXmlObject().Ptr()));
break;
default:
throw LtXmlLib20::CLtException(_T("Unknown Property Index"));
}
}
}
DWORD CInvoice::GetInvoiceNo() const
{
return this->m_InvoiceNo;
}
void CInvoice::SetInvoiceNo(DWORD value)
{
this->m_InvoiceNo = value;
}
SimpleHierarchyLib::CAddressTypePtr CInvoice::GetDeliveryAddress() const
{
return this->m_DeliveryAddress;
}
void CInvoice::SetDeliveryAddress(SimpleHierarchyLib::CAddressType* value)
{
Throw_IfPropertyIsNull(value, _T("DeliveryAddress"));
if (value != NULL)
SetElementName(value, _T("DeliveryAddress"));
this->m_DeliveryAddress = value;
}
SimpleHierarchyLib::CAddressTypePtr CInvoice::GetBillingAddress() const
{
return this->m_BillingAddress;
}
void CInvoice::SetBillingAddress(SimpleHierarchyLib::CAddressType* value)
{
if (value == NULL)
this->m_BillingAddress = NULL;
else
{
SetElementName(value, _T("BillingAddress"));
this->m_BillingAddress = value;
}
}
SimpleHierarchyLib::CItemTypeColPtr CInvoice::GetItem() const
{
return this->m_Item;
}
SimpleHierarchyLib::CPaymentPtr CInvoice::GetPayment() const
{
return this->m_Payment;
}
void CInvoice::SetPayment(SimpleHierarchyLib::CPayment* value)
{
Throw_IfPropertyIsNull(value, _T("Payment"));
if (value != NULL)
SetElementName(value, _T("Payment"));
this->m_Payment = value;
}
SimpleHierarchyLib::CInvoicePtr CInvoice::Clone() const
{
SimpleHierarchyLib::CInvoicePtr newObject = CreateInstance(m_elementName.c_str());
int index = 0;
newObject->m_InvoiceNo = m_InvoiceNo;
newObject->m_DeliveryAddress = NULL;
if (m_DeliveryAddress != NULL)
newObject->m_DeliveryAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(m_DeliveryAddress->Clone().Ptr());
newObject->m_BillingAddress = NULL;
if (m_BillingAddress != NULL)
newObject->m_BillingAddress = dynamic_cast<SimpleHierarchyLib::CAddressType*>(m_BillingAddress->Clone().Ptr());
for (index = 0; index < m_Item->GetCount(); index++)
newObject->m_Item->Add(dynamic_cast<SimpleHierarchyLib::CItemType*>(m_Item->Item(index)->Clone().Ptr()));
newObject->m_Payment = NULL;
if (m_Payment != NULL)
newObject->m_Payment = dynamic_cast<SimpleHierarchyLib::CPayment*>(m_Payment->Clone().Ptr());
return newObject.Ptr();
}
std::tstring CInvoice::GetTargetNamespace() const
{
return _T("");
}
std::tstring CInvoice::GetNamespace() const
{
return _T("");
}
LtXmlLib20::CXmlObjectBase* CInvoice::GetBase()
{
return this;
}
void CInvoice::CleanMetaData()
{
LtXmlLib20::CXmlGeneratedClass::CleanMetaData(ms_pParentElementInfo, ms_ppElementInfo, ms_ppAttributeInfo);
}
LtXmlLib20Data::CParentElementInfo* CInvoice::GetClassInfo() const
{
if (ms_pParentElementInfo == NULL)
{
m_csInit.Enter();
if (ms_pParentElementInfo == NULL)
{
ms_pParentElementInfo = new LtXmlLib20Data::CParentElementInfo(
LtXmlLib20Data::XmlElementGroupType_SEQUENCE,
LtXmlLib20Data::XmlElementType_ELEMENT,
_T("Invoice"),
_T(""),
true,
false,
-1,
LtXmlLib20::ItemType_none,
LtXmlLib20::CWhitespaceUtils::WhitespaceRule_None,
NULL,
false);
}
m_csInit.Leave();
}
return ms_pParentElementInfo;
}
LtXmlLib20Data::CElementInfo** CInvoice::GetClassElementInfo() const
{
if (ms_ppElementInfo == NULL)
{
m_csInit.Enter();
if (ms_ppElementInfo == NULL)
{
ms_ppElementInfo = new LtXmlLib20Data::CElementInfo*[6];
ms_ppElementInfo[0] = new LtXmlLib20Data::CElementInfoSeqPrimMnd(_T("InvoiceNo"), _T(""), 1, false, LtXmlLib20::ItemType_ui4, NULL, LtXmlLib20::CWhitespaceUtils::WhitespaceRule_Collapse, LtXmlLib20::CPrimitiveRestrictions(_T(""), -1, -1, _T(""), _T(""), _T(""), _T(""), -1, -1, -1), NULL);
ms_ppElementInfo[1] = new LtXmlLib20Data::CElementInfoSeqClsMnd(_T("DeliveryAddress"), _T(""), 2, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CAddressType, true);
ms_ppElementInfo[2] = new LtXmlLib20Data::CElementInfoSeqClsOpt(_T("BillingAddress"), _T(""), 3, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CAddressType);
ms_ppElementInfo[3] = new LtXmlLib20Data::CElementInfoSeqClsCol(_T("Item"), _T(""), 4, LtXmlLib20Data::XmlElementType_ELEMENT);
ms_ppElementInfo[4] = new LtXmlLib20Data::CElementInfoSeqClsMnd(_T("Payment"), _T(""), 5, LtXmlLib20Data::XmlElementType_ELEMENT, (LtXmlLib20Data::pfnCreateClassDef)&SimpleHierarchyLib::CClassFactory::CreateClass, SimpleHierarchyLib::CClassFactory::ClsName_CPayment, true);
ms_ppElementInfo[5] = NULL;
}
m_csInit.Leave();
}
return ms_ppElementInfo;
}
LtXmlLib20Data::CAttributeInfo** CInvoice::GetClassAttributeInfo() const
{
if (ms_ppAttributeInfo == NULL)
{
m_csInit.Enter();
if (ms_ppAttributeInfo == NULL)
{
ms_ppAttributeInfo = new LtXmlLib20Data::CAttributeInfo*[1];
ms_ppAttributeInfo[0] = NULL;
}
m_csInit.Leave();
}
return ms_ppAttributeInfo;
}
};