82 lines
1.8 KiB
Plaintext
82 lines
1.8 KiB
Plaintext
<#@ template language="C#" #>
|
|
<#@ assembly name="System.Core" #>
|
|
<#@ import namespace="System.Linq" #>
|
|
<#@ import namespace="System.Text" #>
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
<# var toPredictType = Definition[ToPredict]; #>
|
|
using System;
|
|
using System.Text;
|
|
using Microsoft.ML.Data;
|
|
|
|
namespace DictionaryToObjectConverterNamespace
|
|
{
|
|
public class <#= ClassName #> : testML.IDictionaryToObjectConverter
|
|
{
|
|
<# foreach (var key in Definition.Keys)
|
|
{
|
|
var type = Definition[key];
|
|
#>
|
|
|
|
[ColumnName("<#= key #>")]
|
|
public <#= type.FullName #> <#= key #> { get; set; }
|
|
<# } //Fin loop #>
|
|
|
|
public object this[string propertyName]
|
|
{
|
|
get { return GetValue(propertyName); }
|
|
set { SetValue(propertyName, value); }
|
|
}
|
|
|
|
public void SetValue(string propertyName, object value)
|
|
{
|
|
switch(propertyName)
|
|
{
|
|
<# foreach (var key in Definition.Keys) {
|
|
var type = Definition[key]; #>
|
|
case "<#= key #>": <#= key #> = (<#= type.FullName #>)value; break;
|
|
<# } #>
|
|
}
|
|
}
|
|
|
|
public object GetValue(string propertyName)
|
|
{
|
|
switch(propertyName)
|
|
{
|
|
<# foreach (var key in Definition.Keys) { #>
|
|
case "<#= key #>": return <#= key #>;
|
|
<# } #>
|
|
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public class <#= ClassName #>Prediction: testML.IDictionaryToObjectConverter
|
|
{
|
|
[ColumnName("PredictedLabel")]
|
|
public <#= toPredictType.FullName #> <#= ToPredict #> { get; set; }
|
|
|
|
public object this[string propertyName]
|
|
{
|
|
get { return GetValue(propertyName); }
|
|
set { SetValue(propertyName, value); }
|
|
}
|
|
|
|
public void SetValue(string propertyName, object value)
|
|
{
|
|
switch(propertyName)
|
|
{
|
|
case "<#= ToPredict #>": <#= ToPredict #> = (<#= toPredictType.FullName #>)value; break;
|
|
}
|
|
}
|
|
|
|
public object GetValue(string propertyName)
|
|
{
|
|
switch(propertyName)
|
|
{
|
|
case "<#= ToPredict #>": return <#= ToPredict #>;
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
} |