<#@ template debug="true" hostSpecific="true" #>
<#@ output extension="log" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="System.Xml.Linq.dll" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Xml.Serialization" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="..\Common\CommonCodeblocks.ttinclude" #>
<#@ include file="..\ConsumerApp\ConsumerAppv10.ttinclude" #>
<#@ include file="..\OOP\OOPv10.ttinclude" #>
<#
string templateDirectoryName = Path.GetDirectoryName(Host.TemplateFile);
string directoryName = templateDirectoryName + @"\..\ConsumerApp\Contentv10";
string[] xmlFileNames = Directory.GetFiles(directoryName, "*.xml");
string targetDirectoryName = templateDirectoryName + @"\..\OOP\Contentv10";
foreach(string xmlFileName in xmlFileNames)
{
ConsumerApp_v1_0.ConsumerAppAbstraction abstraction = LoadXml<ConsumerApp_v1_0.ConsumerAppAbstraction>(xmlFileName);
TransformToOOPAbstraction(abstraction, targetDirectoryName, "ConsumerApp_" + Path.GetFileName(xmlFileName));
}
#>
<#+
void TransformToOOPAbstraction(ConsumerAppv10.ConsumerAppAbstraction abstraction, string targetDirectoryName, string targetFileName)
{
OOP_v1_0.OOPAbstraction result = new OOP_v1_0.OOPAbstraction();
result.ObjectTypes = new OOP_v1_0.OOPAbstractionObjectTypes[1];
OOP_v1_0.OOPAbstractionObjectTypes objectType = new OOP_v1_0.OOPAbstractionObjectTypes();
result.ObjectTypes[0] = objectType;
objectType.namespaceName = "ConsumerApp";
objectType.ObjectType = new OOP_v1_0.OOPAbstractionObjectTypesObjectType[1];
OOP_v1_0.OOPAbstractionObjectTypesObjectType oType = new OOP_v1_0.OOPAbstractionObjectTypesObjectType();
objectType.ObjectType[0] = oType;
oType.name = abstraction.ObjectType.name;
oType.Category = new OOP_v1_0.Category();
oType.Category.name = oType.name;
oType.Category.CategoryData = abstraction.ObjectType.Property.Select(prop => GetDataField(prop)).Union(GetDefaultFields()).ToArray();
WriteXml(result, targetDirectoryName + "\\" + targetFileName);
}
OOPv10.CategoryDataField GetDataField(ConsumerAppv10.Property property)
{
string fieldName = property.name;
while(fieldName.Contains(" "))
fieldName = fieldName.Replace(" ", "");
OOP_v1_0.CategoryDataField field = new OOP_v1_0.CategoryDataField();
field.absoluteType = "string";
field.name = fieldName;
return field;
}
OOPv10.CategoryDataField[] GetDefaultFields()
{
return new OOP_v1_0.CategoryDataField[]
{
new OOP_v1_0.CategoryDataField() { name = "ID", absoluteType = "long" },
new OOPv10.CategoryDataField() { name = "Version", absoluteType = "long" },
};
}
#>
<#@ output extension="log" #>
<#@ Assembly Name="System.Core.dll" #>
<#@ Assembly Name="System.Xml.dll" #>
<#@ Assembly Name="System.Xml.Linq.dll" #>
<#@ Assembly Name="System.Windows.Forms.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Xml.Serialization" #>
<#@ import namespace="System.Diagnostics" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="..\Common\CommonCodeblocks.ttinclude" #>
<#@ include file="..\ConsumerApp\ConsumerAppv10.ttinclude" #>
<#@ include file="..\OOP\OOPv10.ttinclude" #>
<#
string templateDirectoryName = Path.GetDirectoryName(Host.TemplateFile);
string directoryName = templateDirectoryName + @"\..\ConsumerApp\Contentv10";
string[] xmlFileNames = Directory.GetFiles(directoryName, "*.xml");
string targetDirectoryName = templateDirectoryName + @"\..\OOP\Contentv10";
foreach(string xmlFileName in xmlFileNames)
{
ConsumerApp_v1_0.ConsumerAppAbstraction abstraction = LoadXml<ConsumerApp_v1_0.ConsumerAppAbstraction>(xmlFileName);
TransformToOOPAbstraction(abstraction, targetDirectoryName, "ConsumerApp_" + Path.GetFileName(xmlFileName));
}
#>
<#+
void TransformToOOPAbstraction(ConsumerAppv10.ConsumerAppAbstraction abstraction, string targetDirectoryName, string targetFileName)
{
OOP_v1_0.OOPAbstraction result = new OOP_v1_0.OOPAbstraction();
result.ObjectTypes = new OOP_v1_0.OOPAbstractionObjectTypes[1];
OOP_v1_0.OOPAbstractionObjectTypes objectType = new OOP_v1_0.OOPAbstractionObjectTypes();
result.ObjectTypes[0] = objectType;
objectType.namespaceName = "ConsumerApp";
objectType.ObjectType = new OOP_v1_0.OOPAbstractionObjectTypesObjectType[1];
OOP_v1_0.OOPAbstractionObjectTypesObjectType oType = new OOP_v1_0.OOPAbstractionObjectTypesObjectType();
objectType.ObjectType[0] = oType;
oType.name = abstraction.ObjectType.name;
oType.Category = new OOP_v1_0.Category();
oType.Category.name = oType.name;
oType.Category.CategoryData = abstraction.ObjectType.Property.Select(prop => GetDataField(prop)).Union(GetDefaultFields()).ToArray();
WriteXml(result, targetDirectoryName + "\\" + targetFileName);
}
OOPv10.CategoryDataField GetDataField(ConsumerAppv10.Property property)
{
string fieldName = property.name;
while(fieldName.Contains(" "))
fieldName = fieldName.Replace(" ", "");
OOP_v1_0.CategoryDataField field = new OOP_v1_0.CategoryDataField();
field.absoluteType = "string";
field.name = fieldName;
return field;
}
OOPv10.CategoryDataField[] GetDefaultFields()
{
return new OOP_v1_0.CategoryDataField[]
{
new OOP_v1_0.CategoryDataField() { name = "ID", absoluteType = "long" },
new OOPv10.CategoryDataField() { name = "Version", absoluteType = "long" },
};
}
#>